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

Commit 7b6b5942 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Add screenshot for LogSystem."

parents 7e67d6fb b62172b8
Loading
Loading
Loading
Loading
+51 −1
Original line number Diff line number Diff line
@@ -459,6 +459,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private boolean mVolumeDownKeyConsumedByScreenshotChord;
    private boolean mVolumeUpKeyTriggered;
    private boolean mPowerKeyTriggered;
    private long mVolumeUpKeyTime;
    private boolean mVolumeUpKeyConsumedByScreenshotChord;
    private long mPowerKeyTime;

    /* The number of steps between min and max brightness */
@@ -707,6 +709,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    private void interceptScreenshotLog() {
        if (mScreenshotChordEnabled
                && mVolumeUpKeyTriggered && mPowerKeyTriggered && !mVolumeDownKeyTriggered) {
            final long now = SystemClock.uptimeMillis();
            if (now <= mVolumeUpKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS
                   && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) {
                mVolumeUpKeyConsumedByScreenshotChord = true;
                cancelPendingScreenshotForLog();

                mHandler.postDelayed(mScreenshotForLog, getScreenshotChordLongPressDelay());
            }
        }
    }

    private void cancelPendingScreenshotForLog() {
        mHandler.removeCallbacks(mScreenshotForLog);
    }

    private long getScreenshotChordLongPressDelay() {
        if (mKeyguardDelegate.isShowing()) {
            // Double the time it takes to take a screenshot from the keyguard
@@ -762,6 +782,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    };

    private final Runnable mScreenshotForLog = new Runnable() {
        public void run() {
            Intent intent = new Intent();
            intent.setAction("android.system.agent");
            intent.putExtra("para", "takeLogs");
            try {
                mContext.startService(intent);
            } catch (Exception e) {
                Slog.e(TAG, "Exception when start SystemAgent service", e);
            }
        }
    };

    void showGlobalActionsDialog() {
        if (mGlobalActions == null) {
            mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs);
@@ -2011,6 +2044,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
                return -1;
            }
            if (mVolumeUpKeyTriggered && !mPowerKeyTriggered) {
                final long now = SystemClock.uptimeMillis();
                final long timeoutTime = mVolumeUpKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS;
                if (now < timeoutTime) {
                    return timeoutTime - now;
                }
            }
            if (keyCode == KeyEvent.KEYCODE_VOLUME_UP
                    && mVolumeUpKeyConsumedByScreenshotChord) {
                if (!down) {
                    mVolumeUpKeyConsumedByScreenshotChord = false;
                }
                return -1;
            }
        }

        // First we always handle the home key here, so applications
@@ -3916,8 +3963,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        if (isScreenOn && !mVolumeUpKeyTriggered
                                && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) {
                            mVolumeUpKeyTriggered = true;
                            mVolumeUpKeyTime = event.getDownTime();
                            mVolumeUpKeyConsumedByScreenshotChord = false;
                            cancelPendingPowerKeyAction();
                            cancelPendingScreenshotChordAction();
                            interceptScreenshotLog();
                        }
                    } else {
                        mVolumeUpKeyTriggered = false;
@@ -4009,6 +4058,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        mPowerKeyTriggered = true;
                        mPowerKeyTime = event.getDownTime();
                        interceptScreenshotChord();
                        interceptScreenshotLog();

                        if (mButtonLightEnabled) {
                            try {