1 /*
2  * Copyright (C) 2014 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.launcher3.compat;
18 
19 import android.content.Context;
20 import android.os.UserHandle;
21 
22 import com.android.launcher3.Utilities;
23 
24 import java.util.List;
25 
26 public abstract class UserManagerCompat {
UserManagerCompat()27     protected UserManagerCompat() {
28     }
29 
30     private static final Object sInstanceLock = new Object();
31     private static UserManagerCompat sInstance;
32 
getInstance(Context context)33     public static UserManagerCompat getInstance(Context context) {
34         synchronized (sInstanceLock) {
35             if (sInstance == null) {
36                 if (Utilities.ATLEAST_P) {
37                     sInstance = new UserManagerCompatVP(context.getApplicationContext());
38                 } else {
39                     sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
40                 }
41             }
42             return sInstance;
43         }
44     }
45 
46     /**
47      * Creates a cache for users.
48      */
enableAndResetCache()49     public abstract void enableAndResetCache();
50 
getUserProfiles()51     public abstract List<UserHandle> getUserProfiles();
getSerialNumberForUser(UserHandle user)52     public abstract long getSerialNumberForUser(UserHandle user);
getUserForSerialNumber(long serialNumber)53     public abstract UserHandle getUserForSerialNumber(long serialNumber);
isQuietModeEnabled(UserHandle user)54     public abstract boolean isQuietModeEnabled(UserHandle user);
isUserUnlocked(UserHandle user)55     public abstract boolean isUserUnlocked(UserHandle user);
56 
isDemoUser()57     public abstract boolean isDemoUser();
requestQuietModeEnabled(boolean enableQuietMode, UserHandle user)58     public abstract boolean requestQuietModeEnabled(boolean enableQuietMode, UserHandle user);
isAnyProfileQuietModeEnabled()59     public abstract boolean isAnyProfileQuietModeEnabled();
60 
hasWorkProfile()61     public abstract boolean hasWorkProfile();
62 }
63