diff options
author | Tyler Gunn <tgunn@google.com> | 2014-08-27 20:37:32 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-08-27 20:37:32 -0700 |
commit | 625eb0b8f6e52e7ac1b5a499c5e1964812911913 (patch) | |
tree | fee24b110c9e669a781bfa1fd17e47ee22f5ed11 | |
parent | 297d540b8f2294245f4ecc69a9c2dc9a02b689ea (diff) | |
download | android_packages_services_Telephony-625eb0b8f6e52e7ac1b5a499c5e1964812911913.tar.gz android_packages_services_Telephony-625eb0b8f6e52e7ac1b5a499c5e1964812911913.tar.bz2 android_packages_services_Telephony-625eb0b8f6e52e7ac1b5a499c5e1964812911913.zip |
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
26 files changed, 55 insertions, 19 deletions
diff --git a/res/drawable-hdpi/ic_emergency_callback_mode.png b/res/drawable-hdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..1902e721b --- /dev/null +++ b/res/drawable-hdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-hdpi/picture_emergency25x25.png b/res/drawable-hdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index 0a6d3c41e..000000000 --- a/res/drawable-hdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-hdpi/picture_emergency32x32.png b/res/drawable-hdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index 89c05e360..000000000 --- a/res/drawable-hdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..0c796b515 --- /dev/null +++ b/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-ldrtl-hdpi/picture_emergency25x25.png b/res/drawable-ldrtl-hdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index 9a70b6d81..000000000 --- a/res/drawable-ldrtl-hdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-ldrtl-hdpi/picture_emergency32x32.png b/res/drawable-ldrtl-hdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index 89e1b07b3..000000000 --- a/res/drawable-ldrtl-hdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..150731068 --- /dev/null +++ b/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-ldrtl-mdpi/picture_emergency25x25.png b/res/drawable-ldrtl-mdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index 9a70b6d81..000000000 --- a/res/drawable-ldrtl-mdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-ldrtl-mdpi/picture_emergency32x32.png b/res/drawable-ldrtl-mdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index 89e1b07b3..000000000 --- a/res/drawable-ldrtl-mdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..7c2f9f141 --- /dev/null +++ b/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png b/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index e4b93426b..000000000 --- a/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png b/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index ddc2642a6..000000000 --- a/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..c08186b90 --- /dev/null +++ b/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..9487cf4b4 --- /dev/null +++ b/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-mdpi/ic_emergency_callback_mode.png b/res/drawable-mdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..d4e5f5d7d --- /dev/null +++ b/res/drawable-mdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-mdpi/picture_emergency25x25.png b/res/drawable-mdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index 0a6d3c41e..000000000 --- a/res/drawable-mdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-mdpi/picture_emergency32x32.png b/res/drawable-mdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index 89c05e360..000000000 --- a/res/drawable-mdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-xhdpi/ic_emergency_callback_mode.png b/res/drawable-xhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..cde9cea3a --- /dev/null +++ b/res/drawable-xhdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-xhdpi/picture_emergency25x25.png b/res/drawable-xhdpi/picture_emergency25x25.png Binary files differdeleted file mode 100644 index 1284dcc37..000000000 --- a/res/drawable-xhdpi/picture_emergency25x25.png +++ /dev/null diff --git a/res/drawable-xhdpi/picture_emergency32x32.png b/res/drawable-xhdpi/picture_emergency32x32.png Binary files differdeleted file mode 100644 index 75fdec2b6..000000000 --- a/res/drawable-xhdpi/picture_emergency32x32.png +++ /dev/null diff --git a/res/drawable-xxhdpi/ic_emergency_callback_mode.png b/res/drawable-xxhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..b761bc466 --- /dev/null +++ b/res/drawable-xxhdpi/ic_emergency_callback_mode.png diff --git a/res/drawable-xxxhdpi/ic_emergency_callback_mode.png b/res/drawable-xxxhdpi/ic_emergency_callback_mode.png Binary files differnew file mode 100644 index 000000000..0e71cf0d3 --- /dev/null +++ b/res/drawable-xxxhdpi/ic_emergency_callback_mode.png diff --git a/src/com/android/phone/EmergencyCallbackModeExitDialog.java b/src/com/android/phone/EmergencyCallbackModeExitDialog.java index 7758b23be..921b7f780 100644 --- a/src/com/android/phone/EmergencyCallbackModeExitDialog.java +++ b/src/com/android/phone/EmergencyCallbackModeExitDialog.java @@ -205,7 +205,7 @@ public class EmergencyCallbackModeExitDialog extends Activity implements OnDismi 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 @@ public class EmergencyCallbackModeExitDialog extends Activity implements OnDismi 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 5309eafe4..e1f7fb34d 100644 --- a/src/com/android/phone/EmergencyCallbackModeService.java +++ b/src/com/android/phone/EmergencyCallbackModeService.java @@ -25,6 +25,7 @@ import android.content.Context; 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 @@ public class EmergencyCallbackModeService extends Service { * 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 @@ public class EmergencyCallbackModeService extends Service { 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 f13676a11..67104b59f 100644 --- a/src/com/android/services/telephony/CdmaConnection.java +++ b/src/com/android/services/telephony/CdmaConnection.java @@ -24,8 +24,15 @@ import com.android.internal.telephony.Connection; * 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 @@ final class CdmaConnection extends TelephonyConnection { @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 7c4d1ae9d..851269dfd 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.CallStateException; 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 @@ public class TelephonyConnectionService extends ConnectionService { } } - 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 @@ public class TelephonyConnectionService extends ConnectionService { 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 @@ public class TelephonyConnectionService extends ConnectionService { } 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 @@ public class TelephonyConnectionService extends ConnectionService { } 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; + } } |