Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ java_library { "src/java/**/*.logtags", ], jarjar_rules: ":framework-hidl-jarjar", libs: [ "voip-common", "ims-common", Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +66 −13 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PRECISE_CALL_STATE; import static android.telephony.SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; import static android.telephony.SubscriptionManager.INVALID_PHONE_INDEX; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading @@ -39,6 +40,7 @@ import android.os.RegistrantList; import android.os.RemoteException; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; import android.telephony.PreciseCallState; import android.telephony.Rlog; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -76,7 +78,8 @@ public class PhoneSwitcher extends Handler { private final int mNumPhones; private final Phone[] mPhones; private final LocalLog mLocalLog; private final PhoneStateListener mPhoneStateListener; @VisibleForTesting public final PhoneStateListener mPhoneStateListener; private int mMaxActivePhones; private static PhoneSwitcher sPhoneSwitcher = null; Loading @@ -95,6 +98,8 @@ public class PhoneSwitcher extends Handler { // Corresponding phoneId after considerting mPreferredDataSubId and mDefaultDataSubId above. protected int mPreferredDataPhoneId = SubscriptionManager.INVALID_PHONE_INDEX; private int mPhoneIdInCall = SubscriptionManager.INVALID_PHONE_INDEX; private static final int EVENT_DEFAULT_SUBSCRIPTION_CHANGED = 101; private static final int EVENT_SUBSCRIPTION_CHANGED = 102; private static final int EVENT_REQUEST_NETWORK = 103; Loading @@ -103,6 +108,7 @@ public class PhoneSwitcher extends Handler { private static final int EVENT_RADIO_CAPABILITY_CHANGED = 106; private static final int EVENT_PREFERRED_SUBSCRIPTION_CHANGED = 107; private static final int EVENT_RADIO_AVAILABLE = 108; private static final int EVENT_PHONE_IN_CALL_CHANGED = 109; // Depending on version of IRadioConfig, we need to send either RIL_REQUEST_ALLOW_DATA if it's // 1.0, or RIL_REQUEST_SET_PREFERRED_DATA if it's 1.1 or later. So internally mHalCommandToUse Loading Loading @@ -174,14 +180,38 @@ public class PhoneSwitcher extends Handler { mRadioConfig = RadioConfig.getInstance(mContext); mPhoneStateListener = new PhoneStateListener(looper) { @Override public void onPhoneCapabilityChanged(PhoneCapability capability) { onPhoneCapabilityChangedInternal(capability); } @Override public void onPreciseCallStateChanged(PreciseCallState callState) { int oldPhoneIdInCall = mPhoneIdInCall; // If there's no active call, the value will become INVALID_PHONE_INDEX // and internet data will be switched back to system selected or user selected // subscription. mPhoneIdInCall = SubscriptionManager.INVALID_PHONE_INDEX; for (Phone phone : mPhones) { if (isCallActive(phone) || isCallActive(phone.getImsPhone())) { mPhoneIdInCall = phone.getPhoneId(); break; } } if (mPhoneIdInCall != oldPhoneIdInCall) { log("mPhoneIdInCall changed from" + oldPhoneIdInCall + " to " + mPhoneIdInCall); Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PHONE_IN_CALL_CHANGED); msg.sendToTarget(); } } }; TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, LISTEN_PHONE_CAPABILITY_CHANGE); telephonyManager.listen(mPhoneStateListener, LISTEN_PHONE_CAPABILITY_CHANGE | LISTEN_PRECISE_CALL_STATE); mActivePhoneRegistrants = new RegistrantList(); mPhoneStates = new PhoneState[numPhones]; Loading Loading @@ -282,6 +312,10 @@ public class PhoneSwitcher extends Handler { onEvaluate(REQUESTS_UNCHANGED, "EVENT_RADIO_AVAILABLE"); break; } case EVENT_PHONE_IN_CALL_CHANGED: { onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED"); break; } } } Loading Loading @@ -404,7 +438,7 @@ public class PhoneSwitcher extends Handler { */ if (mMaxActivePhones == mPhones.length) { for (int i = 0; i < mMaxActivePhones; i++) { newActivePhones.add(mPhones[i].mPhoneId); newActivePhones.add(mPhones[i].getPhoneId()); } } else { for (DcRequest dcRequest : mPrioritizedDcRequests) { Loading Loading @@ -571,6 +605,14 @@ public class PhoneSwitcher extends Handler { // This updates mPreferredDataPhoneId which decides which phone should // handle default network requests. private void updatePhoneIdForDefaultNetworkRequests() { if (SubscriptionManager.isValidPhoneId(mPhoneIdInCall)) { // If a phone is in call and user enabled its mobile data, we // should switch internet connection to it. Because the other modem // will lose data connection anyway. // TODO: validate network first. mPreferredDataPhoneId = mPhoneIdInCall; } else { int subId = getSubIdForDefaultNetworkRequests(); int phoneId = SubscriptionManager.INVALID_PHONE_INDEX; Loading @@ -585,6 +627,7 @@ public class PhoneSwitcher extends Handler { mPreferredDataPhoneId = phoneId; } } public boolean shouldApplyNetworkRequest(NetworkRequest networkRequest, int phoneId) { validatePhoneId(phoneId); Loading Loading @@ -636,6 +679,16 @@ public class PhoneSwitcher extends Handler { } } private boolean isCallActive(Phone phone) { if (phone == null) { return false; } return (phone.getForegroundCall().getState() == Call.State.ACTIVE || phone.getBackgroundCall().getState() == Call.State.ACTIVE || phone.getRingingCall().getState() == Call.State.ACTIVE); } private void updateHalCommandToUse() { mHalCommandToUse = mRadioConfig.isSetPreferredDataCommandSupported() ? HAL_COMMAND_PREFERRED_DATA : HAL_COMMAND_ALLOW_DATA; Loading src/java/com/android/internal/telephony/RIL.java +2 −0 Original line number Diff line number Diff line Loading @@ -990,10 +990,12 @@ public class RIL extends BaseCommands implements CommandsInterface { } try { // TODO: populate fromEmergencyDialer correctly radioProxy14.emergencyDial(rr.mSerial, dialInfo, emergencyNumberInfo.getEmergencyServiceCategoryBitmaskInternalDial(), (ArrayList) emergencyNumberInfo.getEmergencyUrns(), emergencyNumberInfo.getEmergencyCallRouting(), false, emergencyNumberInfo.getEmergencyNumberSourceBitmask() == EmergencyNumber.EMERGENCY_NUMBER_SOURCE_TEST); } catch (RemoteException | RuntimeException e) { Loading src/java/com/android/internal/telephony/RadioIndication.java +23 −7 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ import android.hardware.radio.V1_0.SsInfoData; import android.hardware.radio.V1_0.StkCcUnsolSsResult; import android.hardware.radio.V1_0.SuppSvcNotification; import android.hardware.radio.V1_2.CellConnectionStatus; import android.hardware.radio.V1_2.IRadioIndication; import android.hardware.radio.V1_3.IRadioIndication; import android.hardware.radio.V1_4.RadioFrequencyInfo.hidl_discriminator; import android.os.AsyncResult; import android.os.SystemProperties; Loading Loading @@ -751,13 +751,19 @@ public class RadioIndication extends IRadioIndication.Stub { /** Incremental network scan results */ public void networkScanResult(int indicationType, android.hardware.radio.V1_1.NetworkScanResult result) { responseCellInfos(indicationType, result); responseNetworkScan(indicationType, result); } /** Incremental network scan results with HAL V1_2 */ public void networkScanResult_1_2(int indicationType, android.hardware.radio.V1_2.NetworkScanResult result) { responseCellInfos_1_2(indicationType, result); responseNetworkScan_1_2(indicationType, result); } /** Incremental network scan results with HAL V1_4 */ public void networkScanResult_1_4(int indicationType, android.hardware.radio.V1_4.NetworkScanResult result) { responseNetworkScan_1_4(indicationType, result); } public void imsNetworkStateChanged(int indicationType) { Loading Loading @@ -1036,7 +1042,7 @@ public class RadioIndication extends IRadioIndication.Stub { new AsyncResult(null, response, null)); } private void responseCellInfos(int indicationType, private void responseNetworkScan(int indicationType, android.hardware.radio.V1_1.NetworkScanResult result) { mRil.processIndication(indicationType); Loading @@ -1047,7 +1053,7 @@ public class RadioIndication extends IRadioIndication.Stub { mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } private void responseCellInfos_1_2(int indicationType, private void responseNetworkScan_1_2(int indicationType, android.hardware.radio.V1_2.NetworkScanResult result) { mRil.processIndication(indicationType); Loading @@ -1057,4 +1063,14 @@ public class RadioIndication extends IRadioIndication.Stub { if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } private void responseNetworkScan_1_4(int indicationType, android.hardware.radio.V1_4.NetworkScanResult result) { mRil.processIndication(indicationType); ArrayList<CellInfo> cellInfos = RIL.convertHalCellInfoList_1_4(result.networkInfos); NetworkScanResult nsr = new NetworkScanResult(result.status, result.error, cellInfos); if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } } src/java/com/android/internal/telephony/RadioResponse.java +24 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import android.hardware.radio.V1_0.RadioError; import android.hardware.radio.V1_0.RadioResponseInfo; import android.hardware.radio.V1_0.SendSmsResult; import android.hardware.radio.V1_0.VoiceRegStateResult; import android.hardware.radio.V1_2.IRadioResponse; import android.hardware.radio.V1_3.IRadioResponse; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.os.AsyncResult; Loading Loading @@ -2294,9 +2294,31 @@ public class RadioResponse extends IRadioResponse.Stub { } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param responseInfo Response info struct containing response type, serial number and error. */ public void enableModemResponse(RadioResponseInfo responseInfo) { responseVoid(responseInfo); } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param isEnabled whether the modem stack is enabled. */ public void getModemStackStatusResponse(RadioResponseInfo responseInfo, boolean isEnabled) { RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { if (responseInfo.error == RadioError.NONE) { sendMessageResponse(rr.mResult, isEnabled); } mRil.processResponseDone(rr, responseInfo, isEnabled); } } /** * @param responseInfo Response info struct containing response type, serial number and error. */ public void setSystemSelectionChannelsResponse(RadioResponseInfo responseInfo) { responseVoid(responseInfo); } } Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ java_library { "src/java/**/*.logtags", ], jarjar_rules: ":framework-hidl-jarjar", libs: [ "voip-common", "ims-common", Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +66 −13 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PRECISE_CALL_STATE; import static android.telephony.SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; import static android.telephony.SubscriptionManager.INVALID_PHONE_INDEX; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; Loading @@ -39,6 +40,7 @@ import android.os.RegistrantList; import android.os.RemoteException; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; import android.telephony.PreciseCallState; import android.telephony.Rlog; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -76,7 +78,8 @@ public class PhoneSwitcher extends Handler { private final int mNumPhones; private final Phone[] mPhones; private final LocalLog mLocalLog; private final PhoneStateListener mPhoneStateListener; @VisibleForTesting public final PhoneStateListener mPhoneStateListener; private int mMaxActivePhones; private static PhoneSwitcher sPhoneSwitcher = null; Loading @@ -95,6 +98,8 @@ public class PhoneSwitcher extends Handler { // Corresponding phoneId after considerting mPreferredDataSubId and mDefaultDataSubId above. protected int mPreferredDataPhoneId = SubscriptionManager.INVALID_PHONE_INDEX; private int mPhoneIdInCall = SubscriptionManager.INVALID_PHONE_INDEX; private static final int EVENT_DEFAULT_SUBSCRIPTION_CHANGED = 101; private static final int EVENT_SUBSCRIPTION_CHANGED = 102; private static final int EVENT_REQUEST_NETWORK = 103; Loading @@ -103,6 +108,7 @@ public class PhoneSwitcher extends Handler { private static final int EVENT_RADIO_CAPABILITY_CHANGED = 106; private static final int EVENT_PREFERRED_SUBSCRIPTION_CHANGED = 107; private static final int EVENT_RADIO_AVAILABLE = 108; private static final int EVENT_PHONE_IN_CALL_CHANGED = 109; // Depending on version of IRadioConfig, we need to send either RIL_REQUEST_ALLOW_DATA if it's // 1.0, or RIL_REQUEST_SET_PREFERRED_DATA if it's 1.1 or later. So internally mHalCommandToUse Loading Loading @@ -174,14 +180,38 @@ public class PhoneSwitcher extends Handler { mRadioConfig = RadioConfig.getInstance(mContext); mPhoneStateListener = new PhoneStateListener(looper) { @Override public void onPhoneCapabilityChanged(PhoneCapability capability) { onPhoneCapabilityChangedInternal(capability); } @Override public void onPreciseCallStateChanged(PreciseCallState callState) { int oldPhoneIdInCall = mPhoneIdInCall; // If there's no active call, the value will become INVALID_PHONE_INDEX // and internet data will be switched back to system selected or user selected // subscription. mPhoneIdInCall = SubscriptionManager.INVALID_PHONE_INDEX; for (Phone phone : mPhones) { if (isCallActive(phone) || isCallActive(phone.getImsPhone())) { mPhoneIdInCall = phone.getPhoneId(); break; } } if (mPhoneIdInCall != oldPhoneIdInCall) { log("mPhoneIdInCall changed from" + oldPhoneIdInCall + " to " + mPhoneIdInCall); Message msg = PhoneSwitcher.this.obtainMessage(EVENT_PHONE_IN_CALL_CHANGED); msg.sendToTarget(); } } }; TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, LISTEN_PHONE_CAPABILITY_CHANGE); telephonyManager.listen(mPhoneStateListener, LISTEN_PHONE_CAPABILITY_CHANGE | LISTEN_PRECISE_CALL_STATE); mActivePhoneRegistrants = new RegistrantList(); mPhoneStates = new PhoneState[numPhones]; Loading Loading @@ -282,6 +312,10 @@ public class PhoneSwitcher extends Handler { onEvaluate(REQUESTS_UNCHANGED, "EVENT_RADIO_AVAILABLE"); break; } case EVENT_PHONE_IN_CALL_CHANGED: { onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED"); break; } } } Loading Loading @@ -404,7 +438,7 @@ public class PhoneSwitcher extends Handler { */ if (mMaxActivePhones == mPhones.length) { for (int i = 0; i < mMaxActivePhones; i++) { newActivePhones.add(mPhones[i].mPhoneId); newActivePhones.add(mPhones[i].getPhoneId()); } } else { for (DcRequest dcRequest : mPrioritizedDcRequests) { Loading Loading @@ -571,6 +605,14 @@ public class PhoneSwitcher extends Handler { // This updates mPreferredDataPhoneId which decides which phone should // handle default network requests. private void updatePhoneIdForDefaultNetworkRequests() { if (SubscriptionManager.isValidPhoneId(mPhoneIdInCall)) { // If a phone is in call and user enabled its mobile data, we // should switch internet connection to it. Because the other modem // will lose data connection anyway. // TODO: validate network first. mPreferredDataPhoneId = mPhoneIdInCall; } else { int subId = getSubIdForDefaultNetworkRequests(); int phoneId = SubscriptionManager.INVALID_PHONE_INDEX; Loading @@ -585,6 +627,7 @@ public class PhoneSwitcher extends Handler { mPreferredDataPhoneId = phoneId; } } public boolean shouldApplyNetworkRequest(NetworkRequest networkRequest, int phoneId) { validatePhoneId(phoneId); Loading Loading @@ -636,6 +679,16 @@ public class PhoneSwitcher extends Handler { } } private boolean isCallActive(Phone phone) { if (phone == null) { return false; } return (phone.getForegroundCall().getState() == Call.State.ACTIVE || phone.getBackgroundCall().getState() == Call.State.ACTIVE || phone.getRingingCall().getState() == Call.State.ACTIVE); } private void updateHalCommandToUse() { mHalCommandToUse = mRadioConfig.isSetPreferredDataCommandSupported() ? HAL_COMMAND_PREFERRED_DATA : HAL_COMMAND_ALLOW_DATA; Loading
src/java/com/android/internal/telephony/RIL.java +2 −0 Original line number Diff line number Diff line Loading @@ -990,10 +990,12 @@ public class RIL extends BaseCommands implements CommandsInterface { } try { // TODO: populate fromEmergencyDialer correctly radioProxy14.emergencyDial(rr.mSerial, dialInfo, emergencyNumberInfo.getEmergencyServiceCategoryBitmaskInternalDial(), (ArrayList) emergencyNumberInfo.getEmergencyUrns(), emergencyNumberInfo.getEmergencyCallRouting(), false, emergencyNumberInfo.getEmergencyNumberSourceBitmask() == EmergencyNumber.EMERGENCY_NUMBER_SOURCE_TEST); } catch (RemoteException | RuntimeException e) { Loading
src/java/com/android/internal/telephony/RadioIndication.java +23 −7 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ import android.hardware.radio.V1_0.SsInfoData; import android.hardware.radio.V1_0.StkCcUnsolSsResult; import android.hardware.radio.V1_0.SuppSvcNotification; import android.hardware.radio.V1_2.CellConnectionStatus; import android.hardware.radio.V1_2.IRadioIndication; import android.hardware.radio.V1_3.IRadioIndication; import android.hardware.radio.V1_4.RadioFrequencyInfo.hidl_discriminator; import android.os.AsyncResult; import android.os.SystemProperties; Loading Loading @@ -751,13 +751,19 @@ public class RadioIndication extends IRadioIndication.Stub { /** Incremental network scan results */ public void networkScanResult(int indicationType, android.hardware.radio.V1_1.NetworkScanResult result) { responseCellInfos(indicationType, result); responseNetworkScan(indicationType, result); } /** Incremental network scan results with HAL V1_2 */ public void networkScanResult_1_2(int indicationType, android.hardware.radio.V1_2.NetworkScanResult result) { responseCellInfos_1_2(indicationType, result); responseNetworkScan_1_2(indicationType, result); } /** Incremental network scan results with HAL V1_4 */ public void networkScanResult_1_4(int indicationType, android.hardware.radio.V1_4.NetworkScanResult result) { responseNetworkScan_1_4(indicationType, result); } public void imsNetworkStateChanged(int indicationType) { Loading Loading @@ -1036,7 +1042,7 @@ public class RadioIndication extends IRadioIndication.Stub { new AsyncResult(null, response, null)); } private void responseCellInfos(int indicationType, private void responseNetworkScan(int indicationType, android.hardware.radio.V1_1.NetworkScanResult result) { mRil.processIndication(indicationType); Loading @@ -1047,7 +1053,7 @@ public class RadioIndication extends IRadioIndication.Stub { mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } private void responseCellInfos_1_2(int indicationType, private void responseNetworkScan_1_2(int indicationType, android.hardware.radio.V1_2.NetworkScanResult result) { mRil.processIndication(indicationType); Loading @@ -1057,4 +1063,14 @@ public class RadioIndication extends IRadioIndication.Stub { if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } private void responseNetworkScan_1_4(int indicationType, android.hardware.radio.V1_4.NetworkScanResult result) { mRil.processIndication(indicationType); ArrayList<CellInfo> cellInfos = RIL.convertHalCellInfoList_1_4(result.networkInfos); NetworkScanResult nsr = new NetworkScanResult(result.status, result.error, cellInfos); if (RIL.RILJ_LOGD) mRil.unsljLogRet(RIL_UNSOL_NETWORK_SCAN_RESULT, nsr); mRil.mRilNetworkScanResultRegistrants.notifyRegistrants(new AsyncResult(null, nsr, null)); } }
src/java/com/android/internal/telephony/RadioResponse.java +24 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ import android.hardware.radio.V1_0.RadioError; import android.hardware.radio.V1_0.RadioResponseInfo; import android.hardware.radio.V1_0.SendSmsResult; import android.hardware.radio.V1_0.VoiceRegStateResult; import android.hardware.radio.V1_2.IRadioResponse; import android.hardware.radio.V1_3.IRadioResponse; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.os.AsyncResult; Loading Loading @@ -2294,9 +2294,31 @@ public class RadioResponse extends IRadioResponse.Stub { } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param responseInfo Response info struct containing response type, serial number and error. */ public void enableModemResponse(RadioResponseInfo responseInfo) { responseVoid(responseInfo); } /** * @param responseInfo Response info struct containing response type, serial no. and error * @param isEnabled whether the modem stack is enabled. */ public void getModemStackStatusResponse(RadioResponseInfo responseInfo, boolean isEnabled) { RILRequest rr = mRil.processResponse(responseInfo); if (rr != null) { if (responseInfo.error == RadioError.NONE) { sendMessageResponse(rr.mResult, isEnabled); } mRil.processResponseDone(rr, responseInfo, isEnabled); } } /** * @param responseInfo Response info struct containing response type, serial number and error. */ public void setSystemSelectionChannelsResponse(RadioResponseInfo responseInfo) { responseVoid(responseInfo); } }