Loading src/java/com/android/internal/telephony/SubscriptionController.java +28 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import android.Manifest; Loading @@ -41,6 +42,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.AnomalyReporter; import android.telephony.CarrierConfigManager; import android.telephony.RadioAccessFamily; import android.telephony.SubscriptionInfo; Loading Loading @@ -2947,8 +2949,23 @@ public class SubscriptionController extends ISub.Stub { final long token = Binder.clearCallingIdentity(); try { PhoneSwitcher.getInstance().trySetOpportunisticDataSubscription( subId, needValidation, callback); PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance(); if (phoneSwitcher == null) { logd("Set preferred data sub: phoneSwitcher is null."); AnomalyReporter.reportAnomaly( UUID.fromString("a3ab0b9d-f2aa-4baf-911d-7096c0d4645a"), "Set preferred data sub: phoneSwitcher is null."); if (callback != null) { try { callback.onComplete(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); } catch (RemoteException exception) { logd("RemoteException " + exception); } } return; } phoneSwitcher.trySetOpportunisticDataSubscription(subId, needValidation, callback); } finally { Binder.restoreCallingIdentity(token); } Loading @@ -2960,7 +2977,15 @@ public class SubscriptionController extends ISub.Stub { final long token = Binder.clearCallingIdentity(); try { return PhoneSwitcher.getInstance().getOpportunisticDataSubscriptionId(); PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance(); if (phoneSwitcher == null) { AnomalyReporter.reportAnomaly( UUID.fromString("a3ab0b9d-f2aa-4baf-911d-7096c0d4645a"), "Get preferred data sub: phoneSwitcher is null."); return SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; } return phoneSwitcher.getOpportunisticDataSubscriptionId(); } finally { Binder.restoreCallingIdentity(token); } Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.telephony; import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; Loading Loading @@ -75,6 +77,8 @@ public class SubscriptionControllerTest extends TelephonyTest { private ITelephonyRegistry.Stub mTelephonyRegisteryMock; @Mock private MultiSimSettingController mMultiSimSettingControllerMock; @Mock private ISetOpportunisticDataCallback mSetOpptDataCallback; private static final String MAC_ADDRESS_PREFIX = "mac_"; private static final String DISPLAY_NAME_PREFIX = "my_phone_"; Loading Loading @@ -1091,4 +1095,22 @@ public class SubscriptionControllerTest extends TelephonyTest { > mSubscriptionControllerUT.getNameSourcePriority( SubscriptionManager.NAME_SOURCE_DEFAULT)); } @Test @SmallTest public void testSetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { replaceInstance(PhoneSwitcher.class, "sPhoneSwitcher", null, null); mSubscriptionControllerUT.setPreferredDataSubscriptionId(1, true, mSetOpptDataCallback); verify(mSetOpptDataCallback).onComplete(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); } @Test @SmallTest public void testGetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { replaceInstance(PhoneSwitcher.class, "sPhoneSwitcher", null, null); assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mSubscriptionControllerUT.getPreferredDataSubscriptionId()); } } Loading
src/java/com/android/internal/telephony/SubscriptionController.java +28 −3 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.telephony; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import android.Manifest; Loading @@ -41,6 +42,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.AnomalyReporter; import android.telephony.CarrierConfigManager; import android.telephony.RadioAccessFamily; import android.telephony.SubscriptionInfo; Loading Loading @@ -2947,8 +2949,23 @@ public class SubscriptionController extends ISub.Stub { final long token = Binder.clearCallingIdentity(); try { PhoneSwitcher.getInstance().trySetOpportunisticDataSubscription( subId, needValidation, callback); PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance(); if (phoneSwitcher == null) { logd("Set preferred data sub: phoneSwitcher is null."); AnomalyReporter.reportAnomaly( UUID.fromString("a3ab0b9d-f2aa-4baf-911d-7096c0d4645a"), "Set preferred data sub: phoneSwitcher is null."); if (callback != null) { try { callback.onComplete(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); } catch (RemoteException exception) { logd("RemoteException " + exception); } } return; } phoneSwitcher.trySetOpportunisticDataSubscription(subId, needValidation, callback); } finally { Binder.restoreCallingIdentity(token); } Loading @@ -2960,7 +2977,15 @@ public class SubscriptionController extends ISub.Stub { final long token = Binder.clearCallingIdentity(); try { return PhoneSwitcher.getInstance().getOpportunisticDataSubscriptionId(); PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance(); if (phoneSwitcher == null) { AnomalyReporter.reportAnomaly( UUID.fromString("a3ab0b9d-f2aa-4baf-911d-7096c0d4645a"), "Get preferred data sub: phoneSwitcher is null."); return SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; } return phoneSwitcher.getOpportunisticDataSubscriptionId(); } finally { Binder.restoreCallingIdentity(token); } Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.internal.telephony; import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; Loading Loading @@ -75,6 +77,8 @@ public class SubscriptionControllerTest extends TelephonyTest { private ITelephonyRegistry.Stub mTelephonyRegisteryMock; @Mock private MultiSimSettingController mMultiSimSettingControllerMock; @Mock private ISetOpportunisticDataCallback mSetOpptDataCallback; private static final String MAC_ADDRESS_PREFIX = "mac_"; private static final String DISPLAY_NAME_PREFIX = "my_phone_"; Loading Loading @@ -1091,4 +1095,22 @@ public class SubscriptionControllerTest extends TelephonyTest { > mSubscriptionControllerUT.getNameSourcePriority( SubscriptionManager.NAME_SOURCE_DEFAULT)); } @Test @SmallTest public void testSetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { replaceInstance(PhoneSwitcher.class, "sPhoneSwitcher", null, null); mSubscriptionControllerUT.setPreferredDataSubscriptionId(1, true, mSetOpptDataCallback); verify(mSetOpptDataCallback).onComplete(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION); } @Test @SmallTest public void testGetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { replaceInstance(PhoneSwitcher.class, "sPhoneSwitcher", null, null); assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mSubscriptionControllerUT.getPreferredDataSubscriptionId()); } }