summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
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);
}