am ec7dab76: am 146ef723: When phone is ringing, power button should hang up phone in addition to turning off the screen.

Merge commit 'ec7dab76d41f07d88fc3e8932c430ef7d50fb5a7' into eclair-mr2-plus-aosp

* commit 'ec7dab76d41f07d88fc3e8932c430ef7d50fb5a7':
  When phone is ringing, power button should hang up phone in addition to turning off the screen.
This commit is contained in:
Mike Lockwood
2009-10-29 18:19:53 -07:00
committed by Android Git Automerger

View File

@@ -1686,19 +1686,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// 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.
if (code == KeyEvent.KEYCODE_ENDCALL) {
ITelephony phoneServ = getPhoneInterface();
if (phoneServ != null) {
try {
ITelephony phoneServ = getPhoneInterface();
if (phoneServ != null) {
// 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();
} else {
Log.w(TAG, "!!! Unable to find ITelephony interface !!!");
}
} catch (RemoteException ex) {
Log.w(TAG, "ITelephony.endCall() threw RemoteException" + ex);
Log.w(TAG, "ITelephony threw RemoteException" + ex);
}
} else {
Log.w(TAG, "!!! Unable to find ITelephony interface !!!");
}
if (hungUp || !screenIsOn) {
// power button should turn off screen in addition to hanging up the phone
if ((hungUp && code != KeyEvent.KEYCODE_POWER) || !screenIsOn) {
mShouldTurnOffOnKeyUp = false;
} else {
// only try to turn off the screen if we didn't already hang up