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; 20ed13187a745866483139e2878037e1f8427ce567Kenny Guy 21d794a3f46521b972fa02826d379d1efa112793d2Kenny Guyimport com.android.launcher3.Utilities; 22d794a3f46521b972fa02826d379d1efa112793d2Kenny Guy 23ed13187a745866483139e2878037e1f8427ce567Kenny Guyimport java.util.List; 24ed13187a745866483139e2878037e1f8427ce567Kenny Guy 25ed13187a745866483139e2878037e1f8427ce567Kenny Guypublic abstract class UserManagerCompat { 26ed13187a745866483139e2878037e1f8427ce567Kenny Guy protected UserManagerCompat() { 27ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 28ed13187a745866483139e2878037e1f8427ce567Kenny Guy 29823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal private static final Object sInstanceLock = new Object(); 30823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal private static UserManagerCompat sInstance; 31823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal 32ed13187a745866483139e2878037e1f8427ce567Kenny Guy public static UserManagerCompat getInstance(Context context) { 33823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal synchronized (sInstanceLock) { 34823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal if (sInstance == null) { 3535908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal if (Utilities.isNycMR1OrAbove()) { 3635908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal sInstance = new UserManagerCompatVNMr1(context.getApplicationContext()); 3735908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal } else if (Utilities.isNycOrAbove()) { 38ff05f4375dd47242d7e4864287e0d5af8ac8ba8fKenny Guy sInstance = new UserManagerCompatVN(context.getApplicationContext()); 3935908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal } else if (Utilities.ATLEAST_MARSHMALLOW) { 4035908f9e67b9cdae917385ef9e67e168cb0c93b3Sunny Goyal sInstance = new UserManagerCompatVM(context.getApplicationContext()); 41ff05f4375dd47242d7e4864287e0d5af8ac8ba8fKenny Guy } else if (Utilities.ATLEAST_LOLLIPOP) { 42823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal sInstance = new UserManagerCompatVL(context.getApplicationContext()); 439fc953b94dbc6b99e6de08c9dcc80a0cb8e3e319Sunny Goyal } else if (Utilities.ATLEAST_JB_MR1) { 44823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal sInstance = new UserManagerCompatV17(context.getApplicationContext()); 45823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } else { 46823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal sInstance = new UserManagerCompatV16(); 47823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } 48823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal } 49823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal return sInstance; 50ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 51ed13187a745866483139e2878037e1f8427ce567Kenny Guy } 52ed13187a745866483139e2878037e1f8427ce567Kenny Guy 53823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal /** 54823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal * Creates a cache for users. 55823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal */ 56823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal public abstract void enableAndResetCache(); 57823fd5090209017a029460e7dbd8ab9d51d013ddSunny Goyal 58ed13187a745866483139e2878037e1f8427ce567Kenny Guy public abstract List<UserHandleCompat> getUserProfiles(); 59ed13187a745866483139e2878037e1f8427ce567Kenny Guy public abstract long getSerialNumberForUser(UserHandleCompat user); 60ed13187a745866483139e2878037e1f8427ce567Kenny Guy public abstract UserHandleCompat getUserForSerialNumber(long serialNumber); 61d6fe52636dcaa96ec1e10ce2daebe98b820c9739Kenny Guy public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user); 6218bf8e2ffde3444d53aaa9654da02cdedd0b7cd1Sunny Goyal public abstract long getUserCreationTime(UserHandleCompat user); 63ff05f4375dd47242d7e4864287e0d5af8ac8ba8fKenny Guy public abstract boolean isQuietModeEnabled(UserHandleCompat user); 64d3b87ef1963fb96177ca85bcd6a25879e27e419cSunny Goyal public abstract boolean isUserUnlocked(UserHandleCompat user); 65b5bf3e6ceeb6f8af433357324a543914fd8ebaf9Sunny Goyal 66b5bf3e6ceeb6f8af433357324a543914fd8ebaf9Sunny Goyal public abstract boolean isDemoUser(); 67ed13187a745866483139e2878037e1f8427ce567Kenny Guy} 68