Home | History | Annotate | Download | only in compat
      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 {
     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.isNycMR1OrAbove()) {
     36                     sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
     37                 } else if (Utilities.isNycOrAbove()) {
     38                     sInstance = new UserManagerCompatVN(context.getApplicationContext());
     39                 } else if (Utilities.ATLEAST_MARSHMALLOW) {
     40                     sInstance = new UserManagerCompatVM(context.getApplicationContext());
     41                 } else if (Utilities.ATLEAST_LOLLIPOP) {
     42                     sInstance = new UserManagerCompatVL(context.getApplicationContext());
     43                 } else if (Utilities.ATLEAST_JB_MR1) {
     44                     sInstance = new UserManagerCompatV17(context.getApplicationContext());
     45                 } else {
     46                     sInstance = new UserManagerCompatV16();
     47                 }
     48             }
     49             return sInstance;
     50         }
     51     }
     52 
     53     /**
     54      * Creates a cache for users.
     55      */
     56     public abstract void enableAndResetCache();
     57 
     58     public abstract List<UserHandleCompat> getUserProfiles();
     59     public abstract long getSerialNumberForUser(UserHandleCompat user);
     60     public abstract UserHandleCompat getUserForSerialNumber(long serialNumber);
     61     public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandleCompat user);
     62     public abstract long getUserCreationTime(UserHandleCompat user);
     63     public abstract boolean isQuietModeEnabled(UserHandleCompat user);
     64     public abstract boolean isUserUnlocked(UserHandleCompat user);
     65 
     66     public abstract boolean isDemoUser();
     67 }
     68