summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2021-08-19 01:11:07 +0100
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-20 00:33:55 +0000
commit62458f4b73f6f5a1e1b6c0045932192486f93601 (patch)
treeaf1b036644a47518bc21d41f96c61b5b7c833eb4
parent64d22187430086f9e877c7a367ff686f7f718b1e (diff)
downloadbase-62458f4b73f6f5a1e1b6c0045932192486f93601.tar.gz
WaitForNegativeProximity stopped with power button.
If the device is in a state where it is waiting for negative proximity event to turn the screen back on (as with phone calls), this CL makes it so that power button will also turn the screen back on, even if proximity is still positive. Test: make phone call, cover prox, end call. Previously power button had no effect in this state, now it turns the screen back on. Bug: 190459207 Change-Id: I3ce33fe81e5ee0c0652517a8ce46632519ba73c6 (cherry picked from commit 325cf315e64e7698bee012737b64b3fc53473d23)
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java1
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java11
2 files changed, 10 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 110893765cbd..abbe13ac260f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -2122,7 +2122,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private void ignoreProximitySensorUntilChangedInternal() {
if (!mIgnoreProximityUntilChanged
- && mPowerRequest.useProximitySensor
&& mProximity == PROXIMITY_POSITIVE) {
// Only ignore if it is still reporting positive (near)
mIgnoreProximityUntilChanged = true;
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 9638255dfc79..2b0595492f8a 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -532,6 +532,11 @@ public final class PowerManagerService extends SystemService
// True if the proximity sensor reads a positive result.
private boolean mProximityPositive;
+ // Indicates that we have already intercepted the power key to temporarily ignore the proximity
+ // wake lock and turn the screen back on. This should get reset when prox reads 'far' again
+ // (when {@link #mProximityPositive} is set to false).
+ private boolean mInterceptedPowerKeyForProximity;
+
// Screen brightness setting limits.
public final float mScreenBrightnessMinimum;
public final float mScreenBrightnessMaximum;
@@ -3313,6 +3318,7 @@ public final class PowerManagerService extends SystemService
public void onProximityNegative() {
synchronized (mLock) {
mProximityPositive = false;
+ mInterceptedPowerKeyForProximity = false;
mDirty |= DIRTY_PROXIMITY_POSITIVE;
userActivityNoUpdateLocked(Display.DEFAULT_DISPLAY_GROUP, mClock.uptimeMillis(),
PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
@@ -4153,6 +4159,8 @@ public final class PowerManagerService extends SystemService
}
pw.println();
pw.println(" mRequestWaitForNegativeProximity=" + mRequestWaitForNegativeProximity);
+ pw.println(" mInterceptedPowerKeyForProximity="
+ + mInterceptedPowerKeyForProximity);
pw.println(" mSandmanScheduled=" + mSandmanScheduled);
pw.println(" mBatteryLevelLow=" + mBatteryLevelLow);
pw.println(" mLightDeviceIdleMode=" + mLightDeviceIdleMode);
@@ -5984,8 +5992,9 @@ public final class PowerManagerService extends SystemService
final DisplayPowerRequest displayPowerRequest =
mDisplayGroupPowerStateMapper.getPowerRequestLocked(
Display.DEFAULT_DISPLAY_GROUP);
- if (displayPowerRequest.useProximitySensor && mProximityPositive) {
+ if (mProximityPositive && !mInterceptedPowerKeyForProximity) {
mDisplayManagerInternal.ignoreProximitySensorUntilChanged();
+ mInterceptedPowerKeyForProximity = true;
return true;
}
}