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.shared.data.model 18 19 import android.content.Context 20 import com.android.internal.R 21 import com.android.systemui.dagger.SysUISingleton 22 import javax.inject.Inject 23 24 /** 25 * A container for all the different types of connectivity slots: wifi, mobile, etc. 26 */ 27 @SysUISingleton 28 class ConnectivitySlots @Inject constructor(context: Context) { 29 private val airplaneSlot: String = context.getString(R.string.status_bar_airplane) 30 private val mobileSlot: String = context.getString(R.string.status_bar_mobile) 31 private val wifiSlot: String = context.getString(R.string.status_bar_wifi) 32 private val ethernetSlot: String = context.getString(R.string.status_bar_ethernet) 33 34 private val slotByName: Map<String, ConnectivitySlot> = mapOf( 35 airplaneSlot to ConnectivitySlot.AIRPLANE, 36 mobileSlot to ConnectivitySlot.MOBILE, 37 wifiSlot to ConnectivitySlot.WIFI, 38 ethernetSlot to ConnectivitySlot.ETHERNET 39 ) 40 41 /** 42 * Given a string name of a slot, returns the instance of [ConnectivitySlot] that it corresponds 43 * to, or null if we couldn't find that slot name. 44 */ getSlotFromNamenull45 fun getSlotFromName(slotName: String): ConnectivitySlot? { 46 return slotByName[slotName] 47 } 48 } 49 50 /** The different types of connectivity slots. */ 51 enum class ConnectivitySlot { 52 AIRPLANE, 53 ETHERNET, 54 MOBILE, 55 WIFI, 56 } 57