summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Wang <huiwang@google.com>2022-01-07 03:51:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-01-07 03:51:23 +0000
commit39bee58c8b4c159faaa2ebf50a8de4d96a2f0d90 (patch)
tree42fc3d653f1c1af5d366fc1029686ec0aeef1ef3
parent0f824c5169d4c49aee5de15db253d98b51080693 (diff)
parentf8bd708ca4d68e619852549433bb8b1ed07dee0c (diff)
downloadCellBroadcastReceiver-39bee58c8b4c159faaa2ebf50a8de4d96a2f0d90.tar.gz
Merge "Reset the cache of CellBroadcastChannelRange" into sc-mainline-prod
-rw-r--r--AndroidManifest.xml1
-rw-r--r--AndroidManifest_Platform.xml1
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java19
-rw-r--r--tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastReceiverTest.java1
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