am 6d492b6d: Merge "CB: Add CDMA CMAS"
# By Rika Brooks
# Via Gerrit Code Review (1) and Rika Brooks (1)
* commit '6d492b6d2d628dd2c97b3ca5dd9e0a031905cb15':
CB: Add CDMA CMAS
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
index 41764af..64c220b 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastConfigService.java
@@ -29,6 +29,7 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.internal.telephony.cdma.sms.SmsEnvelope;
import com.android.internal.telephony.gsm.SmsCbConstants;
import static com.android.cellbroadcastreceiver.CellBroadcastReceiver.DBG;
@@ -49,6 +50,9 @@
static final String ACTION_ENABLE_CHANNELS = "ACTION_ENABLE_CHANNELS";
+ static final String EMERGENCY_BROADCAST_RANGE_GSM =
+ "ro.cb.gsm.emergencyids";
+
public CellBroadcastConfigService() {
super(TAG); // use class name for worker thread name
}
@@ -86,7 +90,11 @@
// Make sure CMAS Presidential is enabled (See 3GPP TS 22.268 Section 6.2).
if (DBG) log("setChannelRange: enabling CMAS Presidential");
- manager.enableCellBroadcast(SmsCbConstants.MESSAGE_ID_CMAS_ALERT_PRESIDENTIAL_LEVEL);
+ if (CellBroadcastReceiver.phoneIsCdma()) {
+ manager.enableCellBroadcast(SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT);
+ } else {
+ manager.enableCellBroadcast(SmsCbConstants.MESSAGE_ID_CMAS_ALERT_PRESIDENTIAL_LEVEL);
+ }
}
/**
@@ -101,7 +109,9 @@
}
// Check for system property defining the emergency channel ranges to enable
- String emergencyIdRange = SystemProperties.get("ro.cellbroadcast.emergencyids");
+ String emergencyIdRange = (CellBroadcastReceiver.phoneIsCdma()) ?
+ "" : SystemProperties.get(EMERGENCY_BROADCAST_RANGE_GSM);
+
if (TextUtils.isEmpty(emergencyIdRange)) {
return false;
}
@@ -134,9 +144,11 @@
try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Resources res = getResources();
+ boolean isCdma = CellBroadcastReceiver.phoneIsCdma();
// Check for system property defining the emergency channel ranges to enable
- String emergencyIdRange = SystemProperties.get("ro.cellbroadcast.emergencyids");
+ String emergencyIdRange = isCdma ?
+ "" : SystemProperties.get(EMERGENCY_BROADCAST_RANGE_GSM);
boolean enableEmergencyAlerts = prefs.getBoolean(
CellBroadcastSettings.KEY_ENABLE_EMERGENCY_ALERTS, true);
@@ -155,6 +167,15 @@
if (DBG) log("enabling emergency cell broadcast channels");
if (!TextUtils.isEmpty(emergencyIdRange)) {
setChannelRange(manager, emergencyIdRange, true);
+ } else if (isCdma){
+ // No emergency channel system property, enable all emergency channels
+ manager.enableCellBroadcastRange(
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT,
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE);
+
+ // CMAS Presidential must be on.
+ manager.enableCellBroadcast(
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT);
} else {
// No emergency channel system property, enable all emergency channels
manager.enableCellBroadcastRange(
@@ -171,6 +192,15 @@
if (DBG) log("disabling emergency cell broadcast channels");
if (!TextUtils.isEmpty(emergencyIdRange)) {
setChannelRange(manager, emergencyIdRange, false);
+ } else if (isCdma) {
+ // No emergency channel system property, disable all emergency channels
+ manager.disableCellBroadcastRange(
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT,
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE);
+
+ // CMAS Presidential must be on.
+ manager.enableCellBroadcast(
+ SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT);
} else {
// No emergency channel system property, disable all emergency channels
// except for CMAS Presidential (See 3GPP TS 22.268 Section 6.2)
@@ -184,7 +214,9 @@
if (DBG) log("disabled emergency cell broadcast channels");
}
- if (enableChannel50Alerts) {
+ if (isCdma) {
+ if (DBG) log("channel 50 is not aplicable for cdma");
+ } else if (enableChannel50Alerts) {
if (DBG) log("enabling cell broadcast channel 50");
manager.enableCellBroadcast(50);
if (DBG) log("enabled cell broadcast channel 50");
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
index 3eef633..c1eeeab 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java
@@ -61,6 +61,7 @@
PhoneStateListener.LISTEN_SERVICE_STATE);
} else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) {
boolean airplaneModeOn = intent.getBooleanExtra("state", false);
+ if (DBG) log("airplaneModeOn: " + airplaneModeOn);
if (!airplaneModeOn) {
startConfigService(context);
}
@@ -74,7 +75,7 @@
intent.setClass(context, CellBroadcastAlertService.class);
context.startService(intent);
} else {
- Log.e(TAG, "ignoring unprivileged action received " + action);
+ loge("ignoring unprivileged action received " + action);
}
} else if (Telephony.Sms.Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION
.equals(action)) {
@@ -84,10 +85,10 @@
if (programDataList != null) {
handleCdmaSmsCbProgramData(context, programDataList);
} else {
- Log.e(TAG, "SCPD intent received with no program_data_list");
+ loge("SCPD intent received with no program_data_list");
}
} else {
- Log.e(TAG, "ignoring unprivileged action received " + action);
+ loge("ignoring unprivileged action received " + action);
}
} else if (GET_LATEST_CB_AREA_INFO_ACTION.equals(action)) {
if (privileged) {
@@ -138,7 +139,7 @@
break;
default:
- Log.e(TAG, "Ignoring unknown SCPD operation " + programData.getOperation());
+ loge("Ignoring unknown SCPD operation " + programData.getOperation());
}
}
}
@@ -180,19 +181,15 @@
* @param context the broadcast receiver context
*/
static void startConfigService(Context context) {
- if (phoneIsCdma()) {
- if (DBG) log("CDMA phone detected; doing nothing");
- } else {
- Intent serviceIntent = new Intent(CellBroadcastConfigService.ACTION_ENABLE_CHANNELS,
- null, context, CellBroadcastConfigService.class);
- context.startService(serviceIntent);
- }
+ Intent serviceIntent = new Intent(CellBroadcastConfigService.ACTION_ENABLE_CHANNELS,
+ null, context, CellBroadcastConfigService.class);
+ context.startService(serviceIntent);
}
/**
* @return true if the phone is a CDMA phone type
*/
- private static boolean phoneIsCdma() {
+ static boolean phoneIsCdma() {
boolean isCdma = false;
try {
ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
@@ -230,4 +227,8 @@
private static void log(String msg) {
Log.d(TAG, msg);
}
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
}