From 2eb4796590e068b7089524f3a521cc2ecbe3f124 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Fri, 23 Oct 2009 11:29:52 -0400 Subject: [PATCH] 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 --- .../internal/policy/impl/PhoneWindowManager.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/com/android/internal/policy/impl/PhoneWindowManager.java index 135dc83e65776..df8b265917e47 100755 --- a/policy/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1682,17 +1682,19 @@ public class PhoneWindowManager implements WindowManagerPolicy { 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 @@ public class PhoneWindowManager implements WindowManagerPolicy { 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