zoukankan      html  css  js  c++  java
  • Android RIL CDMA分支总结(1)

    1. CDMA分支代码结构

    代码结构如下:
    ril
    |-- include
    | `-- telephony
    | |-- ril.h
    | `-- ril_cdma_sms.h
    |-- libril
    | |-- ril.cpp
    | |-- ril_commands.h
    | |-- ril_event.cpp
    | |-- ril_event.h
    | `-- ril_unsol_commands.h
    |-- reference-cdma-sms
    | |-- reference-cdma-sms.c
    | `-- reference-cdma-sms.h
    |-- reference-ril
    | |-- at_tok.c
    | |-- at_tok.h
    | |-- atchannel.c
    | |-- atchannel.h
    | |-- misc.c
    | |-- misc.h
    | `-- reference-ril.c
    `-- rild
    |-- radiooptions.c
    `-- rild.c

    reference-ril->libference-ril.so 主要负责modem通信(包含通话、上网、短信以及modem初始化功能等等)

    rild -> rild  rild守护进程,是整个android ril层的入口点。

    libril -> libril.so rild的共享库,驻留在rild中,完成和上层通信的工作,接受ril请求并传递给libreference-ril.so来通知modem,与此同时将其反馈回传给调用进程。

    radiooptions -> radiooptions  无线通信测试程序。

    reference-cdma-sms -> cdma模组特殊定义用于cdma(evdo)通信使用,主要定义短信接口(实现短息的编码解码工作)。

    2.AT从界面到模组流程

    通话外例:

    按通话图标->>

    DialtactsActivity(4个Tab 分别由TwelveKeyDialer<拨号>、RecentCallsListActivity<最近联系人>,两个activity-alias DialtactsContactsEntryActivity<联系人>和DialtactsFavoritesEntryActivity<收藏>)

    输入拨号号码

    TwelveKeyDialer

            mehod: Onclick

            placecall()

                Intent intent =new Intent(Intent.ACTION_CALL_PRIVILEGED,

                           Uri.fromParts("tel",number,null));

                           intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                           startActivity(intent);

    启动拨号->>>>>>

    intert.ACTION_CALL_PRIVILEGED实际字符串为android.intent.action.CALL_PRIVILEGED,通过查找知道了packegs/phone

    下面的androidmanifest.xml中PrivilegedOutgoingCallBroadcaster activity-alias设置了intent-filter,所以需要找到其targetactivity为OutgoingCallBroadcaster。所以进入OutgoingCallBroadcaster的

      method:onCreate()

      //如果为紧急号码马上启动intent.setClass(this, InCallScreen.class); startActivity(intent);

      Intent broadcastIntent = new Intent(Intent.ACTION_NEW_OUTGOING_CALL);

            if (number != null) broadcastIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number);

            broadcastIntent.putExtra(EXTRA_ALREADY_CALLED, callNow);

            broadcastIntent.putExtra(EXTRA_ORIGINAL_URI, intent.getData().toString());

            if (LOGV) Log.v(TAG, "Broadcasting intent " + broadcastIntent + ".");

            sendOrderedBroadcast(broadcastIntent, PERMISSION, null, null,

                                 Activity.RESULT_OK, number, null);

       

    Intent.ACTION_NEW_OUTGOING_CALL实际字符串为android.intent.action.NEW_OUTGOING_CALL,通过查找知道了packegs/phone下面的androidmanifest.xml中OutgoingCallReceiver Receiver接收此intent消息。找到OutgoingCallReceiver,执行

    mothod:onReceive()函数

      Intent newIntent = new Intent(Intent.ACTION_CALL, uri);

            newIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number);

            newIntent.setClass(context, InCallScreen.class);

            newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    《整个流程》

    mothod:onCreate(第一次)/onNewIntent(非第一次)

      internalResolveIntent

        placeCall(intent);

          PhoneUtils.placeCall(mPhone, number, intent.getData());

            phone.dial(number);

              mCT.dial(newDialString);

                dial(dialString, CommandsInterface.CLIR_DEFAULT);

                  cm.dial(pendingMO.address, clirMode, obtainCompleteMessage());//obtainCompleteMessage(EVENT_OPERATION_COMPLETE);

                    send(rr);

                      msg = mSender.obtainMessage(EVENT_SEND, rr);

                      acquireWakeLock();

                      msg.sendToTarget();

                    RILSender.handleMessage()  //已经到系统java ril<gsm &cdma>处理部分

                      case EVENT_SEND:

                        ...

                        s.getOutputStream().write(dataLength);                   

                        s.getOutputStream().write(data);//从这里流程跑到下面ril.cpp中监听部份

    RIL层

    rild守护进程 rild->main=>RIL_startEventLoop

          //建立事件循环线程

        ret = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);

          //注册进程唤醒事件回调

          ril_event_set (&s_wakeupfd_event, s_fdWakeupRead, true,

                    processWakeupCallback, NULL);

          rilEventAddWakeup (&s_wakeupfd_event);

          //建立事件循环

          ril_event_loop

            for (;;) {

              ...

              n = select(nfds, &rfds, NULL, NULL, ptv);

              // Check for timeouts

              processTimeouts();

              // Check for read-ready

              processReadReadies(&rfds, n);

              // Fire away

              firePending();

            }

           funcs = rilInit(&s_rilEnv, argc, rilArgv);//实际是通过动态加载动态库的方式执行reference-ril.c中的RIL_Init

        

          //单独启动一个线程读取串口数据

           ret = pthread_create(&s_tid_mainloop, &attr, mainLoop, NULL);

           fd = open (s_device_path, O_RDWR);//打开虚拟模组

           ret = at_open(fd, onUnsolicited);  //设置模组主动上报

           ret = pthread_create(&s_tid_reader, &attr, readerLoop, &attr);

           RIL_requestTimedCallback(initializeCallback, NULL, &TIMEVAL_0);

    reference-ril.so 处理方式(rild动态加载libreference-ril.so库)

          (处理模型)

          >static void request(x x x)

             switch(x)    //判断请求类型

                  request_dail //电话请求

                      function()  //请求处理函数AT指令

         设置事件回报//

    参考文献:

    http://blog.csdn.net/basonjiang_sz/archive/2011/03/17/6255881.aspx

    Android GSM驱动模块详细分析(作者:熊猫哥哥)

  • 相关阅读:
    jython resources
    Installing a Library of Jython ScriptsPart of the WebSphere Application Server v7.x Administration Series Series
    jython好资料
    ulipad install on 64bit win7 has issue
    an oracle article in high level to descibe how to archtichre operator JAVA relevet project
    table的宽度,单元格内换行问题
    Linux常用命令大全
    dedecms系统后台登陆提示用户名密码不存在
    登录织梦后台提示用户名不存在的解决方法介绍
    Shell常用命令整理
  • 原文地址:https://www.cnblogs.com/yuzaipiaofei/p/4124192.html
Copyright © 2011-2022 走看看