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

Commit a7e58d77 authored by Kweku Adams's avatar Kweku Adams
Browse files

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
parent b94605c3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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);