diff options
author | Hui Wang <huiwang@google.com> | 2022-01-07 03:51:23 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-01-07 03:51:23 +0000 |
commit | 39bee58c8b4c159faaa2ebf50a8de4d96a2f0d90 (patch) | |
tree | 42fc3d653f1c1af5d366fc1029686ec0aeef1ef3 | |
parent | 0f824c5169d4c49aee5de15db253d98b51080693 (diff) | |
parent | f8bd708ca4d68e619852549433bb8b1ed07dee0c (diff) | |
download | CellBroadcastReceiver-39bee58c8b4c159faaa2ebf50a8de4d96a2f0d90.tar.gz |
Merge "Reset the cache of CellBroadcastChannelRange" into sc-mainline-prod
4 files changed, 12 insertions, 10 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 41b6cda9f..bf33287e9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -156,7 +156,6 @@ <action android:name="android.intent.action.LOCALE_CHANGED" /> <action android:name="android.intent.action.SERVICE_STATE" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> - <action android:name="android.telephony.action.SIM_CARD_STATE_CHANGED" /> </intent-filter> <intent-filter> <action android:name="android.telephony.action.SECRET_CODE" /> diff --git a/AndroidManifest_Platform.xml b/AndroidManifest_Platform.xml index 97fe7231a..be36e2f91 100644 --- a/AndroidManifest_Platform.xml +++ b/AndroidManifest_Platform.xml @@ -136,7 +136,6 @@ <action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" /> <action android:name="android.intent.action.SERVICE_STATE" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> - <action android:name="android.telephony.action.SIM_CARD_STATE_CHANGED" /> </intent-filter> <intent-filter> <action android:name="android.telephony.action.SECRET_CODE" /> diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java index 14ebe3b0c..cab4ce5f3 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java @@ -129,6 +129,7 @@ public class CellBroadcastReceiver extends BroadcastReceiver { } else if (CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED.equals(action)) { if (!intent.getBooleanExtra( "android.telephony.extra.REBROADCAST_ON_UNLOCK", false)) { + resetCellBroadcastChannelRanges(); int subId = intent.getIntExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, SubscriptionManager.INVALID_SUBSCRIPTION_ID); initializeSharedPreference(context, subId); @@ -196,14 +197,6 @@ public class CellBroadcastReceiver extends BroadcastReceiver { provider.resyncToSmsInbox(mContext); return true; }); - } else if (TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED.equals(action)) { - int sim_state = intent.getIntExtra( - TelephonyManager.EXTRA_SIM_STATE, TelephonyManager.SIM_STATE_UNKNOWN); - - if (sim_state == TelephonyManager.SIM_STATE_ABSENT - || sim_state == TelephonyManager.SIM_STATE_PRESENT) { - CellBroadcastChannelManager.clearAllCellBroadcastChannelRanges(); - } } else { Log.w(TAG, "onReceive() unexpected action " + action); } @@ -709,6 +702,16 @@ public class CellBroadcastReceiver extends BroadcastReceiver { } } + /** + * Reset cached CellBroadcastChannelRanges + * + * This method's purpose is to enable unit testing + */ + @VisibleForTesting + public void resetCellBroadcastChannelRanges() { + CellBroadcastChannelManager.clearAllCellBroadcastChannelRanges(); + } + private static void log(String msg) { Log.d(TAG, msg); } diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java index 8b6377c90..77979e1de 100644 --- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java +++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java @@ -138,6 +138,7 @@ public class CellBroadcastReceiverTest extends CellBroadcastTest { verify(mCellBroadcastReceiver).initializeSharedPreference(any(), anyInt()); verify(mCellBroadcastReceiver).startConfigServiceToEnableChannels(); verify(mCellBroadcastReceiver).enableLauncher(); + verify(mCellBroadcastReceiver).resetCellBroadcastChannelRanges(); } @Test |