When phone is ringing, power button should only mute the ringer, not hang up.
Fixes my previous fix for bug b/2201585 (Pressing power button when phone ringing should mute ringer)
Change-Id: I9460e21245b9719f715818f7ad878b121857d773
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/phone/com/android/internal/policy/impl/PhoneWindowManager.java b/phone/com/android/internal/policy/impl/PhoneWindowManager.java
index 135dc83..df8b265 100755
--- a/phone/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/phone/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1682,17 +1682,19 @@
if (code == KeyEvent.KEYCODE_ENDCALL
|| code == KeyEvent.KEYCODE_POWER) {
if (down) {
- boolean hungUp = false;
+ boolean handled = false;
// key repeats are generated by the window manager, and we don't see them
// here, so unless the driver is doing something it shouldn't be, we know
// this is the real press event.
ITelephony phoneServ = getPhoneInterface();
if (phoneServ != null) {
try {
- // power button should hang up only when ringing
- // but not after the call has been answered
- if (code == KeyEvent.KEYCODE_ENDCALL || phoneServ.isRinging()) {
- hungUp = phoneServ.endCall();
+ if (code == KeyEvent.KEYCODE_ENDCALL) {
+ handled = phoneServ.endCall();
+ } else if (code == KeyEvent.KEYCODE_POWER && phoneServ.isRinging()) {
+ // Pressing power during incoming call should silence the ringer
+ phoneServ.silenceRinger();
+ handled = true;
}
} catch (RemoteException ex) {
Log.w(TAG, "ITelephony threw RemoteException" + ex);
@@ -1701,7 +1703,7 @@
Log.w(TAG, "!!! Unable to find ITelephony interface !!!");
}
// power button should turn off screen in addition to hanging up the phone
- if ((hungUp && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) {
+ if ((handled && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) {
mShouldTurnOffOnKeyUp = false;
} else {
// only try to turn off the screen if we didn't already hang up