Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +32 −24 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ public class PhoneSwitcher extends Handler { if (mConnectivityManager.getNetworkCapabilities(network) .hasTransport(TRANSPORT_CELLULAR)) { logDataSwitchEvent( mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_END, TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_UNKNOWN); } Loading Loading @@ -338,10 +339,12 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_DEFAULT_SUBSCRIPTION_CHANGED: { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "defaultChanged")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_MANUAL); onEvaluate(REQUESTS_UNCHANGED, "defaultChanged"); registerDefaultNetworkChangeCallback(); } break; } case EVENT_REQUEST_NETWORK: { Loading Loading @@ -378,10 +381,12 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_PHONE_IN_CALL_CHANGED: { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL); onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED"); registerDefaultNetworkChangeCallback(); } break; } case EVENT_NETWORK_VALIDATION_DONE: { Loading Loading @@ -498,19 +503,19 @@ public class PhoneSwitcher extends Handler { private static final boolean REQUESTS_CHANGED = true; private static final boolean REQUESTS_UNCHANGED = false; /** * Re-evaluate things. * Do nothing if nothing's changed. * Re-evaluate things. Do nothing if nothing's changed. * * Otherwise, go through the requests in priority order adding their phone * until we've added up to the max allowed. Then go through shutting down * phones that aren't in the active phone list. Finally, activate all * phones in the active phone list. * Otherwise, go through the requests in priority order adding their phone until we've added up * to the max allowed. Then go through shutting down phones that aren't in the active phone * list. Finally, activate all phones in the active phone list. * * @return {@code True} if the default data subscription need to be changed. */ private void onEvaluate(boolean requestsChanged, String reason) { private boolean onEvaluate(boolean requestsChanged, String reason) { StringBuilder sb = new StringBuilder(reason); if (isEmergency()) { log("onEvalute aborted due to Emergency"); return; return false; } // If we use HAL_COMMAND_PREFERRED_DATA, Loading Loading @@ -610,6 +615,7 @@ public class PhoneSwitcher extends Handler { // Notify all registrants. mActivePhoneRegistrants.notifyRegistrants(); } return diffDetected; } private static class PhoneState { Loading Loading @@ -825,7 +831,7 @@ public class PhoneSwitcher extends Handler { // If validation feature is not supported, set it directly. Otherwise, // start validation on the subscription first. if (CellularNetworkValidator.isValidationFeatureSupported() && needValidation) { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, logDataSwitchEvent(subId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); mSetOpptSubCallback = callback; mValidator.validate(subId, DEFAULT_VALIDATION_EXPIRATION_TIME, Loading Loading @@ -866,12 +872,14 @@ public class PhoneSwitcher extends Handler { private void setPreferredSubscription(int subId) { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); registerDefaultNetworkChangeCallback(); } } } private void onValidationDone(int subId, boolean passed) { log("Network validation " + (passed ? "passed" : "failed") Loading Loading @@ -921,12 +929,12 @@ public class PhoneSwitcher extends Handler { mLocalLog.log(l); } private void logDataSwitchEvent(int state, int reason) { private void logDataSwitchEvent(int subId, int state, int reason) { subId = subId == DEFAULT_SUBSCRIPTION_ID ? mDefaultDataSubId : subId; DataSwitch dataSwitch = new DataSwitch(); dataSwitch.state = state; dataSwitch.reason = reason; TelephonyMetrics.getInstance().writeDataSwitch(dataSwitch); TelephonyMetrics.getInstance().writeDataSwitch(subId, dataSwitch); } private void notifyActiveDataSubIdChanged(int activeDataSubId) { Loading src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java +4 −2 Original line number Diff line number Diff line Loading @@ -1781,10 +1781,12 @@ public class TelephonyMetrics { /** * Write data switch event. * @param subId data switch to the subscription with this id. * @param dataSwitch the reason and state of data switch. */ public void writeDataSwitch(DataSwitch dataSwitch) { addTelephonyEvent(new TelephonyEventBuilder().setDataSwitch(dataSwitch).build()); public void writeDataSwitch(int subId, DataSwitch dataSwitch) { int phoneId = SubscriptionManager.getPhoneId(subId); addTelephonyEvent(new TelephonyEventBuilder(phoneId).setDataSwitch(dataSwitch).build()); } /** Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +32 −24 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ public class PhoneSwitcher extends Handler { if (mConnectivityManager.getNetworkCapabilities(network) .hasTransport(TRANSPORT_CELLULAR)) { logDataSwitchEvent( mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_END, TelephonyEvent.DataSwitch.Reason.DATA_SWITCH_REASON_UNKNOWN); } Loading Loading @@ -338,10 +339,12 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_DEFAULT_SUBSCRIPTION_CHANGED: { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "defaultChanged")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_MANUAL); onEvaluate(REQUESTS_UNCHANGED, "defaultChanged"); registerDefaultNetworkChangeCallback(); } break; } case EVENT_REQUEST_NETWORK: { Loading Loading @@ -378,10 +381,12 @@ public class PhoneSwitcher extends Handler { break; } case EVENT_PHONE_IN_CALL_CHANGED: { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_IN_CALL); onEvaluate(REQUESTS_UNCHANGED, "EVENT_PHONE_IN_CALL_CHANGED"); registerDefaultNetworkChangeCallback(); } break; } case EVENT_NETWORK_VALIDATION_DONE: { Loading Loading @@ -498,19 +503,19 @@ public class PhoneSwitcher extends Handler { private static final boolean REQUESTS_CHANGED = true; private static final boolean REQUESTS_UNCHANGED = false; /** * Re-evaluate things. * Do nothing if nothing's changed. * Re-evaluate things. Do nothing if nothing's changed. * * Otherwise, go through the requests in priority order adding their phone * until we've added up to the max allowed. Then go through shutting down * phones that aren't in the active phone list. Finally, activate all * phones in the active phone list. * Otherwise, go through the requests in priority order adding their phone until we've added up * to the max allowed. Then go through shutting down phones that aren't in the active phone * list. Finally, activate all phones in the active phone list. * * @return {@code True} if the default data subscription need to be changed. */ private void onEvaluate(boolean requestsChanged, String reason) { private boolean onEvaluate(boolean requestsChanged, String reason) { StringBuilder sb = new StringBuilder(reason); if (isEmergency()) { log("onEvalute aborted due to Emergency"); return; return false; } // If we use HAL_COMMAND_PREFERRED_DATA, Loading Loading @@ -610,6 +615,7 @@ public class PhoneSwitcher extends Handler { // Notify all registrants. mActivePhoneRegistrants.notifyRegistrants(); } return diffDetected; } private static class PhoneState { Loading Loading @@ -825,7 +831,7 @@ public class PhoneSwitcher extends Handler { // If validation feature is not supported, set it directly. Otherwise, // start validation on the subscription first. if (CellularNetworkValidator.isValidationFeatureSupported() && needValidation) { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, logDataSwitchEvent(subId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); mSetOpptSubCallback = callback; mValidator.validate(subId, DEFAULT_VALIDATION_EXPIRATION_TIME, Loading Loading @@ -866,12 +872,14 @@ public class PhoneSwitcher extends Handler { private void setPreferredSubscription(int subId) { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, if (onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged")) { logDataSwitchEvent(mPreferredDataSubId, TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); registerDefaultNetworkChangeCallback(); } } } private void onValidationDone(int subId, boolean passed) { log("Network validation " + (passed ? "passed" : "failed") Loading Loading @@ -921,12 +929,12 @@ public class PhoneSwitcher extends Handler { mLocalLog.log(l); } private void logDataSwitchEvent(int state, int reason) { private void logDataSwitchEvent(int subId, int state, int reason) { subId = subId == DEFAULT_SUBSCRIPTION_ID ? mDefaultDataSubId : subId; DataSwitch dataSwitch = new DataSwitch(); dataSwitch.state = state; dataSwitch.reason = reason; TelephonyMetrics.getInstance().writeDataSwitch(dataSwitch); TelephonyMetrics.getInstance().writeDataSwitch(subId, dataSwitch); } private void notifyActiveDataSubIdChanged(int activeDataSubId) { Loading
src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java +4 −2 Original line number Diff line number Diff line Loading @@ -1781,10 +1781,12 @@ public class TelephonyMetrics { /** * Write data switch event. * @param subId data switch to the subscription with this id. * @param dataSwitch the reason and state of data switch. */ public void writeDataSwitch(DataSwitch dataSwitch) { addTelephonyEvent(new TelephonyEventBuilder().setDataSwitch(dataSwitch).build()); public void writeDataSwitch(int subId, DataSwitch dataSwitch) { int phoneId = SubscriptionManager.getPhoneId(subId); addTelephonyEvent(new TelephonyEventBuilder(phoneId).setDataSwitch(dataSwitch).build()); } /** Loading