Ejemplo n.º 1
0
static int onNewMesssageByIndex(char* s, char* sms_pdu)
{
	char *line = NULL;
	int err;
	/* can't issue AT commands here -- call on main thread */
	int index;
	char *response = NULL;
	line = strdup(s);
	at_tok_start(&line);

	err = at_tok_nextstr(&line, &response);
	if (err < 0) {
		LOGD("sms request fail");
		goto out;
	}

	if (strcmp(response, "SM")) {
		LOGD("sms request arrive but it is not a new sms");
		goto out;
	}


	/* Read the memory location of the sms */
	err = at_tok_nextint(&line, &index);
	if (err < 0) {
		LOGD("error parse location");
		goto out;
	}
out:
	free(line);
	RIL_requestTimedCallback (readMessageByIndex, (void *)index, NULL);
	return UNSOLICITED_SUCCESSED;
}
Ejemplo n.º 2
0
static int onMessageListing(char* s, char* sms_pdu)
{
	int*  index = malloc(sizeof(int));
	int stat = -1;
	char* line = NULL;
	line = strdup(s);
	at_tok_start(&line);
	at_tok_nextint(&line, index);
	at_tok_nextint(&line, &stat);
	RIL_requestTimedCallback (deleteMessageByIndex, index, NULL);

	if(stat == 0){
		RIL_onUnsolicitedResponse (
				RIL_UNSOL_RESPONSE_NEW_SMS,
				sms_pdu, strlen(sms_pdu));
	}
	free(line);
	return UNSOLICITED_SUCCESSED;
}
Ejemplo n.º 3
0
void triggerCellInfoList(void* param)
{
    // querying cell information when radio request pending or not registered
    // results in no response from modem.
    if (NULL == param || CTE::GetTE().IsRadioRequestPending() || !CTE::GetTE().IsRegistered())
    {
        CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        return;
    }

    // Get the CellInfo rate and compare.
    // if the newly set rate is less or equal,continue reading cellinfo from modem
    // if it is more, then start a new timed call back with the difference in timeout
    RIL_LOG_VERBOSE("triggerCellInfoList- Enter\r\n");
    int storedRate = CTE::GetTE().GetCellInfoListRate();
    int requestedRate = (int)param;
    RIL_LOG_INFO("triggerCellInfoList- StoredRate %d Rate with callback %d\r\n",
            storedRate, requestedRate);
    if (requestedRate >= storedRate || requestedRate <= 0)
    {
        REQUEST_DATA rReqData;

        memset(&rReqData, 0, sizeof(REQUEST_DATA));
        if (!CopyStringNullTerminate(rReqData.szCmd1, CTE::GetTE().GetReadCellInfoString(),
                sizeof(rReqData.szCmd1)))
        {
            RIL_LOG_CRITICAL("triggerCellInfoList() - Unable to create cellinfo command!\r\n");
            return;
        }

        rReqData.pContextData = (void*)requestedRate;

        // The rate setting has not changed while waiting for time out
        // read the cell information and report to framework
        CCommand* pCmd = new CCommand(g_pReqInfo[RIL_REQUEST_GET_CELL_INFO_LIST].uiChannel,
                NULL, RIL_REQUEST_GET_CELL_INFO_LIST, rReqData,
                &CTE::ParseUnsolCellInfoListRate, &CTE::PostUnsolCellInfoListRate);

        if (pCmd)
        {
            if (!CCommand::AddCmdToQueue(pCmd))
            {
                RIL_LOG_CRITICAL("triggerCellInfoList() - Unable to queue command!\r\n");
                delete pCmd;
                pCmd = NULL;
            }
        }
        else
        {
            RIL_LOG_CRITICAL("triggerCellInfoList() - "
                    "Unable to allocate memory for new command!\r\n");
        }

        /*
         * requestedRate <= 0 means that the cell information query is triggered on
         * cell information change. Stop the timer only if the query is due to
         * timer expiry.
         */
        if (requestedRate > 0)
        {
            CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        }
    }
    // the settings have changed to not to report CELLINFO
    else if (INT_MAX == storedRate)
    {
        CTE::GetTE().SetCellInfoTimerRunning(FALSE);
        RIL_LOG_INFO("triggerCellInfoList- Unsol cell info disabled: %d\r\n", storedRate);
    }
    else
    {
         // A new rate setting, re run the timer for the difference
         if (storedRate > requestedRate)
         {
             RIL_requestTimedCallback(triggerCellInfoList,
                   (void*)storedRate, ((storedRate - requestedRate) / 1000), 0);
         }
    }
    RIL_LOG_VERBOSE("triggerCellInfoList- Exit\r\n");
}
Ejemplo n.º 4
0
static void *
mainLoop(void *param)
{
    int fd;
    int ret;
    char path[50];
    int ttys_index;

    AT_DUMP("== ", "entering mainLoop()", -1 );
    at_set_on_reader_closed(onATReaderClosed);
    at_set_on_timeout(onATTimeout);

    for (;;) {
        fd = -1;
        while  (fd < 0) {
            if (s_port > 0) {
                fd = socket_loopback_client(s_port, SOCK_STREAM);
            } else if (s_device_socket) {
                if (!strcmp(s_device_path, "/dev/socket/qemud")) {
                    /* Qemu-specific control socket */
                    fd = socket_local_client( "qemud",
                                              ANDROID_SOCKET_NAMESPACE_RESERVED,
                                              SOCK_STREAM );
                    if (fd >= 0 ) {
                        char  answer[2];

                        if ( write(fd, "gsm", 3) != 3 ||
                             read(fd, answer, 2) != 2 ||
                             memcmp(answer, "OK", 2) != 0)
                        {
                            close(fd);
                            fd = -1;
                        }
                   }
                }
                else
                    fd = socket_local_client( s_device_path,
                                            ANDROID_SOCKET_NAMESPACE_FILESYSTEM,
                                            SOCK_STREAM );
            } else if (s_device_path != NULL) {
                fd = open (s_device_path, O_RDWR);
                if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
                    /* disable echo on serial ports */
                    struct termios  ios;
                    tcgetattr( fd, &ios );
                    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
                    ios.c_iflag = 0;
                    tcsetattr( fd, TCSANOW, &ios );
                }
            }
   

            if (fd < 0) {
                perror ("opening AT interface. retrying...");
                sleep(10);
                /* never returns */
            }
        }

        RLOGD("FD: %d", fd);

        s_closed = 0;
        ret = at_open(fd, onUnsolicited);

        if (ret < 0) {
            RLOGE ("AT error %d on at_open\n", ret);
            return 0;
        }

        RIL_requestTimedCallback(initializeCallback, NULL, &TIMEVAL_0);

        // Give initializeCallback a chance to dispatched, since
        // we don't presently have a cancellation mechanism
        sleep(1);

        waitForClose();
        RLOGI("Re-opening after close");
    }
}
Ejemplo n.º 5
0
static void *
mainLoop(void *param)
{
    AT_DUMP("== ", "entering mainLoop()", -1 );
    at_set_on_reader_closed(onATReaderClosed);
    at_set_on_timeout(onATTimeout);
    initRILChannels();
	RLOGI("[Emu]mainloop_in");
	RLOGI("[Emu]mainloop_in %d\n",s_device_socket);
	if(s_device_socket)
		{
		emulator_gemini_opensocket();
		return NULL;
	}
	else
		{
		int ret;
	       int i;
	    	RILChannelCtx * p_channel;
	
	    	for (;;) {

		        for (i=0; i < RIL_SUPPORT_CHANNELS; i ++)
		        {
		            p_channel = getChannelCtxbyId(i);

		            while (p_channel->fd < 0)
		            {
		                do {
		                    p_channel->fd = open(s_mux_path[i], O_RDWR);
		                } while (p_channel->fd < 0 && errno == EINTR);
		                
		                if (p_channel->fd < 0) 
		                {
		                    perror ("opening AT interface. retrying...");
		                    RLOGE("could not connect to %s: %s",  s_mux_path[i], strerror(errno));
		                    sleep(10);
		                    /* never returns */
		                }
		                else
		                {
		                    struct termios  ios;
		                    tcgetattr(p_channel->fd, &ios );
		                    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
                  			  ios.c_iflag = 0;
		                    tcsetattr(p_channel->fd, TCSANOW, &ios );
		                }
		            }
		            
		            
		            s_closed = 0;
		            ret = at_open(p_channel->fd,onUnsolicited, p_channel);
		            
		            
		            if (ret < 0) {
		                RLOGE ("AT error %d on at_open\n", ret);
		                return 0;
		            }
	      		  }

		        RIL_requestTimedCallback(initializeCallback, &s_pollSimId, &TIMEVAL_0);
#ifdef MTK_GEMINI
		        RIL_requestTimedCallback(initializeCallback, &s_pollSimId2, &TIMEVAL_0);
#endif 

		        // Give initializeCallback a chance to dispatched, since
		        // we don't presently have a cancellation mechanism
		        sleep(1);

		        waitForClose();
		        RLOGI("Re-opening after close");
		}
   	 }
	
}
Ejemplo n.º 6
0
static void emulator_gemini_opensocket()
{
	int fd;
    		int ret;
		for (;;) {
       		 fd = -1;
			RLOGI("[Emu]emulator_gemini_opensocket_in\n");
			
			RLOGI("[Emu]s_device_socket %d\n",s_device_socket);
			RLOGI("[Emu]s_port %d\n",s_port);
			 while  (fd < 0) {
           			 if (s_port > 0) {
            			    fd = socket_loopback_client(s_port, SOCK_STREAM);
							RLOGI("[Emu]fd1 %d\n",fd);
          			  } else if (s_device_socket) {
            				    if (!strcmp(s_device_path, "/dev/socket/qemud")) {
	                			    /* Qemu-specific control socket */
	             			           fd = socket_local_client( "qemud",
	                                              ANDROID_SOCKET_NAMESPACE_RESERVED,
	                                              SOCK_STREAM );
								RLOGI("[Emu]fd2 %d\n",fd);	
	                 			   if (fd >= 0 ) {
	                 		         	   char  answer[2];

				                        if ( write(fd, "gsm", 3) != 3 ||
				                             read(fd, answer, 2) != 2 ||
				                             memcmp(answer, "OK", 2) != 0)
				                        {
				                            close(fd);
				                            fd = -1;
				                        }
                  		 	 	 }
		            	 	   }
		                	   else {
						  fd = socket_local_client( s_device_path,
                                            ANDROID_SOCKET_NAMESPACE_FILESYSTEM,
                                            SOCK_STREAM );
						}
							   RLOGI("[Emu]fd3 %d\n",fd);
                   			
            				} else if (s_device_path != NULL) {
                				fd = open (s_device_path, O_RDWR);
               				 if ( fd >= 0 && !memcmp( s_device_path, "/dev/ttyS", 9 ) ) {
				                 	/* disable echo on serial ports */
				                    struct termios  ios;
				                    tcgetattr( fd, &ios );
				                    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
							  ios.c_iflag = 0;		
				                    tcsetattr( fd, TCSANOW, &ios );
				                }
							 RLOGI("[Emu]fd4 %d\n",fd);
			            }

			            if (fd < 0) {
							 RLOGI("[Emu]fd<0");
			                perror ("opening AT interface. retrying...");
			                sleep(10);
			                /* never returns */
			            }
       		 }

		        s_closed = 0;
		        ret = at_open_emulator(fd, onUnsolicited,is_gemini_emulator);

		        if (ret < 0) {
		            RLOGE ("AT error %d on at_open\n", ret);
		            return 0;
		        }
			RLOGI("[Emu]RIL_requestTimedCallback");
			RIL_requestTimedCallback(initializeCallback, &s_pollSimId, &TIMEVAL_0);
#ifdef MTK_GEMINI
			RIL_requestTimedCallback(initializeCallback, &s_pollSimId2, &TIMEVAL_0);
#endif 
				RLOGI("[Emu]RIL_requestTimedCallback out");
			// Give initializeCallback a chance to dispatched, since
			// we don't presently have a cancellation mechanism
			sleep(1);
			
			waitForClose();
			RLOGI("Re-opening after close");

		}
}