Esempio n. 1
0
static int
timer_handler(const Event_t *event, void *funcdata)
{
  Conn_t *tmp;

  assert(event->data != NULL);
  tmp = (Conn_t *)event->data;
  dump_conn(tmp);
  tmp->state = call_state(CE_TIMER, 0, tmp);
  return 1;
}
void PhoneMachine::receiveSolicited(const Parcel& data)
{
    int serial = data.readInt32();
    int result = data.readInt32();
    RILRequest *request = getPending(serial);

    if (!request) {
	SLOGW("receiveSolicited: not requested serial=%d result=%d\n", serial, result);
	return;
    }
    SLOGV("<<< Solicited message=%s [%d] serial=%d result=%d\n", rilMessageStr(request->message()), 
	   request->message(), serial, result);
    int token   = request->token();
    int message = request->message();
    int ivalue  = 0;
    Parcel extra;
    switch (message) {
    case RIL_REQUEST_GET_SIM_STATUS: 
	ivalue = data.readInt32();   // Store the card state
	break;
    case RIL_REQUEST_GET_CURRENT_CALLS: {
	// We retrieve audio information for the client.
	// We also update the AudioFlinger audio state appropriately based
	//   on the current call state
	ivalue = data.readInt32();   // How many calls there are
	audio_mode_t audio_mode = AUDIO_MODE_NORMAL;
	for (int i = 0 ; i < ivalue ; i++) {
	    RILCall call(data);
	    CallState call_state(call.state, call.index, 
				 call.number, call.numberPresentation, 
				 call.name, call.namePresentation);
	    call_state.writeToParcel(&extra);
	    if (call.state == RIL_CALL_INCOMING)
		audio_mode = AUDIO_MODE_RINGTONE;
	    else if (call.state == RIL_CALL_ACTIVE || call.state == RIL_CALL_DIALING || call.state == RIL_CALL_ALERTING)
		audio_mode = AUDIO_MODE_IN_CALL;
	}
	SLOGV("    %d calls, audio_mode=%d\n", ivalue, audio_mode);
	updateAudioMode(audio_mode);
        break;
        }
    case RIL_REQUEST_DIAL:
    case RIL_REQUEST_HANGUP:
    case RIL_REQUEST_ANSWER:
    case RIL_REQUEST_UDUB:
    case RIL_REQUEST_SET_MUTE:
	break;
    case RIL_REQUEST_GET_MUTE:
	ivalue = data.readInt32();
	break;
    case RIL_REQUEST_SIGNAL_STRENGTH:
	// In actuality, we should probably read all 12 signal strengths
	ivalue = data.readInt32();
	break;
#if defined(SHORT_PLATFORM_VERSION) && (SHORT_PLATFORM_VERSION == 23)
#else
    case RIL_REQUEST_VOICE_REGISTRATION_STATE:
	ivalue = data.readInt32();   // Starts with the number of strings
	for (int i = 0 ; i < ivalue ; i++)
	    extra.writeString16(data.readString16());
	break;
#endif
    case RIL_REQUEST_OPERATOR: {
	ivalue = data.readInt32();
	assert(ivalue == 3);
	extra.writeString16(data.readString16());
	extra.writeString16(data.readString16());
	extra.writeString16(data.readString16());
        break;
        }
    case RIL_REQUEST_RADIO_POWER:
	SLOGV("    RIL Radio Power\n");
	// No response....
	break;
    default:
	SLOGV("Unhandled RIL request %d\n", message);
	break;
    }
    if (request->client() != NULL) {
	SLOGV("    Passing solicited message to client token=%d message=%d result=%d ivalue=%d...\n",
	       token, message, result, ivalue);
	request->client()->Response( token, message, result, ivalue, extra );
    }
    delete request;
}
Esempio n. 3
0
/*
 * Handle new connections or data arrival
 * data points to Conn_t
 */
static int
data_handler(const Event_t *event, void *funcdata)
{
  Conn_t *tmp, *newconn;
  int fd, nbytes;
  static char buffer[BUFSIZE];
  LaneControl_t *ctmp;
  struct sockaddr_atmsvc addr;

  assert(event->data != NULL);
  tmp = (Conn_t *)event->data;
  dump_conn(tmp);
  if (tmp->type == CT_MAIN) {
    nbytes = sizeof(addr);
    memset(&addr,0, nbytes);
    fd = accept(tmp->fd, (struct sockaddr *)&addr, &nbytes);
    if (fd <0) {
      dump_error(&conn_unit, "accept");
      if (errno == ENETRESET) {
	Debug_unit(&conn_unit,"Restart. Sleeping 10 secs...");
	sleep(10);
	event_put(&conn_unit, CE_RESTART, NULL);
      } else if (errno == EUNATCH) {
	Debug_unit(&conn_unit,"Exiting...");
	event_put(&conn_unit, CE_EXIT, NULL);
      }
      return -1;
    }
    newconn = conn_add(CT_SVC_CD, fd,0);
    newconn->state = call_state(CE_SVC_OPEN, 0, newconn);
  }
  else {
    /* tmp->fd or tmp->sfd ?*/
    nbytes = read(tmp->active_fd, buffer, BUFSIZE);
    if (nbytes < 0) {
      dump_error(&conn_unit, "read");
      if (errno == EUNATCH)
	event_put(&conn_unit, CE_EXIT, NULL);
      if (errno == ENETRESET) {
	Debug_unit(&conn_unit, "Restart. Sleeping 10 secs...");
	sleep(10);
	event_put(&conn_unit, CE_RESTART, NULL);
      }
    } else if (nbytes == 0) {
      /* EOF */
      Debug_unit(&conn_unit, "EOF");
      tmp->state = call_state(CE_SVC_CLOSE, 0, tmp);
    } else {
      buffer[nbytes] = '\0';
      Debug_unit(&conn_unit, "Data: %2.2x %2.2x %2.2x", 
		 0xff&buffer[0],0xff&buffer[1],0xff&buffer[2]);
      ctmp = (LaneControl_t *)buffer;
      if (is_control(ctmp) == 1) {
	control_packet = (LaneControl_t*)buffer;
	dump_control(ctmp);
	tmp->proxy = is_proxy();
	tmp->state = call_state(CE_DATA, ctmp->opcode, tmp);
      } else
	Debug_unit(&conn_unit,"Not a control_packet, discarding...");
    }
  }
  mem_free(&conn_unit, event);
  return 1;
}