UserManagerCompat.java revision ff05f4375dd47242d7e4864287e0d5af8ac8ba8f
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
17package com.android.launcher3.compat;
18
19import android.content.Context;
20
21import com.android.launcher3.Utilities;
22
23import java.util.List;
24
25public abstract class UserManagerCompat {
26    protected UserManagerCompat() {
27    }
28
29    private static final Object sInstanceLock = new Object();
30    private static UserManagerCompat sInstance;
31
32    public static UserManagerCompat getInstance(Context context) {
33        synchronized (sInstanceLock) {
34            if (sInstance == null) {
35                if (Utilities.isNycOrAbove()) {
36                    sInstance = new UserManagerCompatVN(context.getApplicationContext());
37                } else if (Utilities.ATLEAST_LOLLIPOP) {
38                    sInstance = new UserManagerCompatVL(context.getApplicationContext());
39                } else if (Utilities.ATLEAST_JB_MR1) {
40                    sInstance = new UserManagerCompatV17(context.getApplicationContext());
41                } else {
42                    sInstance = new UserManagerCompatV16();
43                }
44            }
45            return sInstance;
46        }
47    }
48
49    /**
50     * Creates a cache for users.
51     */
52    public abstract void enableAndResetCache();
53
54    public abstract List<UserHandleCompat> getUserProfiles();
55    public abstract long getSerialNumberForUser(UserHandleCompat user);
56    public abstract UserHandleCompat getUserForSerialNumber(long serialNumber);
57    public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user);
58    public abstract long getUserCreationTime(UserHandleCompat user);
59    public abstract boolean isQuietModeEnabled(UserHandleCompat user);
60}
61