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 18 19 import android.content.Context 20 import android.telephony.TelephonyManager 21 import com.android.systemui.Dumpable 22 import com.android.systemui.dagger.SysUISingleton 23 import com.android.systemui.dump.DumpManager 24 import com.android.systemui.res.R 25 import java.io.PrintWriter 26 import javax.inject.Inject 27 28 /** 29 * An object storing constants that are used for calculating connectivity icons. 30 * 31 * Stored in a class for logging purposes. 32 */ 33 interface ConnectivityConstants { 34 /** True if this device has the capability for data connections and false otherwise. */ 35 val hasDataCapabilities: Boolean 36 37 /** True if we should show the activityIn/activityOut icons and false otherwise */ 38 val shouldShowActivityConfig: Boolean 39 } 40 41 @SysUISingleton 42 class ConnectivityConstantsImpl 43 @Inject 44 constructor(context: Context, dumpManager: DumpManager, telephonyManager: TelephonyManager) : 45 ConnectivityConstants, Dumpable { 46 init { 47 dumpManager.registerNormalDumpable("ConnectivityConstants", this) 48 } 49 50 override val hasDataCapabilities = telephonyManager.isDataCapable 51 52 override val shouldShowActivityConfig = context.resources.getBoolean(R.bool.config_showActivity) 53 dumpnull54 override fun dump(pw: PrintWriter, args: Array<out String>) { 55 pw.apply { 56 println("hasDataCapabilities=$hasDataCapabilities") 57 println("shouldShowActivityConfig=$shouldShowActivityConfig") 58 } 59 } 60 } 61