Loading services/core/java/com/android/server/power/PowerManagerService.java +13 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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:"); Loading Loading @@ -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 Loading services/core/java/com/android/server/power/PowerManagerShellCommand.java +18 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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(); Loading @@ -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 , ""); Loading Loading
services/core/java/com/android/server/power/PowerManagerService.java +13 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading Loading @@ -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:"); Loading Loading @@ -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 Loading
services/core/java/com/android/server/power/PowerManagerShellCommand.java +18 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading Loading @@ -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(); Loading @@ -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 , ""); Loading