Loading src/java/com/android/internal/telephony/PhoneSwitcher.java +15 −11 Original line number Diff line number Diff line Loading @@ -599,6 +599,9 @@ public class PhoneSwitcher extends Handler { } } notifyActiveDataSubIdChanged(mSubscriptionController.getSubIdUsingPhoneId( mPreferredDataPhoneId)); // Notify all registrants. mActivePhoneRegistrants.notifyRegistrants(); } Loading Loading @@ -859,7 +862,6 @@ public class PhoneSwitcher extends Handler { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); notifyPreferredDataSubIdChanged(); registerDefaultNetworkChangeCallback(); } } Loading @@ -884,16 +886,6 @@ public class PhoneSwitcher extends Handler { subId, needValidation ? 1 : 0, callback).sendToTarget(); } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { tr.notifyPreferredDataSubIdChanged(mPreferredDataSubId); } catch (RemoteException ex) { // Should never happen because TelephonyRegistry service should always be available. } } private boolean isCallActive(Phone phone) { if (phone == null) { return false; Loading Loading @@ -926,6 +918,18 @@ public class PhoneSwitcher extends Handler { dataSwitch.state = state; dataSwitch.reason = reason; TelephonyMetrics.getInstance().writeDataSwitch(dataSwitch); } private void notifyActiveDataSubIdChanged(int activeDataSubId) { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { log("notifyActiveDataSubIdChanged to " + activeDataSubId); tr.notifyActiveDataSubIdChanged(activeDataSubId); } catch (RemoteException ex) { // Should never happen because its always available. } } public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -642,7 +642,13 @@ public class PhoneSwitcherTest extends TelephonyTest { doReturn(mDefaultDataSub).when(mSubscriptionController).getDefaultDataSubId(); doAnswer(invocation -> { int phoneId = (int) invocation.getArguments()[0]; if (phoneId == SubscriptionManager.INVALID_PHONE_INDEX) { return SubscriptionManager.INVALID_SUBSCRIPTION_ID; } else if (phoneId == SubscriptionManager.DEFAULT_PHONE_INDEX) { return mSlotIndexToSubId[0][0]; } else { return mSlotIndexToSubId[phoneId][0]; } }).when(mSubscriptionController).getSubIdUsingPhoneId(anyInt()); doAnswer(invocation -> { Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +12 −12 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ */ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED; import static org.junit.Assert.assertEquals; Loading Loading @@ -44,7 +44,7 @@ public class TelephonyRegistryTest extends TelephonyTest { private PhoneStateListener mPhoneStateListener; private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; private int mActiveSubId; private int mSrvccState = -1; public class PhoneStateListenerWrapper extends PhoneStateListener { Loading @@ -60,8 +60,8 @@ public class TelephonyRegistryTest extends TelephonyTest { setReady(true); } @Override public void onPreferredDataSubIdChanged(int preferredSubId) { mPreferredSubId = preferredSubId; public void onActiveDataSubIdChanged(int activeSubId) { mActiveSubId = activeSubId; setReady(true); } } Loading Loading @@ -121,23 +121,23 @@ public class TelephonyRegistryTest extends TelephonyTest { @Test @SmallTest public void testPreferredDataSubChanged() { public void testActiveDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. setReady(false); int preferredSubId = 0; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); int activeSubId = 0; mTelephonyRegistry.notifyActiveDataSubIdChanged(activeSubId); mTelephonyRegistry.listen(mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_PREFERRED_DATA_SUBID_CHANGE, true); LISTEN_ACTIVE_DATA_SUBID_CHANGE, true); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); assertEquals(activeSubId, mActiveSubId); // notifyPhoneCapabilityChanged with a new capability. Callback should be triggered. setReady(false); mPreferredSubId = 1; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); mActiveSubId = 1; mTelephonyRegistry.notifyActiveDataSubIdChanged(activeSubId); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); assertEquals(activeSubId, mActiveSubId); } /** Loading tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +1 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { } @Override public void notifyPreferredDataSubIdChanged(int subId) { public void notifyActiveDataSubIdChanged(int subId) { throw new RuntimeException("Not implemented"); } Loading Loading
src/java/com/android/internal/telephony/PhoneSwitcher.java +15 −11 Original line number Diff line number Diff line Loading @@ -599,6 +599,9 @@ public class PhoneSwitcher extends Handler { } } notifyActiveDataSubIdChanged(mSubscriptionController.getSubIdUsingPhoneId( mPreferredDataPhoneId)); // Notify all registrants. mActivePhoneRegistrants.notifyRegistrants(); } Loading Loading @@ -859,7 +862,6 @@ public class PhoneSwitcher extends Handler { logDataSwitchEvent(TelephonyEvent.EventState.EVENT_STATE_START, DataSwitch.Reason.DATA_SWITCH_REASON_CBRS); onEvaluate(REQUESTS_UNCHANGED, "preferredDataSubscriptionIdChanged"); notifyPreferredDataSubIdChanged(); registerDefaultNetworkChangeCallback(); } } Loading @@ -884,16 +886,6 @@ public class PhoneSwitcher extends Handler { subId, needValidation ? 1 : 0, callback).sendToTarget(); } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { tr.notifyPreferredDataSubIdChanged(mPreferredDataSubId); } catch (RemoteException ex) { // Should never happen because TelephonyRegistry service should always be available. } } private boolean isCallActive(Phone phone) { if (phone == null) { return false; Loading Loading @@ -926,6 +918,18 @@ public class PhoneSwitcher extends Handler { dataSwitch.state = state; dataSwitch.reason = reason; TelephonyMetrics.getInstance().writeDataSwitch(dataSwitch); } private void notifyActiveDataSubIdChanged(int activeDataSubId) { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { log("notifyActiveDataSubIdChanged to " + activeDataSubId); tr.notifyActiveDataSubIdChanged(activeDataSubId); } catch (RemoteException ex) { // Should never happen because its always available. } } public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSwitcherTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -642,7 +642,13 @@ public class PhoneSwitcherTest extends TelephonyTest { doReturn(mDefaultDataSub).when(mSubscriptionController).getDefaultDataSubId(); doAnswer(invocation -> { int phoneId = (int) invocation.getArguments()[0]; if (phoneId == SubscriptionManager.INVALID_PHONE_INDEX) { return SubscriptionManager.INVALID_SUBSCRIPTION_ID; } else if (phoneId == SubscriptionManager.DEFAULT_PHONE_INDEX) { return mSlotIndexToSubId[0][0]; } else { return mSlotIndexToSubId[phoneId][0]; } }).when(mSubscriptionController).getSubIdUsingPhoneId(anyInt()); doAnswer(invocation -> { Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +12 −12 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ */ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED; import static org.junit.Assert.assertEquals; Loading Loading @@ -44,7 +44,7 @@ public class TelephonyRegistryTest extends TelephonyTest { private PhoneStateListener mPhoneStateListener; private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; private int mActiveSubId; private int mSrvccState = -1; public class PhoneStateListenerWrapper extends PhoneStateListener { Loading @@ -60,8 +60,8 @@ public class TelephonyRegistryTest extends TelephonyTest { setReady(true); } @Override public void onPreferredDataSubIdChanged(int preferredSubId) { mPreferredSubId = preferredSubId; public void onActiveDataSubIdChanged(int activeSubId) { mActiveSubId = activeSubId; setReady(true); } } Loading Loading @@ -121,23 +121,23 @@ public class TelephonyRegistryTest extends TelephonyTest { @Test @SmallTest public void testPreferredDataSubChanged() { public void testActiveDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. setReady(false); int preferredSubId = 0; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); int activeSubId = 0; mTelephonyRegistry.notifyActiveDataSubIdChanged(activeSubId); mTelephonyRegistry.listen(mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_PREFERRED_DATA_SUBID_CHANGE, true); LISTEN_ACTIVE_DATA_SUBID_CHANGE, true); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); assertEquals(activeSubId, mActiveSubId); // notifyPhoneCapabilityChanged with a new capability. Callback should be triggered. setReady(false); mPreferredSubId = 1; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); mActiveSubId = 1; mTelephonyRegistry.notifyActiveDataSubIdChanged(activeSubId); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); assertEquals(activeSubId, mActiveSubId); } /** Loading
tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +1 −1 Original line number Diff line number Diff line Loading @@ -426,7 +426,7 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { } @Override public void notifyPreferredDataSubIdChanged(int subId) { public void notifyActiveDataSubIdChanged(int subId) { throw new RuntimeException("Not implemented"); } Loading