summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-06-25 07:44:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-25 07:44:35 +0000
commita5118454668356b6593c25595760231ab9a1b2a8 (patch)
treeea14e20e99617962d3a5b072e392c387d5581755
parent198f29e82b96bd79ad974ddf0ef0200d00a334f9 (diff)
parent3a0c7a0d45744370aadb9cb1a36bf9a483422bc1 (diff)
downloadCellBroadcastReceiver-a5118454668356b6593c25595760231ab9a1b2a8.tar.gz
Merge "resend CMAS channel config cmd to lower layer when exit APM" into rvc-dev
-rw-r--r--AndroidManifest.xml1
-rw-r--r--AndroidManifest_Platform.xml1
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java35
3 files changed, 37 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 438b081c6..3911fe226 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -131,6 +131,7 @@
<action android:name="android.cellbroadcastreceiver.START_CONFIG" />
<action android:name="android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED" />
<action android:name="android.intent.action.LOCALE_CHANGED" />
+ <action android:name="android.intent.action.SERVICE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.telephony.action.SECRET_CODE" />
diff --git a/AndroidManifest_Platform.xml b/AndroidManifest_Platform.xml
index 69d443f57..d7f44e696 100644
--- a/AndroidManifest_Platform.xml
+++ b/AndroidManifest_Platform.xml
@@ -126,6 +126,7 @@
<action android:name="android.intent.action.LOCALE_CHANGED" />
<action android:name="android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED" />
<action android:name="android.telephony.action.CARRIER_CONFIG_CHANGED" />
+ <action android:name="android.intent.action.SERVICE_STATE" />
</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 9183b095f..defc9fde1 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
@@ -37,6 +37,7 @@ import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.provider.Telephony.CellBroadcasts;
import android.telephony.CarrierConfigManager;
+import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaSmsCbProgramData;
@@ -62,9 +63,15 @@ public class CellBroadcastReceiver extends BroadcastReceiver {
// Key to access the shared preference of cell broadcast testing mode.
private static final String TESTING_MODE = "testing_mode";
+ // Key to access the shared preference of service state.
+ private static final String SERVICE_STATE = "service_state";
+
// shared preference under developer settings
private static final String ENABLE_ALERT_MASTER_PREF = "enable_alerts_master_toggle";
+ public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
+ public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
+
// Intent actions and extras
public static final String CELLBROADCAST_START_CONFIG_ACTION =
"com.android.cellbroadcastreceiver.intent.START_CONFIG";
@@ -120,6 +127,16 @@ public class CellBroadcastReceiver extends BroadcastReceiver {
initializeSharedPreference();
enableLauncher();
startConfigService();
+ } else if (ACTION_SERVICE_STATE.equals(action)) {
+ // lower layer clears channel configurations under APM, thus need to resend
+ // configurations once moving back from APM. This should be fixed in lower layer
+ // going forward.
+ int ss = intent.getIntExtra(EXTRA_VOICE_REG_STATE, ServiceState.STATE_IN_SERVICE);
+ if (ss != ServiceState.STATE_POWER_OFF
+ && getServiceState(context) == ServiceState.STATE_POWER_OFF) {
+ startConfigService();
+ }
+ setServiceState(ss);
} else if (CELLBROADCAST_START_CONFIG_ACTION.equals(action)
|| SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED.equals(action)) {
startConfigService();
@@ -180,6 +197,24 @@ public class CellBroadcastReceiver extends BroadcastReceiver {
}
/**
+ * Store the current service state for voice registration.
+ *
+ * @param ss current voice registration service state.
+ */
+ private void setServiceState(int ss) {
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
+ sp.edit().putInt(SERVICE_STATE, ss).commit();
+ }
+
+ /**
+ * @return the stored voice registration service state
+ */
+ private static int getServiceState(Context context) {
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
+ return sp.getInt(SERVICE_STATE, ServiceState.STATE_IN_SERVICE);
+ }
+
+ /**
* update reminder interval
*/
@VisibleForTesting