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

Commit 4f06c68f authored by Jason Hsu's avatar Jason Hsu Committed by Android (Google) Code Review
Browse files

Merge "Fix crash when toggling ambient collapse button in hearing device dialog" into main

parents 9848646d 8f473d60
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -289,6 +289,8 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,
            List<DeviceItem> hearingDeviceItemList = getHearingDeviceItemList();
            CachedBluetoothDevice activeHearingDevice = getActiveHearingDevice(
                    hearingDeviceItemList);
            mLocalBluetoothManager.getEventManager().registerCallback(this);

            mMainExecutor.execute(() -> {
                setupDeviceListView(dialog, hearingDeviceItemList);
                setupPairNewDeviceButton(dialog);
@@ -301,21 +303,6 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,
        });
    }

    @Override
    public void onStart(@NonNull SystemUIDialog dialog) {
        mBgExecutor.execute(() -> {
            if (mLocalBluetoothManager != null) {
                mLocalBluetoothManager.getEventManager().registerCallback(this);
            }
            if (mPresetController != null) {
                mPresetController.registerHapCallback();
            }
            if (mAmbientController != null) {
                mAmbientController.start();
            }
        });
    }

    @Override
    public void onStop(@NonNull SystemUIDialog dialog) {
        mBgExecutor.execute(() -> {
@@ -378,6 +365,7 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,

        mPresetLayout = dialog.requireViewById(R.id.preset_layout);
        mPresetLayout.setVisibility(mPresetController.isPresetControlAvailable() ? VISIBLE : GONE);
        mBgExecutor.execute(() -> mPresetController.registerHapCallback());
    }

    private void setupAmbientControls(CachedBluetoothDevice activeHearingDevice) {
@@ -387,6 +375,7 @@ public class HearingDevicesDialogDelegate implements SystemUIDialog.Delegate,
                mDialog.getContext(), mLocalBluetoothManager, ambientLayout);
        mAmbientController.setShowUiWhenLocalDataExist(false);
        mAmbientController.loadDevice(activeHearingDevice);
        mBgExecutor.execute(() -> mAmbientController.start());
    }

    private void setupPairNewDeviceButton(SystemUIDialog dialog) {