Android N 高通平台飞行模式下拨打紧急拨号112流程

    xiaoxiao2021-12-15  30

                 简单说下这个流程:

                飞行模式下拨打112,首先是会打开radio,然后才拨出紧急号码的。

          1)在TelephonyConnectionService.java中,执行onCreateOutgoingConnection方法,如下:

                 public Connection onCreateOutgoingConnection(             PhoneAccountHandle connectionManagerPhoneAccount,             final ConnectionRequest request) {         Log.i(this, "onCreateOutgoingConnection, request: " + request);        。。。。。。

            if (isEmergencyNumber) {             mRequest = request;             if (!phone.isRadioOn() || isAirplaneModeOn) {                 mUseEmergencyCallHelper = true;          //这里判断这个mUseEmergencyCallHelper = true             }         } else {             switch (state) {                 case ServiceState.STATE_IN_SERVICE:                 case ServiceState.STATE_EMERGENCY_ONLY:                     break;                 case ServiceState.STATE_OUT_OF_SERVICE:                     if (phone.isUtEnabled() && number.endsWith("#")) {                         Log.d(this, "onCreateOutgoingConnection dial for UT");                         break;                     } else {                         return Connection.createFailedConnection(                                 DisconnectCauseUtil.toTelecomDisconnectCause(                                         android.telephony.DisconnectCause.OUT_OF_SERVICE,                                         "ServiceState.STATE_OUT_OF_SERVICE"));                     }                 case ServiceState.STATE_POWER_OFF:                     return Connection.createFailedConnection(                             DisconnectCauseUtil.toTelecomDisconnectCause(                                     android.telephony.DisconnectCause.POWER_OFF,                                     "ServiceState.STATE_POWER_OFF"));                 default:                     Log.d(this, "onCreateOutgoingConnection, unknown service state: %d", state);                     return Connection.createFailedConnection(                             DisconnectCauseUtil.toTelecomDisconnectCause(                                     android.telephony.DisconnectCause.OUTGOING_FAILURE,                                     "Unknown service state " + state));             }         }         final Context context = getApplicationContext();         if (VideoProfile.isVideo(request.getVideoState()) && isTtyModeEnabled(context) &&                 !isEmergencyNumber) {             return Connection.createFailedConnection(DisconnectCauseUtil.toTelecomDisconnectCause(                     android.telephony.DisconnectCause.VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED));         }         // Check for additional limits on CDMA phones.         final Connection failedConnection = checkAdditionalOutgoingCallLimits(phone);         if (failedConnection != null) {             return failedConnection;         }         final TelephonyConnection connection =                 createConnectionFor(phone, null, true /* isOutgoing */, request.getAccountHandle(),                         request.getTelecomCallId(), request.getAddress());         if (connection == null) {             return Connection.createFailedConnection(                     DisconnectCauseUtil.toTelecomDisconnectCause(                             android.telephony.DisconnectCause.OUTGOING_FAILURE,                             "Invalid phone type"));         }         connection.setAddress(handle, PhoneConstants.PRESENTATION_ALLOWED);         connection.setInitializing();         connection.setVideoState(request.getVideoState());         if (mUseEmergencyCallHelper) {             if (mEmergencyCallHelper == null) {                 mEmergencyCallHelper = new EmergencyCallHelper(this);             }             mEmergencyCallHelper.startTurnOnRadioSequence(number,   //下面就走到这里了,代码跟进去,会发现有打开radio的操作                     new EmergencyCallHelper.Callback() {                         @Override                         public void onComplete(Phone phone, boolean isRadioReady) {                             if (connection.getState() == Connection.STATE_DISCONNECTED) {                                 // If the connection has already been disconnected, do nothing.                             } else if (isRadioReady) {                                 connection.setInitialized();                                 placeOutgoingConnection(connection, phone, request);                             } else {                                 Log.d(this, "onCreateOutgoingConnection, failed to turn on radio");                                 connection.setDisconnected(                                         DisconnectCauseUtil.toTelecomDisconnectCause(                                                 android.telephony.DisconnectCause.POWER_OFF,                                                 "Failed to turn on radio."));                                 connection.destroy();                             }                         }                     });         } else {             placeOutgoingConnection(connection, phone, request);         }         return connection;     }     }

    转载请注明原文地址: https://ju.6miu.com/read-1000005.html

    最新回复(0)