MTK如何在java层直接下发at cmd

GeminiPhone.java/PhoneBase.java中提供了一个API: invokeOemRilRequestStrings(),通过该API可以将具体的at cmd命令下发并将命令执行结果返回给上层。

Demo code如下:

查询IMEI

import com.android.internal.telephony.Phone;

import com.android.internal.telephony.PhoneFactory;

import com.android.internal.telephony.gemini.GeminiPhone;

 

 Phone phone;

 phone = PhoneFactory.getDefaultPhone();

String ImeiString[]=new String[2];

ImeiString[0] = {"AT+EGMR=0,7"};

ImeiString[1] = {"+EGMR"};        //第二个string必须有,且名字是此AT名字,主要给rild用,不会下给modem;否则不会通过此channel返回上来response

 ((GeminiPhone) phone).invokeOemRilRequestStrings(ImeiString,mHandler.obtainMessage(EVENT_GET_IMEI_DONE_1));

 

public void handleMessage(Message msg) {

 switch (msg.what)

 {

  case EVENT_GET_IMEI_DONE_1:

         ar = (AsyncResult)msg.obj;

         Log.d (LOG_TAG, "mHandler.handleMessage() : EVENT_GET_IMEI_DONE_1");

                if (ar.exception == null) {//成功

                    Log.d(LOG_TAG, "ar.exception == null");

            String[] newIMEI=(String[])(ar.result);

                   StringBuilder sb=new StringBuilder();

                   for(int i=0;i<newIMEI.length;i++)

                            sb.append(newIMEI[i]);

                     Log.d("jby","newIMEI is : " +sb);

                }

         else

             Log.d(LOG_TAG, "ar.exception != null");//失败

          break;

   }

}

posted on 2012-08-20 16:24  RTFSC  阅读(3278)  评论(0编辑  收藏  举报

导航