1 /* 2 * 3 * Copyright (C) 2022 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.android.systemui.statusbar.notification.logging 19 20 import android.util.Log 21 import com.android.systemui.CoreStartable 22 import com.android.systemui.dagger.SysUISingleton 23 import com.android.systemui.flags.FeatureFlags 24 import com.android.systemui.flags.Flags 25 import dagger.Lazy 26 import javax.inject.Inject 27 28 /** This class monitors and logs current Notification memory use. */ 29 @SysUISingleton 30 class NotificationMemoryMonitor 31 @Inject 32 constructor( 33 private val featureFlags: FeatureFlags, 34 private val notificationMemoryDumper: NotificationMemoryDumper, 35 private val notificationMemoryLogger: Lazy<NotificationMemoryLogger>, 36 ) : CoreStartable { 37 38 companion object { 39 private const val TAG = "NotificationMemory" 40 } 41 42 override fun start() { 43 Log.d(TAG, "NotificationMemoryMonitor initialized.") 44 notificationMemoryDumper.init() 45 if (featureFlags.isEnabled(Flags.NOTIFICATION_MEMORY_LOGGING_ENABLED)) { 46 Log.d(TAG, "Notification memory logging enabled.") 47 notificationMemoryLogger.get().init() 48 } 49 } 50 } 51