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

Commit eb94fa79 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Improvements to low power mode.

Add new public API for monitoring low power mode.

BatteryService now puts device in to low power mode when
battery level is low.

Window manager now watches low power mode to turn off
animations.

Modifying the animator scale now gets propagated to all
processes.

Change-Id: I8fa566994764ddd4e1977631e28381ab9409f8ee
parent 58ff7de9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ LOCAL_SRC_FILES += \
	core/java/android/view/IWindowId.aidl \
	core/java/android/view/IWindowManager.aidl \
	core/java/android/view/IWindowSession.aidl \
	core/java/android/view/IWindowSessionCallback.aidl \
	core/java/android/speech/IRecognitionListener.aidl \
	core/java/android/speech/IRecognitionService.aidl \
	core/java/android/speech/tts/ITextToSpeechCallback.aidl \
+2 −0
Original line number Diff line number Diff line
@@ -21325,12 +21325,14 @@ package android.os {
  public final class PowerManager {
    method public void goToSleep(long);
    method public boolean isInteractive();
    method public boolean isPowerSaveMode();
    method public deprecated boolean isScreenOn();
    method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
    method public void reboot(java.lang.String);
    method public void userActivity(long, boolean);
    method public void wakeUp(long);
    field public static final int ACQUIRE_CAUSES_WAKEUP = 268435456; // 0x10000000
    field public static final java.lang.String ACTION_POWER_SAVE_MODE_CHANGED = "android.os.action.POWER_SAVE_MODE_CHANGED";
    field public static final deprecated int FULL_WAKE_LOCK = 26; // 0x1a
    field public static final int ON_AFTER_RELEASE = 536870912; // 0x20000000
    field public static final int PARTIAL_WAKE_LOCK = 1; // 0x1
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ interface IPowerManager
    void goToSleep(long time, int reason, int flags);
    void nap(long time);
    boolean isInteractive();
    boolean isPowerSaveMode();

    void reboot(boolean confirm, String reason, boolean wait);
    void shutdown(boolean confirm, boolean wait);
+25 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.os;

import android.annotation.SdkConstant;
import android.content.Context;
import android.util.Log;

@@ -684,6 +685,30 @@ public final class PowerManager {
        }
    }

    /**
     * Returns true if the device is currently in power save mode.  When in this mode,
     * applications should reduce their functionality in order to conserve battery as
     * much as possible.  You can monitor for changes to this state with
     * {@link #ACTION_POWER_SAVE_MODE_CHANGED}.
     *
     * @return Returns true if currently in low power mode, else false.
     */
    public boolean isPowerSaveMode() {
        try {
            return mService.isPowerSaveMode();
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
     * This broadcast is only sent to registered receivers.
     */
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_POWER_SAVE_MODE_CHANGED
            = "android.os.action.POWER_SAVE_MODE_CHANGED";

    /**
     * A wake lock is a mechanism to indicate that your application needs
     * to have the device stay on.
+4 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.IApplicationToken;
import android.view.IOnKeyguardExitResult;
import android.view.IRotationWatcher;
import android.view.IWindowSession;
import android.view.IWindowSessionCallback;
import android.view.KeyEvent;
import android.view.InputEvent;
import android.view.MagnificationSpec;
@@ -56,7 +57,7 @@ interface IWindowManager
    boolean stopViewServer();            // Transaction #2
    boolean isViewServerRunning();       // Transaction #3

    IWindowSession openSession(in IInputMethodClient client,
    IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client,
            in IInputContext inputContext);
    boolean inputMethodClientHasFocus(IInputMethodClient client);

@@ -130,6 +131,8 @@ interface IWindowManager
    void setAnimationScale(int which, float scale);
    void setAnimationScales(in float[] scales);

    float getCurrentAnimatorScale();

    // For testing
    void setInTouchMode(boolean showFocus);

Loading