Support telecom related operations for watch back button usage.

This change allows for the back button to hang up or silence calls when
set through accessibility.

Bug: 30039247
Change-Id: Iff0e67180e1180c9bb8b27df023d7a7a64783543
This commit is contained in:
Bryce Lee
2016-09-03 15:02:00 -07:00
parent f816ac2fa9
commit db776ce7f9
2 changed files with 63 additions and 1 deletions

View File

@@ -5923,6 +5923,36 @@ public final class Settings {
public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
/**
* What happens when the user presses the Back button while in-call
* and the screen is on.<br/>
* <b>Values:</b><br/>
* 0 - The Back buttons does nothing different.<br/>
* 1 - The Back button hangs up the current call.<br/>
*
* @hide
*/
public static final String INCALL_BACK_BUTTON_BEHAVIOR = "incall_back_button_behavior";
/**
* INCALL_BACK_BUTTON_BEHAVIOR value for no action.
* @hide
*/
public static final int INCALL_BACK_BUTTON_BEHAVIOR_NONE = 0x0;
/**
* INCALL_BACK_BUTTON_BEHAVIOR value for "hang up".
* @hide
*/
public static final int INCALL_BACK_BUTTON_BEHAVIOR_HANGUP = 0x1;
/**
* INCALL_POWER_BUTTON_BEHAVIOR default value.
* @hide
*/
public static final int INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT =
INCALL_BACK_BUTTON_BEHAVIOR_NONE;
/**
* Whether the device should wake when the wake gesture sensor detects motion.
* @hide

View File

@@ -647,6 +647,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.)
int mIncallPowerBehavior;
// Behavior of Back button while in-call and screen on
int mIncallBackBehavior;
Display mDisplay;
private int mDisplayRotation;
@@ -837,6 +840,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR), false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.Secure.getUriFor(
Settings.Secure.WAKE_GESTURE_ENABLED), false, this,
UserHandle.USER_ALL);
@@ -1060,7 +1066,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
// This could be a multi-press. Wait a little bit longer to confirm.
Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS,
mBackKeyPressCounter, 0, eventTime);
mBackKeyPressCounter, 0, eventTime);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.getMultiPressTimeout());
}
@@ -1069,6 +1075,27 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Reset back long press state
cancelPendingBackKeyAction();
if (mHasFeatureWatch) {
TelecomManager telecomManager = getTelecommService();
if (telecomManager != null) {
if (telecomManager.isRinging()) {
// Pressing back while there's a ringing incoming
// call should silence the ringer.
telecomManager.silenceRinger();
// It should not prevent navigating away
return false;
} else if (
(mIncallBackBehavior & Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_HANGUP) != 0
&& telecomManager.isInCall()) {
// Otherwise, if "Back button ends call" is enabled,
// the Back button will hang up any current active call.
return telecomManager.endCall();
}
}
}
return handled;
}
@@ -2020,6 +2047,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT,
UserHandle.USER_CURRENT);
mIncallBackBehavior = Settings.Secure.getIntForUser(resolver,
Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR,
Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT,
UserHandle.USER_CURRENT);
// Configure wake gesture.
boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver,
@@ -8040,6 +8071,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive);
pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior);
pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior);
pw.print(" mIncallBackBehavior="); pw.print(mIncallBackBehavior);
pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior);
pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation);
pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation);