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.user; 18 19 import android.os.UserHandle; 20 21 import com.android.settingslib.users.CreateUserDialogController; 22 import com.android.settingslib.users.EditUserInfoController; 23 import com.android.systemui.user.data.repository.UserRepositoryModule; 24 import com.android.systemui.user.domain.interactor.HeadlessSystemUserModeModule; 25 import com.android.systemui.user.ui.dialog.UserDialogModule; 26 27 import dagger.Module; 28 import dagger.Provides; 29 30 /** 31 * Dagger module for User related classes. 32 */ 33 @Module( 34 includes = { 35 UserDialogModule.class, 36 UserRepositoryModule.class, 37 HeadlessSystemUserModeModule.class, 38 } 39 ) 40 public abstract class UserModule { 41 42 private static final String FILE_PROVIDER_AUTHORITY = "com.android.systemui.fileprovider"; 43 44 @Provides provideEditUserInfoController()45 public static EditUserInfoController provideEditUserInfoController() { 46 return new EditUserInfoController(FILE_PROVIDER_AUTHORITY); 47 } 48 49 /** Provides {@link CreateUserDialogController} */ 50 @Provides provideCreateUserDialogController()51 public static CreateUserDialogController provideCreateUserDialogController() { 52 return new CreateUserDialogController(FILE_PROVIDER_AUTHORITY); 53 } 54 55 /** 56 * Provides the {@link UserHandle} for the user associated with this System UI process. 57 * 58 * <p>Note that this is static and unchanging for the life-time of the process we are running 59 * in. It can be <i>different</i> from the user that is the currently-selected user, which may 60 * be associated with a different System UI process. 61 * 62 * <p>For example, the System UI process which creates all the windows and renders UI is always 63 * the one associated with the primary user on the device. However, if the user is switched to 64 * another, non-primary user (for example user "X"), then a secondary System UI process will be 65 * spawned. While the original primary user process continues to be the only one rendering UI, 66 * the new system UI process may be used for things like file or content access. 67 */ 68 @Provides provideUserHandle()69 public static UserHandle provideUserHandle() { 70 return new UserHandle(UserHandle.myUserId()); 71 } 72 } 73