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_NOUGAT_MR1) {
37                     sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
38                 } else if (Utilities.ATLEAST_NOUGAT) {
39                     sInstance = new UserManagerCompatVN(context.getApplicationContext());
40                 } else if (Utilities.ATLEAST_MARSHMALLOW) {
41                     sInstance = new UserManagerCompatVM(context.getApplicationContext());
42                 } else {
43                     sInstance = new UserManagerCompatVL(context.getApplicationContext());
44                 }
45             }
46             return sInstance;
47         }
48     }
49 
50     /**
51      * Creates a cache for users.
52      */
enableAndResetCache()53     public abstract void enableAndResetCache();
54 
getUserProfiles()55     public abstract List<UserHandle> getUserProfiles();
getSerialNumberForUser(UserHandle user)56     public abstract long getSerialNumberForUser(UserHandle user);
getUserForSerialNumber(long serialNumber)57     public abstract UserHandle getUserForSerialNumber(long serialNumber);
getBadgedLabelForUser(CharSequence label, UserHandle user)58     public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user);
getUserCreationTime(UserHandle user)59     public abstract long getUserCreationTime(UserHandle user);
isQuietModeEnabled(UserHandle user)60     public abstract boolean isQuietModeEnabled(UserHandle user);
isUserUnlocked(UserHandle user)61     public abstract boolean isUserUnlocked(UserHandle user);
62 
isDemoUser()63     public abstract boolean isDemoUser();
64 }
65