1 /* 2 * Copyright (C) 2023 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.ethernet.domain 18 19 import com.android.settingslib.AccessibilityContentDescriptions 20 import com.android.systemui.res.R 21 import com.android.systemui.common.shared.model.ContentDescription 22 import com.android.systemui.common.shared.model.Icon 23 import com.android.systemui.dagger.SysUISingleton 24 import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository 25 import javax.inject.Inject 26 import kotlinx.coroutines.flow.Flow 27 import kotlinx.coroutines.flow.map 28 29 /** 30 * Currently we don't do much to interact with ethernet. We simply need a place to map between the 31 * connectivity state of a default ethernet connection, and an icon representing that connection. 32 */ 33 @SysUISingleton 34 class EthernetInteractor 35 @Inject 36 constructor( 37 connectivityRepository: ConnectivityRepository, 38 ) { 39 /** Icon representing the current connectivity status of the ethernet connection */ 40 val icon: Flow<Icon.Resource?> = <lambda>null41 connectivityRepository.defaultConnections.map { 42 if (it.ethernet.isDefault) { 43 if (it.isValidated) { 44 Icon.Resource( 45 R.drawable.stat_sys_ethernet_fully, 46 ContentDescription.Resource( 47 AccessibilityContentDescriptions.ETHERNET_CONNECTION_VALUES[1] 48 ) 49 ) 50 } else { 51 Icon.Resource( 52 R.drawable.stat_sys_ethernet, 53 ContentDescription.Resource( 54 AccessibilityContentDescriptions.ETHERNET_CONNECTION_VALUES[0] 55 ) 56 ) 57 } 58 } else { 59 null 60 } 61 } 62 } 63