Add a flag to change the screenshot keychord delay

Allows overriding the configured keychord delay (the time it takes,
after both the power button and volume down have been pressed, for
a screenshot to be registered/taken). If not set, reads from the
config file (as before). Can be updated with

adb shell device_config put systemui screenshot_keychord_delay <n>

where <n> is the desired timeout, in ms.

Bug: 165267251
Test: manual -- tried setting multiple values, ensured that deleting
the override reverts to the configured value

Change-Id: I2f86abe0332f8072ab4f53baa55f1999aed3865a
This commit is contained in:
Miranda Kephart
2020-08-21 12:02:40 -04:00
parent 82968c5f2d
commit 6e44e9d5b4
2 changed files with 12 additions and 3 deletions

View File

@@ -409,6 +409,11 @@ public final class SystemUiDeviceConfigFlags {
*/
public static final String BACK_GESTURE_SLOP_MULTIPLIER = "back_gesture_slop_multiplier";
/**
* (long) Screenshot keychord delay (how long the buttons must be pressed), in ms
*/
public static final String SCREENSHOT_KEYCHORD_DELAY = "screenshot_keychord_delay";
private SystemUiDeviceConfigFlags() {
}
}

View File

@@ -69,6 +69,7 @@ import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.SCREENSHOT_KEYCHORD_DELAY;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT;
import static com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED;
@@ -148,6 +149,7 @@ import android.os.UEventObserver;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.provider.MediaStore;
import android.provider.Settings;
import android.service.dreams.DreamManagerInternal;
@@ -1378,12 +1380,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
private long getScreenshotChordLongPressDelay() {
long delayMs = DeviceConfig.getLong(
DeviceConfig.NAMESPACE_SYSTEMUI, SCREENSHOT_KEYCHORD_DELAY,
ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout());
if (mKeyguardDelegate.isShowing()) {
// Double the time it takes to take a screenshot from the keyguard
return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER *
ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout());
return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * delayMs);
}
return ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout();
return delayMs;
}
private long getRingerToggleChordDelay() {