Remove 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're simplifying down to just one.

Bug: 79580230
Test: Android builds
Test: atest BatterySaverReceiverTest
Change-Id: I94512aa88f442e827100cc2abf0a02da356641aa
This commit is contained in:
Kweku Adams
2020-03-16 14:24:31 -07:00
parent 5a328a2037
commit f7cd0673be
3 changed files with 1 additions and 34 deletions

View File

@@ -2220,33 +2220,6 @@ public final class PowerManager {
public static final String ACTION_POWER_SAVE_TEMP_WHITELIST_CHANGED
= "android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED";
/**
* 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(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";
/**
* @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";
/**
* Constant for PreIdleTimeout normal mode (default mode, not short nor extend timeout) .
* @hide

View File

@@ -99,7 +99,6 @@
<protected-broadcast android:name="android.intent.action.LOAD_DATA" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGED" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_MODE_CHANGING" />
<protected-broadcast android:name="android.os.action.DEVICE_IDLE_MODE_CHANGED" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_WHITELIST_CHANGED" />
<protected-broadcast android:name="android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED" />

View File

@@ -497,12 +497,7 @@ public class BatterySaverController implements BatterySaverPolicyListener {
// Send the broadcasts and notify the listeners. We only do this when the battery saver
// mode changes, but not when only the screen state changes.
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING)
.putExtra(PowerManager.EXTRA_POWER_SAVE_MODE, isEnabled())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);