summaryrefslogtreecommitdiff
path: root/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
diff options
context:
space:
mode:
authorHui Wang <huiwang@google.com>2021-08-20 22:50:53 +0000
committerHui Wang <huiwang@google.com>2021-08-26 21:17:38 +0000
commit14f7c8ada3af5eb1a43b4ce4c6b9d464db154d55 (patch)
treea9298213fad8459fbe1bb5f1a6cc7ab27abd39dd /src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
parent8a41e3afa83e9e52dfde2977b39132e7380b2355 (diff)
downloadCellBroadcastReceiver-14f7c8ada3af5eb1a43b4ce4c6b9d464db154d55.tar.gz
Mock telephony api instead of static flag in CellBroadcastSettings
Bug: 196349924 Test: atest CellBroadcastReceiverOemUnitTests Test: atest CellBroadcastReceiverUnitTests Merged-In: I1630d09fca01033a47fb94f07d0b6d8d9c7430c0 Change-Id: I1630d09fca01033a47fb94f07d0b6d8d9c7430c0 (cherry picked from commit 4529cee025dcc67c4dbdaa5411a3106716303772)
Diffstat (limited to 'src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java')
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index c8eb50057..8b84bd185 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -177,9 +177,6 @@ public class CellBroadcastSettings extends CollapsingToolbarBaseActivity {
// Key for shared preference which represents whether user has changed any preference
private static final String ANY_PREFERENCE_CHANGED_BY_USER = "any_preference_changed_by_user";
- // Test override for disabling the subId specific resources
- private static boolean sUseResourcesForSubId = true;
-
@Override
public void onCreate(Bundle savedInstanceState) {
// for backward compatibility on R devices
@@ -845,16 +842,6 @@ public class CellBroadcastSettings extends CollapsingToolbarBaseActivity {
}
/**
- * Override used by tests so that we don't call
- * SubscriptionManager.getResourcesForSubId, which is a static unmockable
- * method.
- */
- @VisibleForTesting
- public static void setUseResourcesForSubId(boolean useResourcesForSubId) {
- sUseResourcesForSubId = useResourcesForSubId;
- }
-
- /**
* Get the device resource based on SIM
*
* @param context Context
@@ -863,14 +850,12 @@ public class CellBroadcastSettings extends CollapsingToolbarBaseActivity {
* @return The resource
*/
public static @NonNull Resources getResources(@NonNull Context context, int subId) {
- // based on the latest design, subId can be valid earlier than mcc mnc is known to telephony
- // check if sim is loaded to avoid caching the wrong resources.
- TelephonyManager tm = context.getSystemService(TelephonyManager.class);
- boolean isSimLoaded = tm.getSimApplicationState(SubscriptionManager.getSlotIndex(subId))
- == TelephonyManager.SIM_STATE_LOADED;
if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID
- || !SubscriptionManager.isValidSubscriptionId(subId) || !sUseResourcesForSubId
- || !isSimLoaded) {
+ || !SubscriptionManager.isValidSubscriptionId(subId)
+ // based on the latest design, subId can be valid earlier than mcc mnc is known to
+ // telephony. check if sim is loaded to avoid caching the wrong resources.
+ || context.getSystemService(TelephonyManager.class).getSimApplicationState(
+ SubscriptionManager.getSlotIndex(subId)) != TelephonyManager.SIM_STATE_LOADED) {
return context.getResources();
}