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

Commit 216575b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ignore face down detector with shell command" into 24D1-dev

parents afa97d34 0f0e5512
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -616,6 +616,7 @@ public final class PowerManagerService extends SystemService

    // Value we store for tracking face down behavior.
    private boolean mIsFaceDown = false;
    private boolean mUseFaceDownDetector = true;
    private long mLastFlipTime = 0L;

    // The screen brightness setting override from the window manager
@@ -3198,7 +3199,7 @@ public final class PowerManagerService extends SystemService
            long screenOffTimeout, long screenDimDuration) {
        // If face down, we decrease the timeout to equal the dim duration so that the
        // device will go into a dim state.
        if (mIsFaceDown) {
        if (mIsFaceDown && mUseFaceDownDetector) {
            return Math.min(screenDimDuration, screenOffTimeout);
        }
        return screenOffTimeout;
@@ -4643,6 +4644,7 @@ public final class PowerManagerService extends SystemService
            pw.println("  mHoldingDisplaySuspendBlocker=" + mHoldingDisplaySuspendBlocker);
            pw.println("  mLastFlipTime=" + mLastFlipTime);
            pw.println("  mIsFaceDown=" + mIsFaceDown);
            pw.println("  mUseFaceDownDetector=" + mUseFaceDownDetector);

            pw.println();
            pw.println("Settings and Configuration:");
@@ -6840,6 +6842,16 @@ public final class PowerManagerService extends SystemService
                Binder.restoreCallingIdentity(ident);
            }
        }

        public void setUseFaceDownDetector(boolean enable) {
            final long ident = Binder.clearCallingIdentity();
            try {
                mUseFaceDownDetector = enable;
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        }

    }

    @VisibleForTesting
+18 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ class PowerManagerShellCommand extends ShellCommand {
                    return runListAmbientDisplaySuppressionTokens();
                case "set-prox":
                    return runSetProx();
                case "set-face-down-detector":
                    return runSetFaceDownDetector();
                default:
                    return handleDefaultCommands(cmd);
            }
@@ -178,6 +180,20 @@ class PowerManagerShellCommand extends ShellCommand {
        return 0;
    }

    /**
     * To be used for testing - allowing us to disable the usage of face down detector.
     */
    private int runSetFaceDownDetector() {
        try {
            mService.setUseFaceDownDetector(Boolean.parseBoolean(getNextArgRequired()));
        } catch (Exception e) {
            PrintWriter pw = getOutPrintWriter();
            pw.println("Error: " + e);
            return -1;
        }
        return 0;
    }

    @Override
    public void onHelp() {
        final PrintWriter pw = getOutPrintWriter();
@@ -203,6 +219,8 @@ class PowerManagerShellCommand extends ShellCommand {
        pw.println("    Acquires the proximity sensor wakelock. Wakelock is associated with");
        pw.println("    a specific display if specified. 'list' lists wakelocks previously");
        pw.println("    created by set-prox including their held status.");
        pw.println("  set-face-down-detector [true|false]");
        pw.println("    sets whether we use face down detector timeouts or not");

        pw.println();
        Intent.printIntentArgsHelp(pw , "");