一、撥號流程總結
DialpadFragment提供用戶撥號的互動界面 CallIntentBuilder創建撥號請求的intent物件 TelecomManager繼續傳遞撥號請求intent物件 
二、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");
}
三、原始碼:
https://github.com/ruigege66/Android/tree/master/ContactsTestCSDN:https://blog.csdn.net/weixin_44630050 博客園:https://www.cnblogs.com/ruigege0000/ 歡迎關注微信公眾號:傅里葉變換,個人賬號,僅用于技術交流
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/281193.html
標籤:Android
