From a1324f308b657113242ef574cbb050223b887fb8 Mon Sep 17 00:00:00 2001 From: raylinhsu Date: Fri, 22 Jan 2021 11:41:05 +0800 Subject: [PATCH] Fix ambient information which did not get for locking refresh rate Sometimes we will see that the display state is ON but the DeviceInteractive is false and then BrightnessObserver can not register the light sensor.Hence, it can not judge if the threshold meets the condition for blocking zones.This patch is for fixing this kind of case. Bug: 176962616 Test: atest DisplayModeDirectorTest Test: no fps transition in the blocking zone when the display state change Test: check if the lux will update when the display state change Change-Id: Idcfcbfa9e41bb9a34e4808db6fdd7f8a5901457b --- .../android/server/display/DisplayModeDirector.java | 13 +------------ .../server/display/DisplayModeDirectorTest.java | 5 ----- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayModeDirector.java b/services/core/java/com/android/server/display/DisplayModeDirector.java index cafa45bb4df5d..dce6bd849953f 100644 --- a/services/core/java/com/android/server/display/DisplayModeDirector.java +++ b/services/core/java/com/android/server/display/DisplayModeDirector.java @@ -1312,7 +1312,6 @@ public class DisplayModeDirector { // changeable and low power mode off. After initialization, these states will // be updated from the same handler thread. private int mDefaultDisplayState = Display.STATE_UNKNOWN; - private boolean mIsDeviceActive = false; private boolean mRefreshRateChangeable = false; private boolean mLowPowerModeEnabled = false; @@ -1502,7 +1501,6 @@ public class DisplayModeDirector { pw.println(" mAmbientLux: " + mAmbientLux); pw.println(" mBrightness: " + mBrightness); pw.println(" mDefaultDisplayState: " + mDefaultDisplayState); - pw.println(" mIsDeviceActive: " + mIsDeviceActive); pw.println(" mLowPowerModeEnabled: " + mLowPowerModeEnabled); pw.println(" mRefreshRateChangeable: " + mRefreshRateChangeable); pw.println(" mShouldObserveDisplayLowChange: " + mShouldObserveDisplayLowChange); @@ -1779,9 +1777,7 @@ public class DisplayModeDirector { } private boolean isDeviceActive() { - mIsDeviceActive = mInjector.isDeviceInteractive(mContext); - return (mDefaultDisplayState == Display.STATE_ON) - && mIsDeviceActive; + return mDefaultDisplayState == Display.STATE_ON; } private final class LightSensorEventListener implements SensorEventListener { @@ -2055,8 +2051,6 @@ public class DisplayModeDirector { void registerPeakRefreshRateObserver(@NonNull ContentResolver cr, @NonNull ContentObserver observer); - - boolean isDeviceInteractive(@NonNull Context context); } @VisibleForTesting @@ -2087,11 +2081,6 @@ public class DisplayModeDirector { cr.registerContentObserver(PEAK_REFRESH_RATE_URI, false /*notifyDescendants*/, observer, UserHandle.USER_SYSTEM); } - - @Override - public boolean isDeviceInteractive(@NonNull Context ctx) { - return ctx.getSystemService(PowerManager.class).isInteractive(); - } } } diff --git a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java index 26c304f763d62..2e3178b138929 100644 --- a/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java +++ b/services/tests/servicestests/src/com/android/server/display/DisplayModeDirectorTest.java @@ -818,10 +818,5 @@ public class DisplayModeDirectorTest { PEAK_REFRESH_RATE_URI); } } - - @Override - public boolean isDeviceInteractive(@NonNull Context context) { - return true; - } } }