Loading src/java/com/android/internal/telephony/SubscriptionController.java +12 −1 Original line number Diff line number Diff line Loading @@ -2310,7 +2310,7 @@ public class SubscriptionController extends ISub.Stub { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; PhoneSwitcher.getInstance().setPreferredData(subId); //TODO: notifyPreferredDataSubIdChanged(); notifyPreferredDataSubIdChanged(); } return 0; Loading @@ -2319,6 +2319,17 @@ public class SubscriptionController extends ISub.Stub { } } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { if (DBG) logd("notifyPreferredDataSubIdChanged:"); tr.notifyPreferredDataSubIdChanged(mPreferredDataSubId); } catch (RemoteException ex) { // Should never happen because its always available. } } @Override public List<SubscriptionInfo> getOpportunisticSubscriptions(int slotId, String callingPackage) { return getSubscriptionInfoListFromCacheHelper( Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static org.junit.Assert.assertEquals; Loading @@ -38,6 +39,7 @@ public class TelephonyRegistryTest extends TelephonyTest { private PhoneStateListener mPhoneStateListener; private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; public class PhoneStateListenerWrapper extends PhoneStateListener { @Override Loading @@ -45,6 +47,11 @@ public class TelephonyRegistryTest extends TelephonyTest { mPhoneCapability = capability; setReady(true); } @Override public void onPreferredDataSubIdChanged(int preferredSubId) { mPreferredSubId = preferredSubId; setReady(true); } } private void addTelephonyRegistryService() { Loading Loading @@ -97,4 +104,25 @@ public class TelephonyRegistryTest extends TelephonyTest { waitUntilReady(); assertEquals(phoneCapability, mPhoneCapability); } @Test @SmallTest public void testPreferredDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. setReady(false); int preferredSubId = 0; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); mTelephonyRegistry.listen(mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_PREFERRED_DATA_SUBID_CHANGE, true); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); // notifyPhoneCapabilityChanged with a new capability. Callback should be triggered. setReady(false); mPreferredSubId = 1; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); } } tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +5 −0 Original line number Diff line number Diff line Loading @@ -412,4 +412,9 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { public void notifyPhoneCapabilityChanged(PhoneCapability capability) { throw new RuntimeException("Not implemented"); } @Override public void notifyPreferredDataSubIdChanged(int subId) { throw new RuntimeException("Not implemented"); } } Loading
src/java/com/android/internal/telephony/SubscriptionController.java +12 −1 Original line number Diff line number Diff line Loading @@ -2310,7 +2310,7 @@ public class SubscriptionController extends ISub.Stub { if (mPreferredDataSubId != subId) { mPreferredDataSubId = subId; PhoneSwitcher.getInstance().setPreferredData(subId); //TODO: notifyPreferredDataSubIdChanged(); notifyPreferredDataSubIdChanged(); } return 0; Loading @@ -2319,6 +2319,17 @@ public class SubscriptionController extends ISub.Stub { } } private void notifyPreferredDataSubIdChanged() { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); try { if (DBG) logd("notifyPreferredDataSubIdChanged:"); tr.notifyPreferredDataSubIdChanged(mPreferredDataSubId); } catch (RemoteException ex) { // Should never happen because its always available. } } @Override public List<SubscriptionInfo> getOpportunisticSubscriptions(int slotId, String callingPackage) { return getSubscriptionInfoListFromCacheHelper( Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +28 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.internal.telephony; import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE; import static android.telephony.PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE; import static org.junit.Assert.assertEquals; Loading @@ -38,6 +39,7 @@ public class TelephonyRegistryTest extends TelephonyTest { private PhoneStateListener mPhoneStateListener; private TelephonyRegistry mTelephonyRegistry; private PhoneCapability mPhoneCapability; private int mPreferredSubId; public class PhoneStateListenerWrapper extends PhoneStateListener { @Override Loading @@ -45,6 +47,11 @@ public class TelephonyRegistryTest extends TelephonyTest { mPhoneCapability = capability; setReady(true); } @Override public void onPreferredDataSubIdChanged(int preferredSubId) { mPreferredSubId = preferredSubId; setReady(true); } } private void addTelephonyRegistryService() { Loading Loading @@ -97,4 +104,25 @@ public class TelephonyRegistryTest extends TelephonyTest { waitUntilReady(); assertEquals(phoneCapability, mPhoneCapability); } @Test @SmallTest public void testPreferredDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. setReady(false); int preferredSubId = 0; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); mTelephonyRegistry.listen(mContext.getOpPackageName(), mPhoneStateListener.callback, LISTEN_PREFERRED_DATA_SUBID_CHANGE, true); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); // notifyPhoneCapabilityChanged with a new capability. Callback should be triggered. setReady(false); mPreferredSubId = 1; mTelephonyRegistry.notifyPreferredDataSubIdChanged(preferredSubId); waitUntilReady(); assertEquals(preferredSubId, mPreferredSubId); } }
tests/telephonytests/src/com/android/internal/telephony/mocks/TelephonyRegistryMock.java +5 −0 Original line number Diff line number Diff line Loading @@ -412,4 +412,9 @@ public class TelephonyRegistryMock extends ITelephonyRegistry.Stub { public void notifyPhoneCapabilityChanged(PhoneCapability capability) { throw new RuntimeException("Not implemented"); } @Override public void notifyPreferredDataSubIdChanged(int subId) { throw new RuntimeException("Not implemented"); } }