Android 拨打电话 对方接听时震动功能(移动联通与电信的不同处理)

1.功能:拨打电话 对方接听时震动
2.平台:android6.0 MTK 平台

移动联通:
目录:packages\services\Telecomm\src\com\android\server\telecom
文件:Ringer.java

@Override
public void onCallStateChanged(Call call, int oldState, int newState) {
        if (newState != CallState.RINGING) {
            removeFromUnansweredCall(call);
        }
        ///M: vibrate when MO call connected. @{
        if (newState == CallState.ACTIVE
                && (oldState == CallState.DIALING || oldState == CallState.CONNECTING)
                /// M: CDMA MO call special handling. @{
                // For cdma call, framework will vibrate when the call be 'really' answered
                // by remote side, at this point the CDMA MO call maybe not in
                // real ACTIVE state, so skip this for CDMA MO call.
                && !TelecomUtils.hasCdmaCallCapability(mContext,
                        call.getTargetPhoneAccount())) {
                /// @}
            int emSetting = Settings.Global.getInt(mContext.getContentResolver(),
                    Settings.Global.TELEPHONY_MISC_FEATURE_CONFIG, KEY_MO_VIBRATE_CONFIG);
            boolean enabled = (emSetting & KEY_MO_VIBRATE_CONFIG) != 0;
            if (enabled ) {
                 mVibrator.vibrate(MO_CALL_VIBRATE_TIME);// 就是这里啦!
            }
        }
        /// @}
}

电信:
目录:frameworks\opt\telephony\src\java\com\android\internal\telephony\cdma
文件:CdmaConnection.java

boolean onCdmaCallAccept() {
        Rlog.d(LOG_TAG, "onCdmaCallAccept, mIsRealConnected:" + mIsRealConnected);
        if (!mIsRealConnected) {
            mConnectTimeReal = SystemClock.elapsedRealtime();
            mDuration = 0;
            mConnectTime = System.currentTimeMillis();
            mIsRealConnected = true;
            // send DTMF when the CDMAcall is really accepted.
            processNextPostDialChar();
            vibrateForAccepted();// 就是这里啦!
            return true;
        } else {
            return false;
        }
 }
private void vibrateForAccepted() {
        //if CDMA phone accepted, start a Vibrator
        Vibrator vibrator = (Vibrator) mOwner.mPhone.getContext().getSystemService(
                            Context.VIBRATOR_SERVICE);
        vibrator.vibrate(MO_CALL_VIBRATE_TIME);
   }

你可能感兴趣的:(Android 拨打电话 对方接听时震动功能(移动联通与电信的不同处理))