撥出電話流程:
1、Contacts的AndroidManifest.xml 中android:process="android.process.acore"說明此應用程式運作在acore程序中。
DialtactsActivity的intent-filter的action屬性設定為main,catelog屬性設定為launcher,是以此activity能出現在主菜單中,并且是點選此應用程式的第一個界面。dialtactsactivity包含四個tab,分别由TwelveKeyDialer、RecentCallsListActivity,兩個activity-alias DialtactsContactsEntryActivity和DialtactsFavoritesEntryActivity分别表示聯系人和收藏tab,但是正真的聯系人清單和收藏是由ContactsListActivity負責。
2、進入TwelveKeyDialer 中OnClick方法,按住的按鈕id為:R.id.dialButton,執行placecall()方法:
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,Uri.fromParts("tel", number, null));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
3、intert.ACTION_CALL_PRIVILEGED實際字元串為android.intent.action.CALL_PRIVILEGED,通過查找知道了packegs/phone下面的AndroidManifest.xml中PrivilegedOutgoingCallBroadcaster activity-alias設定了intent-filter,是以需要找到其targetactivity為OutgoingCallBroadcaster。是以進入OutgoingCallBroadcaster的onCreate()中:
String action = intent.getAction();
String number = PhoneNumberUtils.getNumberFromIntent(intent, this);
if (number != null) {
number = PhoneNumberUtils.convertKeypadLettersToDigits(number);
number = PhoneNumberUtils.stripSeparators(number);
}
final boolean emergencyNumber =
(number != null) && PhoneNumberUtils.isEmergencyNumber(number);
擷取過來的Action以及Number,并對Action以及Number類型進行判斷。
//如果為callNow = true;則啟動InCall界面:
intent.setClass(this, InCallScreen.class);
startActivity(intent);
并發送廣播給OutgoingCallReceiver:
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());
sendOrderedBroadcast(broadcastIntent, PERMISSION,
new OutgoingCallReceiver(), null, Activity.RESULT_OK, number, null);
4、Intent.ACTION_NEW_OUTGOING_CALL實際字元串android.intent.action.NEW_OUTGOING_CALL,通過查找知道了packegs/phone下面的androidmanifest.xml中OutgoingCallReceiver Receiver接收此intent消息。找到OutgoingCallBroadcaster類中的内部類OutgoingCallReceiver,執行onReceive()函數:
執行doReceive(context, intent);方法:
擷取傳給來的号碼,根據PhoneApp的執行個體擷取PhoneType等。最後啟動InCall界面:
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);