diff options
author | David Brown <dab@google.com> | 2010-03-08 21:52:59 -0800 |
---|---|---|
committer | David Brown <dab@google.com> | 2010-03-11 15:27:09 -0800 |
commit | 4c938f402663bcdbadc08af91afdd9e96eac7e42 (patch) | |
tree | ef4b04dbdb29958f795f663edf9dd7fa6270f653 | |
parent | 67accfd37face47d46d770aa3b7b6458b1e44a74 (diff) | |
download | base-4c938f402663bcdbadc08af91afdd9e96eac7e42.tar.gz |
Accessibility: optionally allow Power key to end the current call.
This is part 2 of the fix for bug 2364220 "Accessibility improvements for
ending calls".
This change updates the POWER key logic in interceptKeyTq() to check the
value of Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, which allows the
user to specify that the Power button should hang up while in-call,
instead of just turning off the screen.
Bug: 2364220
Change-Id: If6d8e3155f7d60142ab6fd61f0a9db7f0b0d95ab
-rwxr-xr-x | phone/com/android/internal/policy/impl/PhoneWindowManager.java | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/phone/com/android/internal/policy/impl/PhoneWindowManager.java b/phone/com/android/internal/policy/impl/PhoneWindowManager.java index 0699701..f750f23 100755 --- a/phone/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/phone/com/android/internal/policy/impl/PhoneWindowManager.java @@ -260,11 +260,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mLockScreenTimeout; boolean mLockScreenTimerActive; - static final int ENDCALL_HOME = 0x1; - static final int ENDCALL_SLEEPS = 0x2; - static final int DEFAULT_ENDCALL_BEHAVIOR = ENDCALL_SLEEPS; + // Behavior of ENDCALL Button. (See Settings.System.END_BUTTON_BEHAVIOR.) int mEndcallBehavior; - + + // Behavior of POWER button while in-call and screen on. + // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) + int mIncallPowerBehavior; + int mLandscapeRotation = -1; int mPortraitRotation = -1; @@ -278,11 +280,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { SettingsObserver(Handler handler) { super(handler); } - + void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.END_BUTTON_BEHAVIOR), false, this); + resolver.registerContentObserver(Settings.Secure.getUriFor( + Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.ACCELEROMETER_ROTATION), false, this); resolver.registerContentObserver(Settings.System.getUriFor( @@ -548,7 +552,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { View removeView = null; synchronized (mLock) { mEndcallBehavior = Settings.System.getInt(resolver, - Settings.System.END_BUTTON_BEHAVIOR, DEFAULT_ENDCALL_BEHAVIOR); + Settings.System.END_BUTTON_BEHAVIOR, + Settings.System.END_BUTTON_BEHAVIOR_DEFAULT); + mIncallPowerBehavior = Settings.Secure.getInt(resolver, + Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, + Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT); mFancyRotationAnimation = Settings.System.getInt(resolver, "fancy_rotation_anim", 0) != 0 ? 0x80 : 0; int accelerometerDefault = Settings.System.getInt(resolver, @@ -1797,6 +1805,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { || code == KeyEvent.KEYCODE_POWER) { if (down) { boolean handled = false; + boolean hungUp = 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. @@ -1804,11 +1813,21 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (phoneServ != null) { try { 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; + handled = hungUp = phoneServ.endCall(); + } else if (code == KeyEvent.KEYCODE_POWER) { + if (phoneServ.isRinging()) { + // Pressing Power while there's a ringing incoming + // call should silence the ringer. + phoneServ.silenceRinger(); + handled = true; + } else if (phoneServ.isOffhook() && + ((mIncallPowerBehavior + & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) + != 0)) { + // Otherwise, if "Power button ends call" is enabled, + // the Power button will hang up any current active call. + handled = hungUp = phoneServ.endCall(); + } } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException" + ex); @@ -1816,8 +1835,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else { Log.w(TAG, "!!! Unable to find ITelephony interface !!!"); } - // power button should turn off screen in addition to hanging up the phone - if ((handled && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) { + + if (!screenIsOn + || (handled && code != KeyEvent.KEYCODE_POWER) + || (handled && hungUp && code == KeyEvent.KEYCODE_POWER)) { mShouldTurnOffOnKeyUp = false; } else { // only try to turn off the screen if we didn't already hang up @@ -1832,8 +1853,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { mShouldTurnOffOnKeyUp = false; boolean gohome, sleeps; if (code == KeyEvent.KEYCODE_ENDCALL) { - gohome = (mEndcallBehavior & ENDCALL_HOME) != 0; - sleeps = (mEndcallBehavior & ENDCALL_SLEEPS) != 0; + gohome = (mEndcallBehavior + & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0; + sleeps = (mEndcallBehavior + & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0; } else { gohome = false; sleeps = true; @@ -2374,4 +2397,3 @@ public class PhoneWindowManager implements WindowManagerPolicy { return mScreenOn; } } - |