Add control for double tap to wake setting
Bug: 16875464 Change-Id: Ic1ad910dd38acbc68ef040b2acdf3696ec2c2e4e
This commit is contained in:
@@ -5516,6 +5516,12 @@ public final class Settings {
|
||||
*/
|
||||
public static final String APP_IDLE_DURATION = "app_idle_duration";
|
||||
|
||||
/**
|
||||
* Controls whether double tap to wake is enabled.
|
||||
* @hide
|
||||
*/
|
||||
public static final String DOUBLE_TAP_TO_WAKE = "double_tap_to_wake";
|
||||
|
||||
/**
|
||||
* This are the settings to be backed up.
|
||||
*
|
||||
@@ -5571,7 +5577,8 @@ public final class Settings {
|
||||
MOUNT_UMS_PROMPT,
|
||||
MOUNT_UMS_NOTIFY_ENABLED,
|
||||
UI_NIGHT_MODE,
|
||||
SLEEP_TIMEOUT
|
||||
SLEEP_TIMEOUT,
|
||||
DOUBLE_TAP_TO_WAKE,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2141,4 +2141,7 @@
|
||||
|
||||
<!-- This config is ued to determine whether animations are allowed in low power mode. -->
|
||||
<bool name="config_allowAnimationsInLowPowerMode">false</bool>
|
||||
|
||||
<!-- Whether device supports double tap to wake -->
|
||||
<bool name="config_supportDoubleTapWake">false</bool>
|
||||
</resources>
|
||||
|
||||
@@ -2261,4 +2261,5 @@
|
||||
<java-symbol type="layout" name="chooser_row" />
|
||||
<java-symbol type="color" name="chooser_service_row_background_color" />
|
||||
<java-symbol type="id" name="target_badge" />
|
||||
<java-symbol type="bool" name="config_supportDoubleTapWake" />
|
||||
</resources>
|
||||
|
||||
@@ -207,4 +207,7 @@
|
||||
<!-- Default for Settings.Global.GUEST_USER_ENABLED -->
|
||||
<bool name="def_guest_user_enabled">true</bool>
|
||||
|
||||
<!-- Default state of tap to wake -->
|
||||
<bool name="def_double_tap_to_wake">true</bool>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1791,7 +1791,7 @@ public class SettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
private final class UpgradeController {
|
||||
private static final int SETTINGS_VERSION = 119;
|
||||
private static final int SETTINGS_VERSION = 120;
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
@@ -1908,6 +1908,17 @@ public class SettingsProvider extends ContentProvider {
|
||||
currentVersion = 119;
|
||||
}
|
||||
|
||||
// v120: Add double tap to wake setting.
|
||||
if (currentVersion == 119) {
|
||||
SettingsState secureSettings = getSecureSettingsLocked(userId);
|
||||
secureSettings.insertSettingLocked(Settings.Secure.DOUBLE_TAP_TO_WAKE,
|
||||
getContext().getResources().getBoolean(
|
||||
R.bool.def_double_tap_to_wake) ? "1" : "0",
|
||||
SettingsState.SYSTEM_PACKAGE_NAME);
|
||||
|
||||
currentVersion = 120;
|
||||
}
|
||||
|
||||
// vXXX: Add new settings above this point.
|
||||
|
||||
// Return the current version.
|
||||
|
||||
@@ -150,6 +150,12 @@ public final class PowerManagerService extends SystemService
|
||||
private static final int POWER_HINT_INTERACTION = 2;
|
||||
private static final int POWER_HINT_LOW_POWER = 5;
|
||||
|
||||
// Power features defined in hardware/libhardware/include/hardware/power.h.
|
||||
private static final int POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 1;
|
||||
|
||||
// Default setting for double tap to wake.
|
||||
private static final int DEFAULT_DOUBLE_TAP_TO_WAKE = 0;
|
||||
|
||||
private final Context mContext;
|
||||
private final ServiceThread mHandlerThread;
|
||||
private final PowerManagerHandler mHandler;
|
||||
@@ -339,6 +345,9 @@ public final class PowerManagerService extends SystemService
|
||||
// Otherwise the user won't get much screen on time before dimming occurs.
|
||||
private float mMaximumScreenDimRatioConfig;
|
||||
|
||||
// Whether device supports double tap to wake.
|
||||
private boolean mSupportsDoubleTapWakeConfig;
|
||||
|
||||
// The screen off timeout setting value in milliseconds.
|
||||
private int mScreenOffTimeoutSetting;
|
||||
|
||||
@@ -430,6 +439,9 @@ public final class PowerManagerService extends SystemService
|
||||
// True if theater mode is enabled
|
||||
private boolean mTheaterModeEnabled;
|
||||
|
||||
// True if double tap to wake is enabled
|
||||
private boolean mDoubleTapWakeEnabled;
|
||||
|
||||
private final ArrayList<PowerManagerInternal.LowPowerModeListener> mLowPowerModeListeners
|
||||
= new ArrayList<PowerManagerInternal.LowPowerModeListener>();
|
||||
|
||||
@@ -440,6 +452,7 @@ public final class PowerManagerService extends SystemService
|
||||
private static native void nativeSetInteractive(boolean enable);
|
||||
private static native void nativeSetAutoSuspend(boolean enable);
|
||||
private static native void nativeSendPowerHint(int hintId, int data);
|
||||
private static native void nativeSetFeature(int featureId, int data);
|
||||
|
||||
public PowerManagerService(Context context) {
|
||||
super(context);
|
||||
@@ -462,6 +475,7 @@ public final class PowerManagerService extends SystemService
|
||||
nativeInit();
|
||||
nativeSetAutoSuspend(false);
|
||||
nativeSetInteractive(true);
|
||||
nativeSetFeature(POWER_FEATURE_DOUBLE_TAP_TO_WAKE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,6 +594,9 @@ public final class PowerManagerService extends SystemService
|
||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||
Settings.Global.THEATER_MODE_ON),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.DOUBLE_TAP_TO_WAKE),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
// Go.
|
||||
readConfigurationLocked();
|
||||
updateSettingsLocked();
|
||||
@@ -625,6 +642,8 @@ public final class PowerManagerService extends SystemService
|
||||
com.android.internal.R.integer.config_maximumScreenDimDuration);
|
||||
mMaximumScreenDimRatioConfig = resources.getFraction(
|
||||
com.android.internal.R.fraction.config_maximumScreenDimRatio, 1, 1);
|
||||
mSupportsDoubleTapWakeConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_supportDoubleTapWake);
|
||||
}
|
||||
|
||||
private void updateSettingsLocked() {
|
||||
@@ -653,6 +672,16 @@ public final class PowerManagerService extends SystemService
|
||||
mTheaterModeEnabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.THEATER_MODE_ON, 0) == 1;
|
||||
|
||||
if (mSupportsDoubleTapWakeConfig) {
|
||||
boolean doubleTapWakeEnabled = Settings.Secure.getIntForUser(resolver,
|
||||
Settings.Secure.DOUBLE_TAP_TO_WAKE, DEFAULT_DOUBLE_TAP_TO_WAKE,
|
||||
UserHandle.USER_CURRENT) != 0;
|
||||
if (doubleTapWakeEnabled != mDoubleTapWakeEnabled) {
|
||||
mDoubleTapWakeEnabled = doubleTapWakeEnabled;
|
||||
nativeSetFeature(POWER_FEATURE_DOUBLE_TAP_TO_WAKE, mDoubleTapWakeEnabled ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
final int oldScreenBrightnessSetting = mScreenBrightnessSetting;
|
||||
mScreenBrightnessSetting = Settings.System.getIntForUser(resolver,
|
||||
Settings.System.SCREEN_BRIGHTNESS, mScreenBrightnessSettingDefault,
|
||||
@@ -2610,6 +2639,7 @@ public final class PowerManagerService extends SystemService
|
||||
pw.println(" mScreenBrightnessSettingMinimum=" + mScreenBrightnessSettingMinimum);
|
||||
pw.println(" mScreenBrightnessSettingMaximum=" + mScreenBrightnessSettingMaximum);
|
||||
pw.println(" mScreenBrightnessSettingDefault=" + mScreenBrightnessSettingDefault);
|
||||
pw.println(" mDoubleTapWakeEnabled=" + mDoubleTapWakeEnabled);
|
||||
|
||||
final int sleepTimeout = getSleepTimeoutLocked();
|
||||
final int screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout);
|
||||
|
||||
@@ -156,6 +156,14 @@ static void nativeSendPowerHint(JNIEnv *env, jclass clazz, jint hintId, jint dat
|
||||
}
|
||||
}
|
||||
|
||||
static void nativeSetFeature(JNIEnv *env, jclass clazz, jint featureId, jint data) {
|
||||
int data_param = data;
|
||||
|
||||
if (gPowerModule && gPowerModule->setFeature) {
|
||||
gPowerModule->setFeature(gPowerModule, (feature_t)featureId, data_param);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static JNINativeMethod gPowerManagerServiceMethods[] = {
|
||||
@@ -172,6 +180,8 @@ static JNINativeMethod gPowerManagerServiceMethods[] = {
|
||||
(void*) nativeSetAutoSuspend },
|
||||
{ "nativeSendPowerHint", "(II)V",
|
||||
(void*) nativeSendPowerHint },
|
||||
{ "nativeSetFeature", "(II)V",
|
||||
(void*) nativeSetFeature },
|
||||
};
|
||||
|
||||
#define FIND_CLASS(var, className) \
|
||||
|
||||
Reference in New Issue
Block a user