1ed13187a745866483139e2878037e1f8427ce567Kenny Guy/* 2ed13187a745866483139e2878037e1f8427ce567Kenny Guy * Copyright (C) 2014 The Android Open Source Project 3ed13187a745866483139e2878037e1f8427ce567Kenny Guy * 4ed13187a745866483139e2878037e1f8427ce567Kenny Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5ed13187a745866483139e2878037e1f8427ce567Kenny Guy * you may not use this file except in compliance with the License. 6ed13187a745866483139e2878037e1f8427ce567Kenny Guy * You may obtain a copy of the License at 7ed13187a745866483139e2878037e1f8427ce567Kenny Guy * 8ed13187a745866483139e2878037e1f8427ce567Kenny Guy * http://www.apache.org/licenses/LICENSE-2.0 9ed13187a745866483139e2878037e1f8427ce567Kenny Guy * 10ed13187a745866483139e2878037e1f8427ce567Kenny Guy * Unless required by applicable law or agreed to in writing, software 11ed13187a745866483139e2878037e1f8427ce567Kenny Guy * distributed under the License is distributed on an "AS IS" BASIS, 12ed13187a745866483139e2878037e1f8427ce567Kenny Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ed13187a745866483139e2878037e1f8427ce567Kenny Guy * See the License for the specific language governing permissions and 14ed13187a745866483139e2878037e1f8427ce567Kenny Guy * limitations under the License. 15ed13187a745866483139e2878037e1f8427ce567Kenny Guy */ 16ed13187a745866483139e2878037e1f8427ce567Kenny Guy 17ed13187a745866483139e2878037e1f8427ce567Kenny Guypackage com.android.launcher3.compat; 18ed13187a745866483139e2878037e1f8427ce567Kenny Guy 19ed13187a745866483139e2878037e1f8427ce567Kenny Guyimport android.content.Context; 207c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyalimport android.os.UserHandle; 21ed13187a745866483139e2878037e1f8427ce567Kenny Guy 22d794a3f46521b972fa02826d379d1efa112793d2Kenny Guyimport com.android.launcher3.Utilities; 23d794a3f46521b972fa02826d379d1efa112793d2Kenny Guy 24ed13187a745866483139e2878037e1f8427ce567Kenny Guyimport java.util.List; 25ed13187a745866483139e2878037e1f8427ce567Kenny Guy 26ed13187a745866483139e2878037e1f8427ce567Kenny Guypublic abstract class UserManagerCompat { 27ed13187a745866483139e2878037e1f8427ce567Kenny Guy protected UserManagerCompat() { 28ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 29ed13187a745866483139e2878037e1f8427ce567Kenny Guy 30823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal private static final Object sInstanceLock = new Object(); 31823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal private static UserManagerCompat sInstance; 32823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal 33ed13187a745866483139e2878037e1f8427ce567Kenny Guy public static UserManagerCompat getInstance(Context context) { 34823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal synchronized (sInstanceLock) { 35823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal if (sInstance == null) { 36f5e3744637db1598c389e62450627b2548f8f517Sunny Goyal if (Utilities.ATLEAST_NOUGAT_MR1) { 3735908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal sInstance = new UserManagerCompatVNMr1(context.getApplicationContext()); 38f5e3744637db1598c389e62450627b2548f8f517Sunny Goyal } else if (Utilities.ATLEAST_NOUGAT) { 39ff05f4375dd47242d7e4864287e0d5af8ac8ba8fKenny Guy sInstance = new UserManagerCompatVN(context.getApplicationContext()); 4035908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal } else if (Utilities.ATLEAST_MARSHMALLOW) { 4135908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal sInstance = new UserManagerCompatVM(context.getApplicationContext()); 42823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } else { 43a52ecb0390c85afb385371bb844bb496c59ddf87Sunny Goyal sInstance = new UserManagerCompatVL(context.getApplicationContext()); 44823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } 45823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } 46823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal return sInstance; 47ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 48ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 49ed13187a745866483139e2878037e1f8427ce567Kenny Guy 50823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal /** 51823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal * Creates a cache for users. 52823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal */ 53823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal public abstract void enableAndResetCache(); 54823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal 557c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract List<UserHandle> getUserProfiles(); 567c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract long getSerialNumberForUser(UserHandle user); 577c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract UserHandle getUserForSerialNumber(long serialNumber); 587c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user); 597c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract long getUserCreationTime(UserHandle user); 607c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract boolean isQuietModeEnabled(UserHandle user); 617c74e4ae641e76f73d74348e293c244a157f6585Sunny Goyal public abstract boolean isUserUnlocked(UserHandle user); 62b5bf3e6ceeb6f8af433357324a543914fd8ebaf9Sunny Goyal 63b5bf3e6ceeb6f8af433357324a543914fd8ebaf9Sunny Goyal public abstract boolean isDemoUser(); 64ed13187a745866483139e2878037e1f8427ce567Kenny Guy} 65