1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.pipeline.mobile.domain.interactor 18 19 import android.telephony.CellSignalStrength 20 import com.android.settingslib.SignalIcon 21 import com.android.settingslib.mobile.TelephonyIcons 22 import com.android.systemui.log.table.TableLogBuffer 23 import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel 24 import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository.Companion.DEFAULT_NUM_LEVELS 25 import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel 26 import kotlinx.coroutines.flow.MutableStateFlow 27 28 class FakeMobileIconInteractor( 29 override val tableLogBuffer: TableLogBuffer, 30 ) : MobileIconInteractor { 31 override val alwaysShowDataRatIcon = MutableStateFlow(false) 32 33 override val alwaysUseCdmaLevel = MutableStateFlow(false) 34 35 override val activity = 36 MutableStateFlow( 37 DataActivityModel( 38 hasActivityIn = false, 39 hasActivityOut = false, 40 ) 41 ) 42 43 override val isConnected = MutableStateFlow(true) 44 45 private val _iconGroup = MutableStateFlow<SignalIcon.MobileIconGroup>(TelephonyIcons.THREE_G) 46 override val networkTypeIconGroup = _iconGroup 47 48 override val networkName = MutableStateFlow(NetworkNameModel.IntentDerived("demo mode")) 49 50 private val _isEmergencyOnly = MutableStateFlow(false) 51 override val isEmergencyOnly = _isEmergencyOnly 52 53 override val isRoaming = MutableStateFlow(false) 54 55 private val _isFailedConnection = MutableStateFlow(false) 56 override val isDefaultConnectionFailed = _isFailedConnection 57 58 override val isDataConnected = MutableStateFlow(true) 59 60 override val isInService = MutableStateFlow(true) 61 62 private val _isDataEnabled = MutableStateFlow(true) 63 override val isDataEnabled = _isDataEnabled 64 65 private val _isDefaultDataEnabled = MutableStateFlow(true) 66 override val isDefaultDataEnabled = _isDefaultDataEnabled 67 68 private val _level = MutableStateFlow(CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) 69 override val level = _level 70 71 private val _numberOfLevels = MutableStateFlow(DEFAULT_NUM_LEVELS) 72 override val numberOfLevels = _numberOfLevels 73 74 override val isForceHidden = MutableStateFlow(false) 75 setIconGroupnull76 fun setIconGroup(group: SignalIcon.MobileIconGroup) { 77 _iconGroup.value = group 78 } 79 setIsEmergencyOnlynull80 fun setIsEmergencyOnly(emergency: Boolean) { 81 _isEmergencyOnly.value = emergency 82 } 83 setIsDataEnablednull84 fun setIsDataEnabled(enabled: Boolean) { 85 _isDataEnabled.value = enabled 86 } 87 setIsDefaultDataEnablednull88 fun setIsDefaultDataEnabled(disabled: Boolean) { 89 _isDefaultDataEnabled.value = disabled 90 } 91 setIsFailedConnectionnull92 fun setIsFailedConnection(failed: Boolean) { 93 _isFailedConnection.value = failed 94 } 95 setLevelnull96 fun setLevel(level: Int) { 97 _level.value = level 98 } 99 setNumberOfLevelsnull100 fun setNumberOfLevels(num: Int) { 101 _numberOfLevels.value = num 102 } 103 } 104