1 /* <lambda>null2 * 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.dump 18 19 import android.content.Context 20 import com.android.systemui.CoreStartable 21 import com.android.systemui.Dumpable 22 import com.android.systemui.res.R 23 import com.android.systemui.dagger.SysUISingleton 24 import java.io.PrintWriter 25 import javax.inject.Inject 26 import javax.inject.Provider 27 28 @SysUISingleton 29 class SystemUIConfigDumpable 30 @Inject 31 constructor( 32 dumpManager: DumpManager, 33 private val context: Context, 34 private val startables: MutableMap<Class<*>, Provider<CoreStartable>>, 35 ) : Dumpable { 36 init { 37 dumpManager.registerCriticalDumpable("SystemUiServiceComponents", this) 38 } 39 40 override fun dump(pw: PrintWriter, args: Array<out String>) { 41 pw.println("SystemUiServiceComponents configuration:") 42 pw.print("vendor component: ") 43 pw.println(context.resources.getString(R.string.config_systemUIVendorServiceComponent)) 44 val services: MutableList<String> = 45 startables.keys.map { cls: Class<*> -> cls.simpleName }.toMutableList() 46 47 services.add(context.resources.getString(R.string.config_systemUIVendorServiceComponent)) 48 dumpServiceList(pw, "global", services.toTypedArray()) 49 dumpServiceList(pw, "per-user", R.array.config_systemUIServiceComponentsPerUser) 50 } 51 52 private fun dumpServiceList(pw: PrintWriter, type: String, resId: Int) { 53 val services: Array<String> = context.resources.getStringArray(resId) 54 dumpServiceList(pw, type, services) 55 } 56 57 private fun dumpServiceList(pw: PrintWriter, type: String, services: Array<String>?) { 58 pw.print(type) 59 pw.print(": ") 60 if (services == null) { 61 pw.println("N/A") 62 return 63 } 64 pw.print(services.size) 65 pw.println(" services") 66 for (i in services.indices) { 67 pw.print(" ") 68 pw.print(i) 69 pw.print(": ") 70 pw.println(services[i]) 71 } 72 } 73 } 74