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

Commit 7d96d0a4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make BT dialog view model lazy. It could be constructed only when needed." into main

parents 07687b72 eb74339c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.BluetoothController;

import dagger.Lazy;

import kotlinx.coroutines.Job;

import java.util.List;
@@ -84,7 +86,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {

    private final Executor mExecutor;

    private final BluetoothDetailsContentViewModel mDetailsContentViewModel;
    private final Lazy<BluetoothDetailsContentViewModel> mDetailsContentViewModel;

    private final FeatureFlags mFeatureFlags;
    @Nullable
@@ -104,7 +106,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
            QSLogger qsLogger,
            BluetoothController bluetoothController,
            FeatureFlags featureFlags,
            BluetoothDetailsContentViewModel detailsContentViewModel
            Lazy<BluetoothDetailsContentViewModel> detailsContentViewModel
    ) {
        super(host, uiEventLogger, backgroundLooper, mainHandler, falsingManager, metricsLogger,
                statusBarStateController, activityStarter, qsLogger);
@@ -133,7 +135,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
                callback.accept(new BluetoothDetailsViewModel(() -> {
                    longClick(null);
                    return null;
                }, mDetailsContentViewModel))
                }, mDetailsContentViewModel.get()))
        );
        return true;
    }
@@ -158,7 +160,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {

    private void handleClickEvent(@Nullable Expandable expandable) {
        if (mFeatureFlags.isEnabled(Flags.BLUETOOTH_QS_TILE_DIALOG)) {
            mDetailsContentViewModel.showDetailsContent(expandable, /* view= */ null);
            mDetailsContentViewModel.get().showDetailsContent(expandable, /* view= */ null);
        } else {
            // Secondary clicks are header clicks, just toggle.
            toggleBluetooth();
+4 −4
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import dagger.Lazy
import kotlin.test.assertTrue
import kotlinx.coroutines.Job
import org.junit.After
@@ -96,8 +97,7 @@ class BluetoothTileTest(flags: FlagsParameterization) : SysuiTestCase() {
                qsLogger,
                bluetoothController,
                featureFlags,
                bluetoothDetailsContentViewModel,
            )
            ) { bluetoothDetailsContentViewModel }

        tile.initialize()
        testableLooper.processAllMessages()
@@ -308,7 +308,7 @@ class BluetoothTileTest(flags: FlagsParameterization) : SysuiTestCase() {
        qsLogger: QSLogger,
        bluetoothController: BluetoothController,
        featureFlags: FeatureFlagsClassic,
        bluetoothDetailsContentViewModel: BluetoothDetailsContentViewModel,
        lazyBluetoothDetailsContentViewModel: Lazy<BluetoothDetailsContentViewModel>,
    ) :
        BluetoothTile(
            qsHost,
@@ -322,7 +322,7 @@ class BluetoothTileTest(flags: FlagsParameterization) : SysuiTestCase() {
            qsLogger,
            bluetoothController,
            featureFlags,
            bluetoothDetailsContentViewModel,
            lazyBluetoothDetailsContentViewModel,
        ) {
        var restrictionChecked: String? = null