1 package com.android.systemui.statusbar.window 2 3 import android.view.LayoutInflater 4 import com.android.systemui.res.R 5 import com.android.systemui.dagger.SysUISingleton 6 import dagger.Module 7 import dagger.Provides 8 import javax.inject.Qualifier 9 10 /** Module providing dependencies related to the status bar window. */ 11 @Module 12 abstract class StatusBarWindowModule { 13 /** 14 * Provides a [StatusBarWindowView]. 15 * 16 * Only [StatusBarWindowController] should inject the view. 17 */ 18 @Module 19 companion object { 20 @JvmStatic 21 @Provides 22 @SysUISingleton 23 @InternalWindowView providesStatusBarWindowViewnull24 fun providesStatusBarWindowView(layoutInflater: LayoutInflater): StatusBarWindowView { 25 return layoutInflater.inflate( 26 R.layout.super_status_bar, 27 /* root= */null 28 ) as StatusBarWindowView? 29 ?: throw IllegalStateException( 30 "R.layout.super_status_bar could not be properly inflated" 31 ) 32 } 33 } 34 35 /** 36 * We want [StatusBarWindowView] to be provided to [StatusBarWindowController]'s constructor via 37 * dagger so that we can provide a fake window view when testing the controller. However, we wan 38 * want *only* the controller to be able to inject the window view. 39 * 40 * This protected qualifier annotation achieves this. [StatusBarWindowView] can only be injected 41 * if it's annotated with [InternalWindowView], and only classes inside this [statusbar.window] 42 * package can access the annotation. 43 */ 44 @Retention(AnnotationRetention.BINARY) 45 @Qualifier 46 protected annotation class InternalWindowView 47 } 48