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