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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user