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