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

Commit e9d4b631 authored by Piotr Wilczyński's avatar Piotr Wilczyński Committed by Android (Google) Code Review
Browse files

Merge "Provide the current auto-brightness levels in DisplayOffloadSession" into main

parents 589cf5ff b472d6b3
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -751,6 +751,23 @@ public abstract class DisplayManagerInternal {
         */
        boolean blockScreenOn(Runnable unblocker);

        /**
         * Get the brightness levels used to determine automatic brightness based on lux levels.
         * @param mode The auto-brightness mode
         *             (AutomaticBrightnessController.AutomaticBrightnessMode)
         * @return The brightness levels for the specified mode. The values are between
         * {@link PowerManager.BRIGHTNESS_MIN} and {@link PowerManager.BRIGHTNESS_MAX}.
         */
        float[] getAutoBrightnessLevels(int mode);

        /**
         * Get the lux levels used to determine automatic brightness.
         * @param mode The auto-brightness mode
         *             (AutomaticBrightnessController.AutomaticBrightnessMode)
         * @return The lux levels for the specified mode
         */
        float[] getAutoBrightnessLuxLevels(int mode);

        /** Returns whether displayoffload supports the given display state. */
        static boolean isSupportedOffloadState(int displayState) {
            return Display.isSuspendedState(displayState);
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public class AutomaticBrightnessController {
    public static final int AUTO_BRIGHTNESS_MODE_DEFAULT = 0;
    public static final int AUTO_BRIGHTNESS_MODE_IDLE = 1;
    public static final int AUTO_BRIGHTNESS_MODE_DOZE = 2;
    public static final int AUTO_BRIGHTNESS_MODE_MAX = AUTO_BRIGHTNESS_MODE_DOZE;

    // How long the current sensor reading is assumed to be valid beyond the current time.
    // This provides a bit of prediction, as well as ensures that the weight for the last sample is
+18 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display;

import static com.android.server.display.AutomaticBrightnessController.AUTO_BRIGHTNESS_MODE_MAX;

import android.annotation.Nullable;
import android.hardware.display.DisplayManagerInternal;
import android.os.PowerManager;
@@ -65,6 +67,22 @@ public class DisplayOffloadSessionImpl implements DisplayManagerInternal.Display
        return true;
    }

    @Override
    public float[] getAutoBrightnessLevels(int mode) {
        if (mode < 0 || mode > AUTO_BRIGHTNESS_MODE_MAX) {
            throw new IllegalArgumentException("Unknown auto-brightness mode: " + mode);
        }
        return mDisplayPowerController.getAutoBrightnessLevels(mode);
    }

    @Override
    public float[] getAutoBrightnessLuxLevels(int mode) {
        if (mode < 0 || mode > AUTO_BRIGHTNESS_MODE_MAX) {
            throw new IllegalArgumentException("Unknown auto-brightness mode: " + mode);
        }
        return mDisplayPowerController.getAutoBrightnessLuxLevels(mode);
    }

    /**
     * Start the offload session. The method returns if the session is already active.
     * @return Whether the session was started successfully
+14 −0
Original line number Diff line number Diff line
@@ -2213,6 +2213,20 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        // The old DPC is no longer supported
    }

    @Override
    public float[] getAutoBrightnessLevels(
            @AutomaticBrightnessController.AutomaticBrightnessMode int mode) {
        // The old DPC is no longer supported
        return null;
    }

    @Override
    public float[] getAutoBrightnessLuxLevels(
            @AutomaticBrightnessController.AutomaticBrightnessMode int mode) {
        // The old DPC is no longer supported
        return null;
    }

    @Override
    public BrightnessInfo getBrightnessInfo() {
        synchronized (mCachedBrightnessInfo) {
+18 −0
Original line number Diff line number Diff line
@@ -1885,6 +1885,24 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
        mHandler.sendMessageAtTime(msg, mClock.uptimeMillis());
    }

    @Override
    public float[] getAutoBrightnessLevels(
            @AutomaticBrightnessController.AutomaticBrightnessMode int mode) {
        int preset = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_FOR_ALS,
                Settings.System.SCREEN_BRIGHTNESS_AUTOMATIC_NORMAL, UserHandle.USER_CURRENT);
        return mDisplayDeviceConfig.getAutoBrightnessBrighteningLevels(mode, preset);
    }

    @Override
    public float[] getAutoBrightnessLuxLevels(
            @AutomaticBrightnessController.AutomaticBrightnessMode int mode) {
        int preset = Settings.System.getIntForUser(mContext.getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_FOR_ALS,
                Settings.System.SCREEN_BRIGHTNESS_AUTOMATIC_NORMAL, UserHandle.USER_CURRENT);
        return mDisplayDeviceConfig.getAutoBrightnessBrighteningLevelsLux(mode, preset);
    }

    @Override
    public BrightnessInfo getBrightnessInfo() {
        synchronized (mCachedBrightnessInfo) {
Loading