summaryrefslogtreecommitdiff
path: root/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
diff options
context:
space:
mode:
authorPresubmit Automerger Backend <android-build-presubmit-automerger-backend@system.gserviceaccount.com>2022-02-01 19:36:35 +0000
committerPresubmit Automerger Backend <android-build-presubmit-automerger-backend@system.gserviceaccount.com>2022-02-01 19:36:35 +0000
commit5a4a4f64b390141af09fc65829ebca9ee29ef498 (patch)
tree4d5631c4b0c5fae62f11f44b0c6d522ee4aa75b8 /src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
parent3d2a41fe0913f5de7c43b04f02eea09abbb54a94 (diff)
parent9beb2691d9507aff2e6eab2f1fcb9fafe12be070 (diff)
downloadCellBroadcastReceiver-5a4a4f64b390141af09fc65829ebca9ee29ef498.tar.gz
[automerge] Cache the resources when the mnc of the configuration is not zero 2p: 9beb2691d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/CellBroadcastReceiver/+/16623889 Bug: 214250834 Change-Id: I6a58d40958baca878b3c6cfdae5bb2e46f64861c
Diffstat (limited to 'src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java')
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index 4d461f83d..aae899d43 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -33,7 +33,6 @@ import android.os.Bundle;
import android.os.UserManager;
import android.os.Vibrator;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Switch;
@@ -854,17 +853,8 @@ public class CellBroadcastSettings extends CollapsingToolbarBaseActivity {
*/
public static @NonNull Resources getResources(@NonNull Context context, int subId) {
- try {
- if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID
- || !SubscriptionManager.isValidSubscriptionId(subId)
- // per 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();
- }
- } catch (Exception e) {
- Log.d(TAG, "Fail to getSimApplicationState due to " + e);
+ if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID
+ || !SubscriptionManager.isValidSubscriptionId(subId)) {
return context.getResources();
}
@@ -875,7 +865,11 @@ public class CellBroadcastSettings extends CollapsingToolbarBaseActivity {
Resources res = SubscriptionManager.getResourcesForSubId(context, subId);
- sResourcesCache.put(subId, res);
+ if (res.getConfiguration().mnc != 0) {
+ Log.d(TAG, "Cache resource for sub: " + subId + ", mcc: "
+ + res.getConfiguration().mcc + ", mnc:" + res.getConfiguration().mnc);
+ sResourcesCache.put(subId, res);
+ }
return res;
}