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

Commit 1d380c7a authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "Refine bluetooth tile dialog." into main

parents 889fd847 0ed5ad8a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -629,7 +629,7 @@
    <!-- QuickSettings: Bluetooth detail panel, text when there are no items [CHAR LIMIT=NONE] -->
    <string name="quick_settings_bluetooth_detail_empty_text">No paired devices available</string>
    <!-- QuickSettings: Bluetooth dialog subtitle [CHAR LIMIT=NONE]-->
    <string name="quick_settings_bluetooth_tile_subtitle">Tap a device to connect</string>
    <string name="quick_settings_bluetooth_tile_subtitle">Tap to connect or disconnect a device </string>
    <!-- QuickSettings: Bluetooth dialog pair new devices [CHAR LIMIT=NONE]-->
    <string name="pair_new_bluetooth_devices">Pair new device</string>
    <!-- QuickSettings: Bluetooth dialog see all devices [CHAR LIMIT=NONE]-->
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.log.dagger

import javax.inject.Qualifier

/** A [com.android.systemui.log.LogBuffer] for Bluetooth QS tile dialog related logging. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class BluetoothTileDialogLog
+8 −0
Original line number Diff line number Diff line
@@ -552,4 +552,12 @@ public class LogModule {
    public static LogBuffer provideSceneFrameworkLogBuffer(LogBufferFactory factory) {
        return factory.create("SceneFramework", 50);
    }

    /** Provides a {@link LogBuffer} for the bluetooth QS tile dialog. */
    @Provides
    @SysUISingleton
    @BluetoothTileDialogLog
    public static LogBuffer provideQBluetoothTileDialogLogBuffer(LogBufferFactory factory) {
        return factory.create("BluetoothTileDialogLog", 50);
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.qs.tiles.dialog.bluetooth

import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothAdapter.STATE_OFF
import android.bluetooth.BluetoothAdapter.STATE_ON
import com.android.settingslib.bluetooth.BluetoothCallback
@@ -37,6 +38,7 @@ internal class BluetoothStateInteractor
@Inject
constructor(
    private val localBluetoothManager: LocalBluetoothManager?,
    private val logger: BluetoothTileDialogLogger,
    @Application private val coroutineScope: CoroutineScope,
) {

@@ -47,6 +49,10 @@ constructor(
                        override fun onBluetoothStateChanged(bluetoothState: Int) {
                            if (bluetoothState == STATE_ON || bluetoothState == STATE_OFF) {
                                super.onBluetoothStateChanged(bluetoothState)
                                logger.logBluetoothState(
                                    BluetoothStateStage.BLUETOOTH_STATE_CHANGE_RECEIVED,
                                    BluetoothAdapter.nameForState(bluetoothState)
                                )
                                trySendWithFailureLogging(
                                    bluetoothState == STATE_ON,
                                    TAG,
@@ -70,6 +76,10 @@ constructor(
            if (isBluetoothEnabled != value) {
                localBluetoothManager?.bluetoothAdapter?.apply {
                    if (value) enable() else disable()
                    logger.logBluetoothState(
                        BluetoothStateStage.BLUETOOTH_STATE_VALUE_SET,
                        value.toString()
                    )
                }
            }
        }
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.internal.logging.UiEventLogger
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.util.time.SystemClock
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
@@ -46,7 +47,9 @@ constructor(
    private val bluetoothToggleInitialValue: Boolean,
    private val subtitleResIdInitialValue: Int,
    private val bluetoothTileDialogCallback: BluetoothTileDialogCallback,
    private val systemClock: SystemClock,
    private val uiEventLogger: UiEventLogger,
    private val logger: BluetoothTileDialogLogger,
    context: Context,
) : SystemUIDialog(context, DEFAULT_THEME, DEFAULT_DISMISS_ON_DEVICE_LOCK) {

@@ -102,9 +105,11 @@ constructor(
        showSeeAll: Boolean,
        showPairNewDevice: Boolean
    ) {
        val start = systemClock.elapsedRealtime()
        deviceItemAdapter.refreshDeviceItemList(deviceItem) {
            seeAllViewGroup.visibility = if (showSeeAll) VISIBLE else GONE
            pairNewDeviceViewGroup.visibility = if (showPairNewDevice) VISIBLE else GONE
            logger.logDeviceUiUpdate(systemClock.elapsedRealtime() - start)
        }
    }

@@ -117,6 +122,7 @@ constructor(
        toggleView.isChecked = bluetoothToggleInitialValue
        toggleView.setOnCheckedChangeListener { _, isChecked ->
            mutableBluetoothStateToggle.value = isChecked
            logger.logBluetoothState(BluetoothStateStage.USER_TOGGLED, isChecked.toString())
            uiEventLogger.log(BluetoothTileDialogUiEvent.BLUETOOTH_TOGGLE_CLICKED)
        }
    }
Loading