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

Commit a1324f30 authored by raylinhsu's avatar raylinhsu
Browse files

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
parent 3bb0fbea
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -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();
        }
    }

}
+0 −5
Original line number Diff line number Diff line
@@ -818,10 +818,5 @@ public class DisplayModeDirectorTest {
                        PEAK_REFRESH_RATE_URI);
            }
        }

        @Override
        public boolean isDeviceInteractive(@NonNull Context context) {
            return true;
        }
    }
}