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: 176018998
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
Merged-In: Idcfcbfa9e41bb9a34e4808db6fdd7f8a5901457b
This commit is contained in:
raylinhsu
2021-01-22 11:41:05 +08:00
committed by Raylin Hsu
parent f6247e3d30
commit f63122d51e
2 changed files with 1 additions and 17 deletions

View File

@@ -1173,7 +1173,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;
@@ -1363,7 +1362,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);
@@ -1640,9 +1638,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 {
@@ -1916,8 +1912,6 @@ public class DisplayModeDirector {
void registerPeakRefreshRateObserver(@NonNull ContentResolver cr,
@NonNull ContentObserver observer);
boolean isDeviceInteractive(@NonNull Context context);
}
@VisibleForTesting
@@ -1948,11 +1942,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();
}
}
}

View File

@@ -723,10 +723,5 @@ public class DisplayModeDirectorTest {
PEAK_REFRESH_RATE_URI);
}
}
@Override
public boolean isDeviceInteractive(@NonNull Context context) {
return true;
}
}
}