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

Commit 3b1ab4d1 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Support PowerHAL AIDL service" into rvc-dev am: 73e2b381

Change-Id: I7d8e696ee742905167013438d1b964aa2bbe0966
parents a23cea25 73e2b381
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,8 @@ interface IPowerManager
    void releaseWakeLock(IBinder lock, int flags);
    void releaseWakeLock(IBinder lock, int flags);
    void updateWakeLockUids(IBinder lock, in int[] uids);
    void updateWakeLockUids(IBinder lock, in int[] uids);
    oneway void powerHint(int hintId, int data);
    oneway void powerHint(int hintId, int data);
    oneway void setPowerBoost(int boost, int durationMs);
    oneway void setPowerMode(int mode, boolean enabled);


    void updateWakeLockWorkSource(IBinder lock, in WorkSource ws, String historyTag);
    void updateWakeLockWorkSource(IBinder lock, in WorkSource ws, String historyTag);
    boolean isWakeLockLevelSupported(int level);
    boolean isWakeLockLevelSupported(int level);
+113 −0
Original line number Original line Diff line number Diff line
@@ -201,6 +201,119 @@ public abstract class PowerManagerInternal {
     */
     */
    public abstract void powerHint(int hintId, int data);
    public abstract void powerHint(int hintId, int data);


    /**
     * Boost: It is sent when user interacting with the device, for example,
     * touchscreen events are incoming.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Boost.aidl
     */
    public static final int BOOST_INTERACTION = 0;

    /**
     * Boost: It indicates that the framework is likely to provide a new display
     * frame soon. This implies that the device should ensure that the display
     * processing path is powered up and ready to receive that update.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Boost.aidl
     */
    public static final int BOOST_DISPLAY_UPDATE_IMMINENT = 1;

    /**
     * SetPowerBoost() indicates the device may need to boost some resources, as
     * the load is likely to increase before the kernel governors can react.
     * Depending on the boost, it may be appropriate to raise the frequencies of
     * CPU, GPU, memory subsystem, or stop CPU from going into deep sleep state.
     *
     * @param boost Boost which is to be set with a timeout.
     * @param durationMs The expected duration of the user's interaction, if
     *        known, or 0 if the expected duration is unknown.
     *        a negative value indicates canceling previous boost.
     *        A given platform can choose to boost some time based on durationMs,
     *        and may also pick an appropriate timeout for 0 case.
     */
    public abstract void setPowerBoost(int boost, int durationMs);

    /**
     * Mode: It indicates that the device is to allow wake up when the screen
     * is tapped twice.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_DOUBLE_TAP_TO_WAKE = 0;

    /**
     * Mode: It indicates Low power mode is activated or not. Low power mode
     * is intended to save battery at the cost of performance.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_LOW_POWER = 1;

    /**
     * Mode: It indicates Sustained Performance mode is activated or not.
     * Sustained performance mode is intended to provide a consistent level of
     * performance for a prolonged amount of time.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_SUSTAINED_PERFORMANCE = 2;

    /**
     * Mode: It sets the device to a fixed performance level which can be sustained
     * under normal indoor conditions for at least 10 minutes.
     * Fixed performance mode puts both upper and lower bounds on performance such
     * that any workload run while in a fixed performance mode should complete in
     * a repeatable amount of time.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_FIXED_PERFORMANCE = 3;

    /**
     * Mode: It indicates VR Mode is activated or not. VR mode is intended to
     * provide minimum guarantee for performance for the amount of time the device
     * can sustain it.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_VR = 4;

    /**
     * Mode: It indicates that an application has been launched.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_LAUNCH = 5;

    /**
     * Mode: It indicates that the device is about to enter a period of expensive
     * rendering.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_EXPENSIVE_RENDERING = 6;

    /**
     * Mode: It indicates that the device is about entering/leaving interactive
     * state or on-interactive state.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_INTERACTIVE = 7;

    /**
     * Mode: It indicates the device is in device idle, externally known as doze.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_DEVICE_IDLE = 8;

    /**
     * Mode: It indicates that display is either off or still on but is optimized
     * for low power.
     * Defined in hardware/interfaces/power/aidl/android/hardware/power/Mode.aidl
     */
    public static final int MODE_DISPLAY_INACTIVE = 9;

    /**
     * SetPowerMode() is called to enable/disable specific hint mode, which
     * may result in adjustment of power/performance parameters of the
     * cpufreq governor and other controls on device side.
     *
     * @param mode Mode which is to be enable/disable.
     * @param enabled true to enable, false to disable the mode.
     */
    public abstract void setPowerMode(int mode, boolean enabled);

    /** Returns whether there hasn't been a user activity event for the given number of ms. */
    /** Returns whether there hasn't been a user activity event for the given number of ms. */
    public abstract boolean wasDeviceIdleFor(long ms);
    public abstract boolean wasDeviceIdleFor(long ms);


+1 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,7 @@ java_library_static {
        "services-stubs",
        "services-stubs",
        "services.net",
        "services.net",
        "android.hardware.light-V2.0-java",
        "android.hardware.light-V2.0-java",
        "android.hardware.power-java",
        "android.hardware.power-V1.0-java",
        "android.hardware.power-V1.0-java",
        "android.hardware.tv.cec-V1.0-java",
        "android.hardware.tv.cec-V1.0-java",
        "android.hardware.vibrator-java",
        "android.hardware.vibrator-java",
+53 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,8 @@ import android.hardware.SystemSensorManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.DisplayManagerInternal;
import android.hardware.display.DisplayManagerInternal;
import android.hardware.display.DisplayManagerInternal.DisplayPowerRequest;
import android.hardware.display.DisplayManagerInternal.DisplayPowerRequest;
import android.hardware.power.Boost;
import android.hardware.power.Mode;
import android.hardware.power.V1_0.PowerHint;
import android.hardware.power.V1_0.PowerHint;
import android.net.Uri;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.BatteryManager;
@@ -732,6 +734,16 @@ public final class PowerManagerService extends SystemService
            PowerManagerService.nativeSendPowerHint(hintId, data);
            PowerManagerService.nativeSendPowerHint(hintId, data);
        }
        }


        /** Wrapper for PowerManager.nativeSetPowerBoost */
        public void nativeSetPowerBoost(int boost, int durationMs) {
            PowerManagerService.nativeSetPowerBoost(boost, durationMs);
        }

        /** Wrapper for PowerManager.nativeSetPowerMode */
        public void nativeSetPowerMode(int mode, boolean enabled) {
            PowerManagerService.nativeSetPowerMode(mode, enabled);
        }

        /** Wrapper for PowerManager.nativeSetFeature */
        /** Wrapper for PowerManager.nativeSetFeature */
        public void nativeSetFeature(int featureId, int data) {
        public void nativeSetFeature(int featureId, int data) {
            PowerManagerService.nativeSetFeature(featureId, data);
            PowerManagerService.nativeSetFeature(featureId, data);
@@ -817,6 +829,8 @@ public final class PowerManagerService extends SystemService
    private static native void nativeSetInteractive(boolean enable);
    private static native void nativeSetInteractive(boolean enable);
    private static native void nativeSetAutoSuspend(boolean enable);
    private static native void nativeSetAutoSuspend(boolean enable);
    private static native void nativeSendPowerHint(int hintId, int data);
    private static native void nativeSendPowerHint(int hintId, int data);
    private static native void nativeSetPowerBoost(int boost, int durationMs);
    private static native void nativeSetPowerMode(int mode, boolean enabled);
    private static native void nativeSetFeature(int featureId, int data);
    private static native void nativeSetFeature(int featureId, int data);
    private static native boolean nativeForceSuspend();
    private static native boolean nativeForceSuspend();


@@ -3608,6 +3622,16 @@ public final class PowerManagerService extends SystemService
        mNativeWrapper.nativeSendPowerHint(hintId, data);
        mNativeWrapper.nativeSendPowerHint(hintId, data);
    }
    }


    private void setPowerBoostInternal(int boost, int durationMs) {
        // Maybe filter the event.
        mNativeWrapper.nativeSetPowerBoost(boost, durationMs);
    }

    private void setPowerModeInternal(int mode, boolean enabled) {
        // Maybe filter the event.
        mNativeWrapper.nativeSetPowerMode(mode, enabled);
    }

    @VisibleForTesting
    @VisibleForTesting
    boolean wasDeviceIdleForInternal(long ms) {
    boolean wasDeviceIdleForInternal(long ms) {
        synchronized (mLock) {
        synchronized (mLock) {
@@ -4663,6 +4687,26 @@ public final class PowerManagerService extends SystemService
            powerHintInternal(hintId, data);
            powerHintInternal(hintId, data);
        }
        }


        @Override // Binder call
        public void setPowerBoost(int boost, int durationMs) {
            if (!mSystemReady) {
                // Service not ready yet, so who the heck cares about power hints, bah.
                return;
            }
            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
            setPowerBoostInternal(boost, durationMs);
        }

        @Override // Binder call
        public void setPowerMode(int mode, boolean enabled) {
            if (!mSystemReady) {
                // Service not ready yet, so who the heck cares about power hints, bah.
                return;
            }
            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
            setPowerModeInternal(mode, enabled);
        }

        @Override // Binder call
        @Override // Binder call
        public void acquireWakeLock(IBinder lock, int flags, String tag, String packageName,
        public void acquireWakeLock(IBinder lock, int flags, String tag, String packageName,
                WorkSource ws, String historyTag) {
                WorkSource ws, String historyTag) {
@@ -5456,6 +5500,15 @@ public final class PowerManagerService extends SystemService
            powerHintInternal(hintId, data);
            powerHintInternal(hintId, data);
        }
        }


        @Override
        public void setPowerBoost(int boost, int durationMs) {
            setPowerBoostInternal(boost, durationMs);
        }

        @Override
        public void setPowerMode(int mode, boolean enabled) {
            setPowerModeInternal(mode, enabled);
        }
       @Override
       @Override
        public boolean wasDeviceIdleFor(long ms) {
        public boolean wasDeviceIdleFor(long ms) {
            return wasDeviceIdleForInternal(ms);
            return wasDeviceIdleForInternal(ms);
+1 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,7 @@ cc_defaults {
        "android.hardware.light@2.0",
        "android.hardware.light@2.0",
        "android.hardware.power@1.0",
        "android.hardware.power@1.0",
        "android.hardware.power@1.1",
        "android.hardware.power@1.1",
        "android.hardware.power-cpp",
        "android.hardware.power.stats@1.0",
        "android.hardware.power.stats@1.0",
        "android.hardware.thermal@1.0",
        "android.hardware.thermal@1.0",
        "android.hardware.tv.cec@1.0",
        "android.hardware.tv.cec@1.0",
Loading