Support CDMA emergency callback. (1/2)
1. Update emergency callback mode notification icon and update creation of
the notification to use a builder.
2. For CDMA calls, if phone is in ECM mode, disable mute in the
Connection PhoneCapabilities.
Bug: 16182748
Change-Id: I698eb7d377346467fc4b87a0bec53d89f96797b1
diff --git a/src/com/android/phone/EmergencyCallbackModeExitDialog.java b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
index 7758b23..921b7f7 100644
--- a/src/com/android/phone/EmergencyCallbackModeExitDialog.java
+++ b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
@@ -205,7 +205,7 @@
case EXIT_ECM_DIALOG:
CharSequence text = getDialogText(mEcmTimeout);
mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
- .setIcon(R.drawable.picture_emergency32x32)
+ .setIcon(R.drawable.ic_emergency_callback_mode)
.setTitle(R.string.phone_in_ecm_notification_title)
.setMessage(text)
.setPositiveButton(R.string.alert_dialog_yes,
@@ -233,7 +233,7 @@
case EXIT_ECM_IN_EMERGENCY_CALL_DIALOG:
mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
- .setIcon(R.drawable.picture_emergency32x32)
+ .setIcon(R.drawable.ic_emergency_callback_mode)
.setTitle(R.string.phone_in_ecm_notification_title)
.setMessage(R.string.alert_dialog_in_ecm_call)
.setNeutralButton(R.string.alert_dialog_dismiss,
diff --git a/src/com/android/phone/EmergencyCallbackModeService.java b/src/com/android/phone/EmergencyCallbackModeService.java
index 5309eaf..e1f7fb3 100644
--- a/src/com/android/phone/EmergencyCallbackModeService.java
+++ b/src/com/android/phone/EmergencyCallbackModeService.java
@@ -25,6 +25,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
+import android.graphics.BitmapFactory;
import android.os.AsyncResult;
import android.os.Binder;
import android.os.CountDownTimer;
@@ -163,16 +164,19 @@
* Shows notification for Emergency Callback Mode
*/
private void showNotification(long millisUntilFinished) {
-
- // Set the icon and text
- Notification notification = new Notification(
- R.drawable.picture_emergency25x25,
- getText(R.string.phone_entered_ecm_text), 0);
+ final Notification.Builder builder = new Notification.Builder(getApplicationContext());
+ builder.setOngoing(true);
+ builder.setPriority(Notification.PRIORITY_HIGH);
+ builder.setSmallIcon(R.drawable.ic_emergency_callback_mode);
+ builder.setTicker(getText(R.string.phone_entered_ecm_text));
+ builder.setContentTitle(getText(R.string.phone_in_ecm_notification_title));
+ builder.setColor(getResources().getColor(R.color.dialer_theme_color));
// PendingIntent to launch Emergency Callback Mode Exit activity if the user selects
// this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(EmergencyCallbackModeExitDialog.ACTION_SHOW_ECM_EXIT_DIALOG), 0);
+ builder.setContentIntent(contentIntent);
// Format notification string
String text = null;
@@ -184,14 +188,10 @@
text = String.format(getResources().getQuantityText(
R.plurals.phone_in_ecm_notification_time, minutes).toString(), time);
}
- // Set the info in the notification
- notification.setLatestEventInfo(this, getText(R.string.phone_in_ecm_notification_title),
- text, contentIntent);
-
- notification.flags = Notification.FLAG_ONGOING_EVENT;
+ builder.setContentText(text);
// Show notification
- mNotificationManager.notify(R.string.phone_in_ecm_notification_title, notification);
+ mNotificationManager.notify(R.string.phone_in_ecm_notification_title, builder.build());
}
/**
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index f13676a..67104b5 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -24,8 +24,15 @@
* Manages a single phone call handled by CDMA.
*/
final class CdmaConnection extends TelephonyConnection {
- CdmaConnection(Connection connection) {
+
+ /**
+ * {@code True} if the CDMA connection should allow mute.
+ */
+ private final boolean mAllowMute;
+
+ CdmaConnection(Connection connection, boolean allowMute) {
super(connection);
+ mAllowMute = allowMute;
}
/** {@inheritDoc} */
@@ -49,7 +56,10 @@
@Override
protected int buildCallCapabilities() {
- int capabilities = PhoneCapabilities.MUTE;
+ int capabilities = 0;
+ if (mAllowMute) {
+ capabilities = PhoneCapabilities.MUTE;
+ }
return capabilities;
}
}
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 7c4d1ae..851269d 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -36,7 +36,9 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.SubscriptionController;
+import com.android.internal.telephony.cdma.CDMAPhone;
import com.android.phone.MMIDialogActivity;
import java.util.Objects;
@@ -120,7 +122,7 @@
}
}
- final TelephonyConnection connection = createConnectionFor(phone.getPhoneType(), null);
+ final TelephonyConnection connection = createConnectionFor(phone, null);
if (connection == null) {
return Connection.createFailedConnection(
DisconnectCause.OUTGOING_FAILURE, "Invalid phone type");
@@ -182,7 +184,7 @@
return Connection.createCanceledConnection();
}
- Connection connection = createConnectionFor(phone.getPhoneType(), originalConnection);
+ Connection connection = createConnectionFor(phone, originalConnection);
if (connection == null) {
connection = Connection.createCanceledConnection();
return Connection.createCanceledConnection();
@@ -248,11 +250,13 @@
}
private TelephonyConnection createConnectionFor(
- int phoneType, com.android.internal.telephony.Connection originalConnection) {
+ Phone phone, com.android.internal.telephony.Connection originalConnection) {
+ int phoneType = phone.getPhoneType();
if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
return new GsmConnection(originalConnection);
} else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
- return new CdmaConnection(originalConnection);
+ boolean allowMute = allowMute(phone);
+ return new CdmaConnection(originalConnection, allowMute);
} else {
return null;
}
@@ -289,4 +293,26 @@
}
return null;
}
+
+ /**
+ * Determines if the connection should allow mute.
+ *
+ * @param phone The current phone.
+ * @return {@code True} if the connection should allow mute.
+ */
+ private boolean allowMute(Phone phone) {
+ // For CDMA phones, check if we are in Emergency Callback Mode (ECM). Mute is disallowed
+ // in ECM mode.
+ if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
+ PhoneProxy phoneProxy = (PhoneProxy)phone;
+ CDMAPhone cdmaPhone = (CDMAPhone)phoneProxy.getActivePhone();
+ if (cdmaPhone != null) {
+ if (cdmaPhone.isInEcm()) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
}