android 4.4电话源码 :拨号流程

之前公司一直在做6.0 、7.0 的产品,突然来个4.4,差别还是有的,4.4竟然没有Telecomm,看来6.0的是从Telephony分离出来的。好了,开始了。

从Dialer的DialpadFragment开始。

    public void dialButtonPressed() {
        mHaptic.vibrate();
        handleDialButtonPressed();
    }
    private void handleDialButtonPressed() {
        if (isDigitsEmpty()) { // No number entered.
            handleDialButtonClickWithEmptyDigits();
        } else {
            final String number = mDigits.getText().toString();

            // "persist.radio.otaspdial" is a temporary hack needed for one carrier's automated
            // test equipment.
            // TODO: clean it up.
            if (number != null
                    && !TextUtils.isEmpty(mProhibitedPhoneNumberRegexp)
                    && number.matches(mProhibitedPhoneNumberRegexp)
                    && (SystemProperties.getInt("persist.radio.otaspdial", 0) != 1)) {
                Log.i(TAG, "The phone number is prohibited explicitly by a rule.");
                if (getActivity() != null) {
                    DialogFragment dialogFragment = ErrorDialogFragment.newInstance(
                            R.string.dialog_phone_call_prohibited_message);
                    dialogFragment.show(getFragmentManager(), "phone_prohibited_dialog");
                }

                // Clear the digits just in case.
                mDigits.getText().clear();
            } else {
                final Intent intent = CallUtil.getCallIntent(number,
                        (getActivity() instanceof DialtactsActivityOriginal ?
                                ((DialtactsActivityOriginal) getActivity()).getCallOrigin() : null));
                /* SPRD: no need to select card @{ */
                if (PhoneNumberUtils.isEmergencyNumber(number)) {
                    int validPhoneId = SprdPhoneCommonUtils.getValidPhoneId(mContext);
                    intent.putExtra(TelephonyIntents.NOT_NEED_SIMCARD_SELECTION, true);
                    intent.putExtra(TelephonyIntents.EXTRA_PHONE_ID, validPhoneId);
                }
                /* @} */
                startActivity(intent);
                hideAndClearDialpad();
            }
        }
    }

if里面的限制一般是没有的,所以看else

会在CallUtil中生成Intent,然后startActivity

CallUtil.java

    public static Intent getCallIntent(Uri uri, String callOrigin) {
        final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        if (callOrigin != null) {
            intent.putExtra(PhoneConstants.EXTRA_CALL_ORIGIN, callOrigin);
        }

        // Set phone as an explicit component of CALL_PRIVILEGED intent.
        // Setting destination explicitly prevents other apps from capturing this Intent since,
        // unlike SendBroadcast, there is no API for specifying a permission on startActivity.
        intent.setComponent(CALL_INTENT_DESTINATION);

        return intent;
    }
在packages 中搜索内容android.intent.action.CALL_PRIVILEGED(因为一般都是注册在xml,所以搜索值,而不是键),在Telephony的manifest里面找到对应标签
        <activity-alias android:name="PrivilegedOutgoingCallBroadcaster"
                android:targetActivity="OutgoingCallBroadcaster"
                android:screenOrientation="nosensor"
                android:permission="android.permission.CALL_PRIVILEGED">
            <intent-filter android:priority="1000">
                <action android:name="android.intent.action.CALL_PRIVILEGED" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="tel" />


在Telephony 的OutgoingCallBroadcaster中,这是个activity,在oncreate中调用了processIntent

在processIntent中对action进行了转换,如果是紧急号码就设为ACTION_CALL_EMERGENCY,否则就是Action_call

然后

        sendOrderedBroadcastAsUser(broadcastIntent, UserHandle.OWNER,
                PERMISSION, new OutgoingCallReceiver(),
                null,  // scheduler
                Activity.RESULT_OK,  // initialCode
                number,  // initialData: initial value for the result data
                null);  // initialExtras

...csdn保存进度丢失了

猜你喜欢

转载自blog.csdn.net/ccc905341846/article/details/79413888