Change to public POWER_SAVE_MODE_CHANGED broadcast.

The 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, so we're simplifying down to just one.

Bug: 79580230
Test: atest BatterySaverReceiverTest
Change-Id: Ib27fc91bc23126f58532e534575d912e3b72ac43
This commit is contained in:
Kweku Adams
2020-03-16 12:56:46 -07:00
parent b94605c378
commit a7e58d7732
2 changed files with 3 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ public class BatterySaverReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.d(TAG, "Received " + intent.getAction());
String action = intent.getAction();
if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGING.equals(action)) {
if (PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)) {
if (mBatterySaverListener != null) {
mBatterySaverListener.onPowerSaveModeChanged();
}
@@ -55,7 +55,7 @@ public class BatterySaverReceiver extends BroadcastReceiver {
public void setListening(boolean listening) {
if (listening && !mRegistered) {
final IntentFilter ifilter = new IntentFilter();
ifilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING);
ifilter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
ifilter.addAction(Intent.ACTION_BATTERY_CHANGED);
mContext.registerReceiver(this, ifilter);
mRegistered = true;

View File

@@ -68,7 +68,7 @@ public class BatterySaverReceiverTest {
@Test
public void testOnReceive_powerSaveModeChanged_invokeCallback() {
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGING);
Intent intent = new Intent(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
mBatterySaverReceiver.onReceive(mContext, intent);