Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −1 Original line number Diff line number Diff line Loading @@ -1194,7 +1194,8 @@ public class SubscriptionInfoUpdater extends Handler { loge("Cannot manage subId=" + currentSubId + ", carrierPackage=" + configPackageName); } else { boolean isOpportunistic = config.getBoolean( CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL, false); CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL, currentSubInfo.isOpportunistic()); if (currentSubInfo.isOpportunistic() != isOpportunistic) { if (DBG) logd("Set SubId=" + currentSubId + " isOpportunistic=" + isOpportunistic); cv.put(SubscriptionManager.IS_OPPORTUNISTIC, isOpportunistic ? "1" : "0"); Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -792,6 +792,38 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged(); } @Test @SmallTest public void testOpportunisticSubscriptionNotUnsetWithEmptyConfigKey() throws Exception { final int phoneId = mPhone.getPhoneId(); PersistableBundle carrierConfig = new PersistableBundle(); String carrierPackageName = "FakeCarrierPackageName"; doReturn(FAKE_SUB_ID_1).when(mSubscriptionController).getSubIdUsingPhoneId(phoneId); doReturn(mSubInfo).when(mSubscriptionController).getSubscriptionInfo(eq(FAKE_SUB_ID_1)); doReturn(true).when(mSubInfo).isOpportunistic(); doReturn(carrierPackageName).when(mTelephonyManager) .getCarrierServicePackageNameForLogicalSlot(eq(phoneId)); ((MockContentResolver) mContext.getContentResolver()).addProvider( SubscriptionManager.CONTENT_URI.getAuthority(), new FakeSubscriptionContentProvider()); mUpdater.updateSubscriptionByCarrierConfig(mPhone.getPhoneId(), carrierPackageName, carrierConfig); ArgumentCaptor<ContentValues> cvCaptor = ArgumentCaptor.forClass(ContentValues.class); verify(mContentProvider, times(1)).update( eq(SubscriptionManager.getUriForSubscriptionId(FAKE_SUB_ID_1)), cvCaptor.capture(), eq(null), eq(null)); // no key is added for the opportunistic bit assertNull(cvCaptor.getValue().getAsInteger(SubscriptionManager.IS_OPPORTUNISTIC)); // only carrier certs updated assertEquals(1, cvCaptor.getValue().size()); verify(mSubscriptionController, times(1)).refreshCachedActiveSubscriptionInfoList(); verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged(); } @Test @SmallTest public void testUpdateFromCarrierConfigOpportunisticAddToGroup() throws Exception { Loading Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −1 Original line number Diff line number Diff line Loading @@ -1194,7 +1194,8 @@ public class SubscriptionInfoUpdater extends Handler { loge("Cannot manage subId=" + currentSubId + ", carrierPackage=" + configPackageName); } else { boolean isOpportunistic = config.getBoolean( CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL, false); CarrierConfigManager.KEY_IS_OPPORTUNISTIC_SUBSCRIPTION_BOOL, currentSubInfo.isOpportunistic()); if (currentSubInfo.isOpportunistic() != isOpportunistic) { if (DBG) logd("Set SubId=" + currentSubId + " isOpportunistic=" + isOpportunistic); cv.put(SubscriptionManager.IS_OPPORTUNISTIC, isOpportunistic ? "1" : "0"); Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -792,6 +792,38 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged(); } @Test @SmallTest public void testOpportunisticSubscriptionNotUnsetWithEmptyConfigKey() throws Exception { final int phoneId = mPhone.getPhoneId(); PersistableBundle carrierConfig = new PersistableBundle(); String carrierPackageName = "FakeCarrierPackageName"; doReturn(FAKE_SUB_ID_1).when(mSubscriptionController).getSubIdUsingPhoneId(phoneId); doReturn(mSubInfo).when(mSubscriptionController).getSubscriptionInfo(eq(FAKE_SUB_ID_1)); doReturn(true).when(mSubInfo).isOpportunistic(); doReturn(carrierPackageName).when(mTelephonyManager) .getCarrierServicePackageNameForLogicalSlot(eq(phoneId)); ((MockContentResolver) mContext.getContentResolver()).addProvider( SubscriptionManager.CONTENT_URI.getAuthority(), new FakeSubscriptionContentProvider()); mUpdater.updateSubscriptionByCarrierConfig(mPhone.getPhoneId(), carrierPackageName, carrierConfig); ArgumentCaptor<ContentValues> cvCaptor = ArgumentCaptor.forClass(ContentValues.class); verify(mContentProvider, times(1)).update( eq(SubscriptionManager.getUriForSubscriptionId(FAKE_SUB_ID_1)), cvCaptor.capture(), eq(null), eq(null)); // no key is added for the opportunistic bit assertNull(cvCaptor.getValue().getAsInteger(SubscriptionManager.IS_OPPORTUNISTIC)); // only carrier certs updated assertEquals(1, cvCaptor.getValue().size()); verify(mSubscriptionController, times(1)).refreshCachedActiveSubscriptionInfoList(); verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged(); } @Test @SmallTest public void testUpdateFromCarrierConfigOpportunisticAddToGroup() throws Exception { Loading