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

Commit 62cef43a authored by Kweku Adams's avatar Kweku Adams
Browse files

Deprecate POWER_SAVE_MODE_CHANGING broadcast.

The internal POWER_SAVE_MODE_CHANGING broadcast is sent at the same
time as the POWER_SAVE_MODE_CHANGED broadcast. Since broadcasts are
asynchronous,there's no reason to have both, especially since it can
potentially lead to inconsistency, so we should simplify down to just
one. Mark the POWER_SAVE_MODE_CHANGING broadcast as deprecated in R and
unavailable to apps targeting R. We'll remove it in a future version.

Bug: 79580230
Test: Android builds
Test: atest BatterySaverReceiverTest
Change-Id: I70e20ce53b496a3dc88a1083c230334f53032d81
parent f1d96d48
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -2224,15 +2224,27 @@ public final class PowerManager {
     * Intent that is broadcast when the state of {@link #isPowerSaveMode()} is about to change.
     * This broadcast is only sent to registered receivers.
     *
     * @deprecated This is sent at the same time as {@link #ACTION_POWER_SAVE_MODE_CHANGED} so it
     * does not provide advanced warning. As such it will be removed in future Android versions.
     * Use {@link #ACTION_POWER_SAVE_MODE_CHANGED} and {@link #isPowerSaveMode()} instead.
     *
     * @hide
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q,
            publicAlternatives = "Use {@link #ACTION_POWER_SAVE_MODE_CHANGED} instead.")
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    @Deprecated
    public static final String ACTION_POWER_SAVE_MODE_CHANGING
            = "android.os.action.POWER_SAVE_MODE_CHANGING";

    /** @hide */
    @UnsupportedAppUsage
    /**
     * @deprecated Use {@link #isPowerSaveMode()} instead.
     *
     * @hide
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q,
            publicAlternatives = "Use {@link #isPowerSaveMode()} instead.")
    @Deprecated
    public static final String EXTRA_POWER_SAVE_MODE = "mode";

    /**