Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62ec88d0 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Add a config resource to disable key-chord screenshotting" into ics-aah

parents fe2d34a8 77dff41d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -308,6 +308,9 @@
    <!-- If this is true, the screen will fade off. -->
    <bool name="config_animateScreenLights">true</bool>

    <!-- If this is true, key chords can be used to take a screenshot on the device. -->
    <bool name="config_enableScreenshotChord">true</bool>

    <!-- If true, the screen can be rotated via the accelerometer in all 4
         rotations as the default behavior. -->
    <bool name="config_allowAllRotations">false</bool>
+7 −2
Original line number Diff line number Diff line
@@ -445,6 +445,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // Screenshot trigger states
    // Time to volume and power must be pressed within this interval of each other.
    private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150;
    private boolean mScreenshotChordEnabled;
    private boolean mVolumeDownKeyTriggered;
    private long mVolumeDownKeyTime;
    private boolean mVolumeDownKeyConsumedByScreenshotChord;
@@ -612,7 +613,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private void interceptScreenshotChord() {
        if (mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) {
        if (mScreenshotChordEnabled
                && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) {
            final long now = SystemClock.uptimeMillis();
            if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS
                    && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) {
@@ -835,6 +837,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(),
                com.android.internal.R.array.config_safeModeEnabledVibePattern);

        mScreenshotChordEnabled = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_enableScreenshotChord);

        // Controls rotation and the like.
        initializeHdmiState();

@@ -1506,7 +1511,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // If we think we might have a volume down & power key chord on the way
        // but we're not sure, then tell the dispatcher to wait a little while and
        // try again later before dispatching.
        if ((flags & KeyEvent.FLAG_FALLBACK) == 0) {
        if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) {
            if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) {
                final long now = SystemClock.uptimeMillis();
                final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS;