UserManagerCompat.java revision 9fc953b94dbc6b99e6de08c9dcc80a0cb8e3e319
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;
20import android.graphics.drawable.Drawable;
21import android.os.Build;
22
23import com.android.launcher3.Utilities;
24
25import java.util.List;
26
27public abstract class UserManagerCompat {
28    protected UserManagerCompat() {
29    }
30
31    private static final Object sInstanceLock = new Object();
32    private static UserManagerCompat sInstance;
33
34    public static UserManagerCompat getInstance(Context context) {
35        synchronized (sInstanceLock) {
36            if (sInstance == null) {
37                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 Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user);
58    public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user);
59    public abstract long getUserCreationTime(UserHandleCompat user);
60}
61