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 21 import com.android.launcher3.Utilities; 22 23 import java.util.List; 24 25 public abstract class UserManagerCompat { UserManagerCompat()26 protected UserManagerCompat() { 27 } 28 29 private static final Object sInstanceLock = new Object(); 30 private static UserManagerCompat sInstance; 31 getInstance(Context context)32 public static UserManagerCompat getInstance(Context context) { 33 synchronized (sInstanceLock) { 34 if (sInstance == null) { 35 if (Utilities.ATLEAST_N) { 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 */ enableAndResetCache()52 public abstract void enableAndResetCache(); 53 getUserProfiles()54 public abstract List<UserHandleCompat> getUserProfiles(); getSerialNumberForUser(UserHandleCompat user)55 public abstract long getSerialNumberForUser(UserHandleCompat user); getUserForSerialNumber(long serialNumber)56 public abstract UserHandleCompat getUserForSerialNumber(long serialNumber); getBadgedLabelForUser(CharSequence label, UserHandleCompat user)57 public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user); getUserCreationTime(UserHandleCompat user)58 public abstract long getUserCreationTime(UserHandleCompat user); isQuietModeEnabled(UserHandleCompat user)59 public abstract boolean isQuietModeEnabled(UserHandleCompat user); 60 } 61