summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorxinhe <xinhe@google.com>2014-09-30 15:14:39 -0700
committerJohn Huang <jsh@google.com>2014-09-30 23:57:34 +0000
commit0a2aef9d9ece08c4821f3eaf8208314af4d77dd0 (patch)
tree823946518386b644c126116316dc55b69219b808 /src/com/android
parent5a853498a52dd249dda506dbee05c1b58281368d (diff)
downloadandroid_packages_apps_CellBroadcastReceiver-0a2aef9d9ece08c4821f3eaf8208314af4d77dd0.tar.gz
android_packages_apps_CellBroadcastReceiver-0a2aef9d9ece08c4821f3eaf8208314af4d77dd0.tar.bz2
android_packages_apps_CellBroadcastReceiver-0a2aef9d9ece08c4821f3eaf8208314af4d77dd0.zip
Fix for CMAS is not turned on
CMAS is not turned on for several reasons: (1) Exception happends when default SMS sub Id is not available. (2) Cellbroadcast thread can die before the servicestate change triggered Bug:17571958 Change-Id: I7b210226fa24f266896763ff80235c4ed4b936eb
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
index c1eeeab7..a04cc2c7 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
@@ -27,7 +27,6 @@ import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.telephony.CellBroadcastMessage;
-import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaSmsCbProgramData;
@@ -35,11 +34,12 @@ import android.util.Log;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
+import com.android.internal.telephony.TelephonyIntents;
public class CellBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = "CellBroadcastReceiver";
static final boolean DBG = true; // STOPSHIP: change to false before ship
-
+ private int mServiceState = -1;
private static final String GET_LATEST_CB_AREA_INFO_ACTION =
"android.cellbroadcastreceiver.GET_LATEST_CB_AREA_INFO";
@@ -53,12 +53,19 @@ public class CellBroadcastReceiver extends BroadcastReceiver {
String action = intent.getAction();
- if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
- if (DBG) log("Registering for ServiceState updates");
- TelephonyManager tm = (TelephonyManager) context.getSystemService(
- Context.TELEPHONY_SERVICE);
- tm.listen(new ServiceStateListener(context.getApplicationContext()),
- PhoneStateListener.LISTEN_SERVICE_STATE);
+ if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) {
+ if (DBG) log("Intent ACTION_SERVICE_STATE_CHANGED");
+ ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
+ int newState = serviceState.getState();
+ if (newState != mServiceState) {
+ Log.d(TAG, "Service state changed! " + newState + " Full: " + serviceState +
+ " Current state=" + mServiceState);
+ mServiceState = newState;
+ if (newState == ServiceState.STATE_IN_SERVICE ||
+ newState == ServiceState.STATE_EMERGENCY_ONLY) {
+ startConfigService(context.getApplicationContext());
+ }
+ }
} else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
boolean airplaneModeOn = intent.getBooleanExtra("state", false);
if (DBG) log("airplaneModeOn: " + airplaneModeOn);
@@ -202,28 +209,6 @@ public class CellBroadcastReceiver extends BroadcastReceiver {
return isCdma;
}
- private static class ServiceStateListener extends PhoneStateListener {
- private final Context mContext;
- private int mServiceState = -1;
-
- ServiceStateListener(Context context) {
- mContext = context;
- }
-
- @Override
- public void onServiceStateChanged(ServiceState ss) {
- int newState = ss.getState();
- if (newState != mServiceState) {
- Log.d(TAG, "Service state changed! " + newState + " Full: " + ss);
- mServiceState = newState;
- if (newState == ServiceState.STATE_IN_SERVICE ||
- newState == ServiceState.STATE_EMERGENCY_ONLY) {
- startConfigService(mContext);
- }
- }
- }
- }
-
private static void log(String msg) {
Log.d(TAG, msg);
}