Loading src/java/com/android/internal/telephony/MccTable.java +16 −26 Original line number Diff line number Diff line Loading @@ -21,16 +21,14 @@ import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.content.Context; import android.content.res.Configuration; import android.os.Build; import android.os.RemoteException; import android.os.SystemProperties; import com.android.telephony.Rlog; import android.text.TextUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.util.TelephonyUtils; import com.android.telephony.Rlog; import libcore.timezone.TelephonyLookup; import libcore.timezone.TelephonyNetwork; Loading Loading @@ -286,36 +284,28 @@ public final class MccTable { } if (!TextUtils.isEmpty(mccmnc)) { int mcc, mnc; int mccInt; try { mcc = Integer.parseInt(mccmnc.substring(0, 3)); mnc = Integer.parseInt(mccmnc.substring(3)); mccInt = Integer.parseInt(mccmnc.substring(0, 3)); } catch (NumberFormatException | StringIndexOutOfBoundsException ex) { Rlog.e(LOG_TAG, "Error parsing IMSI: " + mccmnc + ". ex=" + ex); Rlog.e(LOG_TAG, "Error parsing mccmnc: " + mccmnc + ". ex=" + ex); return; } Rlog.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc); try { Configuration config = new Configuration(); boolean updateConfig = false; if (mcc != 0) { config.mcc = mcc; config.mnc = mnc == 0 ? Configuration.MNC_ZERO : mnc; updateConfig = true; if (mccInt != 0) { ActivityManager activityManager = (ActivityManager) context.getSystemService( Context.ACTIVITY_SERVICE); if (!activityManager.updateMccMncConfiguration( mccmnc.substring(0, 3), mccmnc.substring(3))) { Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc=" + mccmnc + " failure"); return; } else { Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc=" + mccmnc + " success"); } if (updateConfig) { Rlog.d(LOG_TAG, "updateMccMncConfiguration updateConfig config=" + config); ActivityManager.getService().updateConfiguration(config); } else { Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update"); } } catch (RemoteException e) { Rlog.e(LOG_TAG, "Can't update configuration", e); } } } Loading tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.DownloadManager; Loading Loading @@ -227,6 +228,8 @@ public class ContextFixture implements TestFixture<Context> { switch (name) { case Context.TELEPHONY_SERVICE: return mTelephonyManager; case Context.ACTIVITY_SERVICE: return mActivityManager; case Context.APP_OPS_SERVICE: return mAppOpsManager; case Context.NOTIFICATION_SERVICE: Loading Loading @@ -595,6 +598,7 @@ public class ContextFixture implements TestFixture<Context> { private final ApplicationInfo mApplicationInfo = mock(ApplicationInfo.class); private final PackageManager mPackageManager = mock(PackageManager.class); private final TelephonyManager mTelephonyManager = mock(TelephonyManager.class); private final ActivityManager mActivityManager = mock(ActivityManager.class); private final DownloadManager mDownloadManager = mock(DownloadManager.class); private final AppOpsManager mAppOpsManager = mock(AppOpsManager.class); private final NotificationManager mNotificationManager = mock(NotificationManager.class); Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { .getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1)); doReturn("89012604200000000000").when(mIccRecord).getFullIccId(); doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(FAKE_SUB_ID_1); when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn( true); mUpdater.updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_LOADED, null, FAKE_SUB_ID_1, false); Loading Loading @@ -445,6 +447,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { doReturn(FAKE_SUB_ID_2).when(mSubscriptionController).getPhoneId(eq(FAKE_SUB_ID_2)); doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(2).when(mTelephonyManager).getActiveModemCount(); when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn( true); doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_1)); doReturn(FAKE_MCC_MNC_2).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_2)); verify(mSubscriptionController, times(0)).clearSubInfo(); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ public abstract class TelephonyTest { @Mock protected IccCard mIccCard; protected ActivityManager mActivityManager; protected ImsCallProfile mImsCallProfile; protected TelephonyManager mTelephonyManager; protected TelephonyRegistryManager mTelephonyRegistryManager; Loading Loading @@ -398,6 +399,7 @@ public abstract class TelephonyTest { doReturn(mUiccProfile).when(mUiccCard).getUiccProfile(); mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); mTelephonyRegistryManager = (TelephonyRegistryManager) mContext.getSystemService( Context.TELEPHONY_REGISTRY_SERVICE); mSubscriptionManager = (SubscriptionManager) mContext.getSystemService( Loading Loading
src/java/com/android/internal/telephony/MccTable.java +16 −26 Original line number Diff line number Diff line Loading @@ -21,16 +21,14 @@ import android.annotation.Nullable; import android.annotation.UnsupportedAppUsage; import android.app.ActivityManager; import android.content.Context; import android.content.res.Configuration; import android.os.Build; import android.os.RemoteException; import android.os.SystemProperties; import com.android.telephony.Rlog; import android.text.TextUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.util.TelephonyUtils; import com.android.telephony.Rlog; import libcore.timezone.TelephonyLookup; import libcore.timezone.TelephonyNetwork; Loading Loading @@ -286,36 +284,28 @@ public final class MccTable { } if (!TextUtils.isEmpty(mccmnc)) { int mcc, mnc; int mccInt; try { mcc = Integer.parseInt(mccmnc.substring(0, 3)); mnc = Integer.parseInt(mccmnc.substring(3)); mccInt = Integer.parseInt(mccmnc.substring(0, 3)); } catch (NumberFormatException | StringIndexOutOfBoundsException ex) { Rlog.e(LOG_TAG, "Error parsing IMSI: " + mccmnc + ". ex=" + ex); Rlog.e(LOG_TAG, "Error parsing mccmnc: " + mccmnc + ". ex=" + ex); return; } Rlog.d(LOG_TAG, "updateMccMncConfiguration: mcc=" + mcc + ", mnc=" + mnc); try { Configuration config = new Configuration(); boolean updateConfig = false; if (mcc != 0) { config.mcc = mcc; config.mnc = mnc == 0 ? Configuration.MNC_ZERO : mnc; updateConfig = true; if (mccInt != 0) { ActivityManager activityManager = (ActivityManager) context.getSystemService( Context.ACTIVITY_SERVICE); if (!activityManager.updateMccMncConfiguration( mccmnc.substring(0, 3), mccmnc.substring(3))) { Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc=" + mccmnc + " failure"); return; } else { Rlog.d(LOG_TAG, "updateMccMncConfiguration: update mccmnc=" + mccmnc + " success"); } if (updateConfig) { Rlog.d(LOG_TAG, "updateMccMncConfiguration updateConfig config=" + config); ActivityManager.getService().updateConfiguration(config); } else { Rlog.d(LOG_TAG, "updateMccMncConfiguration nothing to update"); } } catch (RemoteException e) { Rlog.e(LOG_TAG, "Can't update configuration", e); } } } Loading
tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.DownloadManager; Loading Loading @@ -227,6 +228,8 @@ public class ContextFixture implements TestFixture<Context> { switch (name) { case Context.TELEPHONY_SERVICE: return mTelephonyManager; case Context.ACTIVITY_SERVICE: return mActivityManager; case Context.APP_OPS_SERVICE: return mAppOpsManager; case Context.NOTIFICATION_SERVICE: Loading Loading @@ -595,6 +598,7 @@ public class ContextFixture implements TestFixture<Context> { private final ApplicationInfo mApplicationInfo = mock(ApplicationInfo.class); private final PackageManager mPackageManager = mock(PackageManager.class); private final TelephonyManager mTelephonyManager = mock(TelephonyManager.class); private final ActivityManager mActivityManager = mock(ActivityManager.class); private final DownloadManager mDownloadManager = mock(DownloadManager.class); private final AppOpsManager mAppOpsManager = mock(AppOpsManager.class); private final NotificationManager mNotificationManager = mock(NotificationManager.class); Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -315,6 +315,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { .getSubInfoUsingSlotIndexPrivileged(eq(FAKE_SUB_ID_1)); doReturn("89012604200000000000").when(mIccRecord).getFullIccId(); doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(FAKE_SUB_ID_1); when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn( true); mUpdater.updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_LOADED, null, FAKE_SUB_ID_1, false); Loading Loading @@ -445,6 +447,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest { doReturn(FAKE_SUB_ID_2).when(mSubscriptionController).getPhoneId(eq(FAKE_SUB_ID_2)); doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(2).when(mTelephonyManager).getActiveModemCount(); when(mActivityManager.updateMccMncConfiguration(anyString(), anyString())).thenReturn( true); doReturn(FAKE_MCC_MNC_1).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_1)); doReturn(FAKE_MCC_MNC_2).when(mTelephonyManager).getSimOperatorNumeric(eq(FAKE_SUB_ID_2)); verify(mSubscriptionController, times(0)).clearSubInfo(); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ public abstract class TelephonyTest { @Mock protected IccCard mIccCard; protected ActivityManager mActivityManager; protected ImsCallProfile mImsCallProfile; protected TelephonyManager mTelephonyManager; protected TelephonyRegistryManager mTelephonyRegistryManager; Loading Loading @@ -398,6 +399,7 @@ public abstract class TelephonyTest { doReturn(mUiccProfile).when(mUiccCard).getUiccProfile(); mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); mTelephonyRegistryManager = (TelephonyRegistryManager) mContext.getSystemService( Context.TELEPHONY_REGISTRY_SERVICE); mSubscriptionManager = (SubscriptionManager) mContext.getSystemService( Loading