1 /* 2 * Copyright (C) 2020 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.settings.dagger; 18 19 import android.app.ActivityManager; 20 import android.app.IActivityManager; 21 import android.content.Context; 22 import android.hardware.display.DisplayManager; 23 import android.os.Handler; 24 import android.os.UserManager; 25 26 import com.android.systemui.CoreStartable; 27 import com.android.systemui.dagger.SysUISingleton; 28 import com.android.systemui.dagger.qualifiers.Background; 29 import com.android.systemui.dump.DumpManager; 30 import com.android.systemui.settings.DisplayTracker; 31 import com.android.systemui.settings.DisplayTrackerImpl; 32 import com.android.systemui.settings.UserContentResolverProvider; 33 import com.android.systemui.settings.UserContextProvider; 34 import com.android.systemui.settings.UserFileManager; 35 import com.android.systemui.settings.UserFileManagerImpl; 36 import com.android.systemui.settings.UserTracker; 37 import com.android.systemui.settings.UserTrackerImpl; 38 39 import dagger.Binds; 40 import dagger.Module; 41 import dagger.Provides; 42 import dagger.multibindings.ClassKey; 43 import dagger.multibindings.IntoMap; 44 45 /** 46 * Dagger Module for classes found within the com.android.systemui.settings package. 47 */ 48 @Module 49 public abstract class MultiUserUtilsModule { 50 @Binds 51 @SysUISingleton bindUserContextProvider(UserTracker tracker)52 abstract UserContextProvider bindUserContextProvider(UserTracker tracker); 53 54 @Binds 55 @SysUISingleton bindUserContentResolverProvider( UserTracker tracker)56 abstract UserContentResolverProvider bindUserContentResolverProvider( 57 UserTracker tracker); 58 59 @SysUISingleton 60 @Provides provideUserTracker( Context context, UserManager userManager, IActivityManager iActivityManager, DumpManager dumpManager, @Background Handler handler )61 static UserTracker provideUserTracker( 62 Context context, 63 UserManager userManager, 64 IActivityManager iActivityManager, 65 DumpManager dumpManager, 66 @Background Handler handler 67 ) { 68 int startingUser = ActivityManager.getCurrentUser(); 69 UserTrackerImpl tracker = new UserTrackerImpl(context, userManager, iActivityManager, 70 dumpManager, handler); 71 tracker.initialize(startingUser); 72 return tracker; 73 } 74 75 @SysUISingleton 76 @Provides provideDisplayTracker( DisplayManager displayManager, @Background Handler handler )77 static DisplayTracker provideDisplayTracker( 78 DisplayManager displayManager, 79 @Background Handler handler 80 ) { 81 return new DisplayTrackerImpl(displayManager, handler); 82 } 83 84 @Binds 85 @IntoMap 86 @ClassKey(UserFileManagerImpl.class) bindUserFileManagerCoreStartable(UserFileManagerImpl sysui)87 abstract CoreStartable bindUserFileManagerCoreStartable(UserFileManagerImpl sysui); 88 89 @Binds bindUserFileManager(UserFileManagerImpl impl)90 abstract UserFileManager bindUserFileManager(UserFileManagerImpl impl); 91 } 92