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

Commit fb1e9b79 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Set initial screen brightness earlier in the boot process."

parents 147931e3 5d6443bf
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -195,7 +195,6 @@ LOCAL_SRC_FILES += \
	core/java/android/os/IBatteryPropertiesListener.aidl \
	core/java/android/os/IBatteryPropertiesListener.aidl \
	core/java/android/os/IBatteryPropertiesRegistrar.aidl \
	core/java/android/os/IBatteryPropertiesRegistrar.aidl \
	core/java/android/os/ICancellationSignal.aidl \
	core/java/android/os/ICancellationSignal.aidl \
	core/java/android/os/IHardwareService.aidl \
	core/java/android/os/IMessenger.aidl \
	core/java/android/os/IMessenger.aidl \
	core/java/android/os/INetworkActivityListener.aidl \
	core/java/android/os/INetworkActivityListener.aidl \
	core/java/android/os/INetworkManagementService.aidl \
	core/java/android/os/INetworkManagementService.aidl \
+0 −26
Original line number Original line Diff line number Diff line
/**
 * Copyright (c) 2007, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.os;

/** {@hide} */
interface IHardwareService
{
    // obsolete flashlight support
    boolean getFlashlightEnabled();
    void setFlashlightEnabled(boolean on);
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,5 +20,5 @@ package com.android.server.display;
 * Interface used to update the actual display state.
 * Interface used to update the actual display state.
 */
 */
public interface DisplayBlanker {
public interface DisplayBlanker {
    void requestDisplayState(int state);
    void requestDisplayState(int state, int brightness);
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -118,10 +118,12 @@ abstract class DisplayDevice {
    /**
    /**
     * Sets the display state, if supported.
     * Sets the display state, if supported.
     *
     *
     * @param state The new display state.
     * @param brightness The new display brightness.
     * @return A runnable containing work to be deferred until after we have
     * @return A runnable containing work to be deferred until after we have
     * exited the critical section, or null if none.
     * exited the critical section, or null if none.
     */
     */
    public Runnable requestDisplayStateLocked(int state) {
    public Runnable requestDisplayStateLocked(int state, int brightness) {
        return null;
        return null;
    }
    }


+38 −10
Original line number Original line Diff line number Diff line
@@ -40,11 +40,13 @@ import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.IBinder.DeathRecipient;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.os.PowerManager;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.Trace;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Slog;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseArray;
@@ -179,7 +181,11 @@ public final class DisplayManagerService extends SystemService {


    // The overall display state, independent of changes that might influence one
    // The overall display state, independent of changes that might influence one
    // display or another in particular.
    // display or another in particular.
    private int mGlobalDisplayState = Display.STATE_UNKNOWN;
    private int mGlobalDisplayState = Display.STATE_ON;

    // The overall display brightness.
    // For now, this only applies to the built-in display but we may split it up eventually.
    private int mGlobalDisplayBrightness = PowerManager.BRIGHTNESS_DEFAULT;


    // Set to true when there are pending display changes that have yet to be applied
    // Set to true when there are pending display changes that have yet to be applied
    // to the surface flinger state.
    // to the surface flinger state.
@@ -226,6 +232,9 @@ public final class DisplayManagerService extends SystemService {
        mUiHandler = UiThread.getHandler();
        mUiHandler = UiThread.getHandler();
        mDisplayAdapterListener = new DisplayAdapterListener();
        mDisplayAdapterListener = new DisplayAdapterListener();
        mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false);
        mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false);

        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();
    }
    }


    @Override
    @Override
@@ -322,17 +331,35 @@ public final class DisplayManagerService extends SystemService {
        }
        }
    }
    }


    private void requestGlobalDisplayStateInternal(int state) {
    private void requestGlobalDisplayStateInternal(int state, int brightness) {
        if (state == Display.STATE_UNKNOWN) {
            state = Display.STATE_ON;
        }
        if (state == Display.STATE_OFF) {
            brightness = PowerManager.BRIGHTNESS_OFF;
        } else if (brightness < 0) {
            brightness = PowerManager.BRIGHTNESS_DEFAULT;
        } else if (brightness > PowerManager.BRIGHTNESS_ON) {
            brightness = PowerManager.BRIGHTNESS_ON;
        }

        synchronized (mTempDisplayStateWorkQueue) {
        synchronized (mTempDisplayStateWorkQueue) {
            try {
            try {
                // Update the display state within the lock.
                // Update the display state within the lock.
                synchronized (mSyncRoot) {
                synchronized (mSyncRoot) {
                    if (mGlobalDisplayState != state) {
                    if (mGlobalDisplayState == state
                            && mGlobalDisplayBrightness == brightness) {
                        return; // no change
                    }

                    Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState("
                            + Display.stateToString(state)
                            + ", brightness=" + brightness + ")");
                    mGlobalDisplayState = state;
                    mGlobalDisplayState = state;
                    mGlobalDisplayBrightness = brightness;
                    updateGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
                    updateGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
                    scheduleTraversalLocked(false);
                    scheduleTraversalLocked(false);
                }
                }
                }


                // Setting the display power state can take hundreds of milliseconds
                // Setting the display power state can take hundreds of milliseconds
                // to complete so we defer the most expensive part of the work until
                // to complete so we defer the most expensive part of the work until
@@ -341,6 +368,7 @@ public final class DisplayManagerService extends SystemService {
                for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) {
                for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) {
                    mTempDisplayStateWorkQueue.get(i).run();
                    mTempDisplayStateWorkQueue.get(i).run();
                }
                }
                Trace.traceEnd(Trace.TRACE_TAG_POWER);
            } finally {
            } finally {
                mTempDisplayStateWorkQueue.clear();
                mTempDisplayStateWorkQueue.clear();
            }
            }
@@ -708,7 +736,7 @@ public final class DisplayManagerService extends SystemService {
        // by the display power controller (if known).
        // by the display power controller (if known).
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
        if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
        if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
            return device.requestDisplayStateLocked(mGlobalDisplayState);
            return device.requestDisplayStateLocked(mGlobalDisplayState, mGlobalDisplayBrightness);
        }
        }
        return null;
        return null;
    }
    }
@@ -1462,16 +1490,16 @@ public final class DisplayManagerService extends SystemService {
            synchronized (mSyncRoot) {
            synchronized (mSyncRoot) {
                DisplayBlanker blanker = new DisplayBlanker() {
                DisplayBlanker blanker = new DisplayBlanker() {
                    @Override
                    @Override
                    public void requestDisplayState(int state) {
                    public void requestDisplayState(int state, int brightness) {
                        // The order of operations is important for legacy reasons.
                        // The order of operations is important for legacy reasons.
                        if (state == Display.STATE_OFF) {
                        if (state == Display.STATE_OFF) {
                            requestGlobalDisplayStateInternal(state);
                            requestGlobalDisplayStateInternal(state, brightness);
                        }
                        }


                        callbacks.onDisplayStateChange(state);
                        callbacks.onDisplayStateChange(state);


                        if (state != Display.STATE_OFF) {
                        if (state != Display.STATE_OFF) {
                            requestGlobalDisplayStateInternal(state);
                            requestGlobalDisplayStateInternal(state, brightness);
                        }
                        }
                    }
                    }
                };
                };
Loading