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.content.Context; 21 import android.os.Handler; 22 import android.os.UserManager; 23 24 import com.android.systemui.dagger.SysUISingleton; 25 import com.android.systemui.dagger.qualifiers.Background; 26 import com.android.systemui.dump.DumpManager; 27 import com.android.systemui.settings.UserContentResolverProvider; 28 import com.android.systemui.settings.UserContextProvider; 29 import com.android.systemui.settings.UserTracker; 30 import com.android.systemui.settings.UserTrackerImpl; 31 32 import dagger.Binds; 33 import dagger.Module; 34 import dagger.Provides; 35 36 /** 37 * Dagger Module for classes found within the com.android.systemui.settings package. 38 */ 39 @Module 40 public abstract class SettingsModule { 41 42 43 @Binds 44 @SysUISingleton bindUserContextProvider(UserTracker tracker)45 abstract UserContextProvider bindUserContextProvider(UserTracker tracker); 46 47 @Binds 48 @SysUISingleton bindUserContentResolverProvider( UserTracker tracker)49 abstract UserContentResolverProvider bindUserContentResolverProvider( 50 UserTracker tracker); 51 52 @SysUISingleton 53 @Provides provideUserTracker( Context context, UserManager userManager, DumpManager dumpManager, @Background Handler handler )54 static UserTracker provideUserTracker( 55 Context context, 56 UserManager userManager, 57 DumpManager dumpManager, 58 @Background Handler handler 59 ) { 60 int startingUser = ActivityManager.getCurrentUser(); 61 UserTrackerImpl tracker = new UserTrackerImpl(context, userManager, dumpManager, handler); 62 tracker.initialize(startingUser); 63 return tracker; 64 } 65 } 66