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.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         }
37 )
38 public abstract class UserModule {
39 
40     private static final String FILE_PROVIDER_AUTHORITY = "com.android.systemui.fileprovider";
41 
42     @Provides
provideEditUserInfoController()43     public static EditUserInfoController provideEditUserInfoController() {
44         return new EditUserInfoController(FILE_PROVIDER_AUTHORITY);
45     }
46 
47     /** Provides {@link CreateUserDialogController} */
48     @Provides
provideCreateUserDialogController()49     public static CreateUserDialogController provideCreateUserDialogController() {
50         return new CreateUserDialogController(FILE_PROVIDER_AUTHORITY);
51     }
52 
53     /**
54      * Provides the {@link UserHandle} for the user associated with this System UI process.
55      *
56      * <p>Note that this is static and unchanging for the life-time of the process we are running
57      * in. It can be <i>different</i> from the user that is the currently-selected user, which may
58      * be associated with a different System UI process.
59      *
60      * <p>For example, the System UI process which creates all the windows and renders UI is always
61      * the one associated with the primary user on the device. However, if the user is switched to
62      * another, non-primary user (for example user "X"), then a secondary System UI process will be
63      * spawned. While the original primary user process continues to be the only one rendering UI,
64      * the new system UI process may be used for things like file or content access.
65      */
66     @Provides
provideUserHandle()67     public static UserHandle provideUserHandle() {
68         return new UserHandle(UserHandle.myUserId());
69     }
70 }
71