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-20 22:57:52 +0000
commit4529cee025dcc67c4dbdaa5411a3106716303772 (patch)
tree2d5b4a14d94782478bdcaf76ba01c96b41dac457 /src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
parentad1d51e768f06afd9b252f46170f7e8ead985016 (diff)
downloadCellBroadcastReceiver-4529cee025dcc67c4dbdaa5411a3106716303772.tar.gz
Mock telephony api instead of static flag in CellBroadcastSettings
Bug: 196349924 Test: atest CellBroadcastReceiverOemUnitTests Test: atest CellBroadcastReceiverUnitTests Change-Id: I1630d09fca01033a47fb94f07d0b6d8d9c7430c0
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 0e958d497..355c5775d 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
@@ -831,16 +828,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
@@ -849,14 +836,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();
}