zoukankan      html  css  js  c++  java
  • Android连载40-ITelecomService详解

    一、拨号流程总结

    • DialpadFragment提供用户拨号的交互界面
    • CallIntentBuilder创建拨号请求的intent对象
    • TelecomManager继续传递拨号请求intent对象 40.1

    二、ITelecomService接收拨号请求服务

    • /packages/services/Telecomm/src/com/android/server/telecom这个代码库编译出来就是Telecom.apk Android应用程序,后面统一称为Telecom应用
            <service android:name=".components.TelecomService"
                    android:singleUser="true"
                    android:process="system">
                <intent-filter>
                    <action android:name="android.telecom.ITelecomService" />
                </intent-filter>
            </service>
    • 指定进程为system,也就是这个服务将会运行在system_server系统,唯一的action为android.telecom.ITelecomService.

    注意:Dialer应用的com.android.dialer进程提供用户拨号界面并且响应用户的拨号请求,把拨号请求包装成action为Intent.ACTION_CALL的intent对象,通过调用ITelecomService提供的placeCall接口,将拨号请求intent发送给了Telelcom应用(system_server进程),完成了第一次跨进程的服务调用。

    • 看一下TelecomServiceImpl.java文件中的placeCall方法
    public void placeCall(Uri handle, Bundle extras, String callingPackage) {
                try {
                    Log.startSession("TSI.pC");
                    enforceCallingPackage(callingPackage);

                    PhoneAccountHandle phoneAccountHandle = null;
                    if (extras != null) {
                        phoneAccountHandle = extras.getParcelable(
                                TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
                        if (extras.containsKey(TelecomManager.EXTRA_IS_HANDOVER)) {
                            // This extra is for Telecom use only so should never be passed in.
                            extras.remove(TelecomManager.EXTRA_IS_HANDOVER);
                        }
                    }
                    boolean isSelfManaged = phoneAccountHandle != null &&
                            isSelfManagedConnectionService(phoneAccountHandle);
                    if (isSelfManaged) {
                        mContext.enforceCallingOrSelfPermission(Manifest.permission.MANAGE_OWN_CALLS,
                                "Self-managed ConnectionServices require MANAGE_OWN_CALLS permission.");

                        if (!callingPackage.equals(
                                phoneAccountHandle.getComponentName().getPackageName())
                                && !canCallPhone(callingPackage,
                                "CALL_PHONE permission required to place calls.")) {
                            // The caller is not allowed to place calls, so we want to ensure that it
                            // can only place calls through itself.
                            throw new SecurityException("Self-managed ConnectionServices can only "
                                    + "place calls through their own ConnectionService.");
                        }
                    } else if (!canCallPhone(callingPackage, "placeCall")) {
                        throw new SecurityException("Package " + callingPackage
                                + " is not allowed to place phone calls");
                    }

    三、源码:

  • 相关阅读:
    hadoop-eclipse插件的使用
    python IDLE的执行py文件
    【转】Java Commons.IO 库官方文档
    【转】Java 集合框架之 WeakHashMap 和 IdentityHashMap 介绍
    JavaSE 中的队列简介
    【转】Java 集合之Hash 表
    【转】博客园转载别人的文章
    Java 中 深入理解 HashMap 和 TreeMap 的区别
    Java 中 equals() 和 hashcode() 方法详解
    百度搜索常用技巧
  • 原文地址:https://www.cnblogs.com/ruigege0000/p/14716380.html
Copyright © 2011-2022 走看看