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

Commit bbbae9af authored by Hugh Chen's avatar Hugh Chen
Browse files

Fix battery level of earbuds bt devices is inconsistent

Before this CL, bluetooth settings update the battery level of earbuds
when receiving first pair status callback. But sometimes the callback
will not send immediately cause the battery level is inconsistent.

This CL will update the earbuds battery level when onResum() to refresh
battery level immediately.

Bug: 174929347
Bug: 159544311
Test: make -j42 RunSettingsRoboTests
Change-Id: I8505f8fed4ec821b9fa2d88bc437bddd7a30f0e2
parent 6d513a2c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ public final class BluetoothDevicePreference extends GearPreference {
        mHideSecondTarget = hideSecondTarget;
    }

    private void onPreferenceAttributesChanged() {
    void onPreferenceAttributesChanged() {
        ThreadUtils.postOnBackgroundThread(() -> {
            final Pair<Drawable, String> pair =
                    BluetoothUtils.getBtRainbowDrawableWithDescription(getContext(), mCachedDevice);
+9 −0
Original line number Diff line number Diff line
@@ -317,4 +317,13 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback,
        }
        return device.getBondState() == BluetoothDevice.BOND_BONDED && device.isConnected();
    }

    /**
     * Update the attributes of {@link Preference}.
     */
    public void refreshPreference() {
        for (Preference preference : mPreferenceMap.values()) {
            ((BluetoothDevicePreference) preference).onPreferenceAttributesChanged();
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public class AvailableMediaDeviceGroupController extends BasePreferenceControlle
        }
        mBluetoothDeviceUpdater.registerCallback();
        mLocalBluetoothManager.getEventManager().registerCallback(this);
        mBluetoothDeviceUpdater.refreshPreference();
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class ConnectedDeviceGroupController extends BasePreferenceController
        mBluetoothDeviceUpdater.registerCallback();
        mConnectedUsbDeviceUpdater.registerCallback();
        mConnectedDockUpdater.registerCallback();
        mBluetoothDeviceUpdater.refreshPreference();
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
        mBluetoothDeviceUpdater.registerCallback();
        mSavedDockUpdater.registerCallback();
        mContext.registerReceiver(mReceiver, mIntentFilter);
        mBluetoothDeviceUpdater.refreshPreference();
    }

    @Override
Loading