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

Commit ae068648 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Status Bar] Implement WifiRepository interface using WifiTrackerLib.

This CL also adds a flag to switch between using the current
WifiRepository and using the WifiRepository based on WifiTrackerLib.

Bug: 292534484
Bug: 292533677
Test: Flip WIFI_TRACKER_LIB_FOR_WIFI_ICON flag on -> verify wifi icon
generally still works
Test: dump WifiTrackerLibInputLog and WifiTrackerLibTableLog -> verify
data is included only with flag **on**
Test: dump WifiInputLog and WifiTableLog -> verify data is included when
flag is on **and** off

Test: atest WifiRepositoryViaTrackerLibTest

Change-Id: Ib74835e78399c6c5ca3821e4aed09bfc0925fc28
parent e50d7b5d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -375,6 +375,10 @@ object Flags {
    @JvmField
    val NEW_BLUETOOTH_REPOSITORY = releasedFlag(612, "new_bluetooth_repository")

    // TODO(b/292533677): Tracking Bug
    val WIFI_TRACKER_LIB_FOR_WIFI_ICON =
        unreleasedFlag(613, "wifi_tracker_lib_for_wifi_icon")

    // 700 - dialer/calls
    // TODO(b/254512734): Tracking Bug
    val ONGOING_CALL_STATUS_BAR_CHIP = releasedFlag(700, "ongoing_call_status_bar_chip")
+57 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.statusbar.pipeline.dagger
import android.net.wifi.WifiManager
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBufferFactory
import com.android.systemui.log.table.TableLogBuffer
@@ -48,9 +50,12 @@ import com.android.systemui.statusbar.pipeline.shared.ui.viewmodel.CollapsedStat
import com.android.systemui.statusbar.pipeline.shared.ui.viewmodel.CollapsedStatusBarViewModelImpl
import com.android.systemui.statusbar.pipeline.wifi.data.repository.RealWifiRepository
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepositoryDagger
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepositorySwitcher
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepositoryViaTrackerLibDagger
import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.DisabledWifiRepository
import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.WifiRepositoryImpl
import com.android.systemui.statusbar.pipeline.wifi.data.repository.prod.WifiRepositoryViaTrackerLib
import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractor
import com.android.systemui.statusbar.pipeline.wifi.domain.interactor.WifiInteractorImpl
import dagger.Binds
@@ -114,14 +119,19 @@ abstract class StatusBarPipelineModule {
        impl: CollapsedStatusBarViewBinderImpl
    ): CollapsedStatusBarViewBinder

    @Binds
    @IntoMap
    @ClassKey(WifiRepositoryDagger::class)
    abstract fun bindWifiRepositoryDagger(impl: WifiRepositoryDagger): CoreStartable

    companion object {
        @Provides
        @SysUISingleton
        fun provideRealWifiRepository(
        fun provideWifiRepositoryDagger(
            wifiManager: WifiManager?,
            disabledWifiRepository: DisabledWifiRepository,
            wifiRepositoryImplFactory: WifiRepositoryImpl.Factory,
        ): RealWifiRepository {
        ): WifiRepositoryDagger {
            // If we have a null [WifiManager], then the wifi repository should be permanently
            // disabled.
            return if (wifiManager == null) {
@@ -131,6 +141,36 @@ abstract class StatusBarPipelineModule {
            }
        }

        @Provides
        @SysUISingleton
        fun provideWifiRepositoryViaTrackerLibDagger(
            wifiManager: WifiManager?,
            disabledWifiRepository: DisabledWifiRepository,
            wifiRepositoryFromTrackerLibFactory: WifiRepositoryViaTrackerLib.Factory,
        ): WifiRepositoryViaTrackerLibDagger {
            // If we have a null [WifiManager], then the wifi repository should be permanently
            // disabled.
            return if (wifiManager == null) {
                disabledWifiRepository
            } else {
                wifiRepositoryFromTrackerLibFactory.create(wifiManager)
            }
        }

        @Provides
        @SysUISingleton
        fun provideRealWifiRepository(
            wifiRepository: WifiRepositoryDagger,
            wifiRepositoryFromTrackerLib: WifiRepositoryViaTrackerLibDagger,
            flags: FeatureFlags,
        ): RealWifiRepository {
            return if (flags.isEnabled(Flags.WIFI_TRACKER_LIB_FOR_WIFI_ICON)) {
                wifiRepositoryFromTrackerLib
            } else {
                wifiRepository
            }
        }

        @Provides
        @SysUISingleton
        @Named(FIRST_MOBILE_SUB_SHOWING_NETWORK_TYPE_ICON)
@@ -149,6 +189,14 @@ abstract class StatusBarPipelineModule {
            return factory.create("WifiInputLog", 50)
        }

        @Provides
        @SysUISingleton
        @WifiTrackerLibInputLog
        fun provideWifiTrackerLibInputLogBuffer(factory: LogBufferFactory): LogBuffer {
            // WifiTrackerLib is pretty noisy, so give it more room than WifiInputLog.
            return factory.create("WifiTrackerLibInputLog", 200)
        }

        @Provides
        @SysUISingleton
        @WifiTableLog
@@ -156,6 +204,13 @@ abstract class StatusBarPipelineModule {
            return factory.create("WifiTableLog", 100)
        }

        @Provides
        @SysUISingleton
        @WifiTrackerLibTableLog
        fun provideWifiTrackerLibTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
            return factory.create("WifiTrackerLibTableLog", 100)
        }

        @Provides
        @SysUISingleton
        @AirplaneTableLog
+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.statusbar.pipeline.dagger

import javax.inject.Qualifier

/** Wifi logs for inputs into [WifiRepositoryViaTrackerLib]. */
@Qualifier
@MustBeDocumented
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
annotation class WifiTrackerLibInputLog
+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.statusbar.pipeline.dagger

import javax.inject.Qualifier

/** Wifi logs from [WifiRepositoryViaTrackerLib] in table format. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class WifiTrackerLibTableLog
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.pipeline.wifi.data.repository

import com.android.systemui.CoreStartable
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
import kotlinx.coroutines.flow.StateFlow
@@ -42,6 +43,13 @@ interface WifiRepository {
        val currentNetwork = wifiNetwork.value
        return currentNetwork is WifiNetworkModel.Active && currentNetwork.hasValidSsid()
    }

    companion object {
        /** Column name to use for [isWifiEnabled] for table logging. */
        const val COL_NAME_IS_ENABLED = "isEnabled"
        /** Column name to use for [isWifiDefault] for table logging. */
        const val COL_NAME_IS_DEFAULT = "isDefault"
    }
}

/**
@@ -53,3 +61,8 @@ interface WifiRepository {
 * repository.
 */
interface RealWifiRepository : WifiRepository

/** Used only by Dagger to bind [WifiRepositoryImpl]. */
interface WifiRepositoryDagger : RealWifiRepository, CoreStartable
/** Used only by Dagger to bind [WifiRepositoryViaTrackerLib]. */
interface WifiRepositoryViaTrackerLibDagger : RealWifiRepository
Loading