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 import android.os.UserHandle;
     21 
     22 import com.android.launcher3.Utilities;
     23 
     24 import java.util.List;
     25 
     26 public abstract class UserManagerCompat {
     27     protected UserManagerCompat() {
     28     }
     29 
     30     private static final Object sInstanceLock = new Object();
     31     private static UserManagerCompat sInstance;
     32 
     33     public static UserManagerCompat getInstance(Context context) {
     34         synchronized (sInstanceLock) {
     35             if (sInstance == null) {
     36                 if (Utilities.ATLEAST_P) {
     37                     sInstance = new UserManagerCompatVP(context.getApplicationContext());
     38                 } else if (Utilities.ATLEAST_NOUGAT_MR1) {
     39                     sInstance = new UserManagerCompatVNMr1(context.getApplicationContext());
     40                 } else if (Utilities.ATLEAST_NOUGAT) {
     41                     sInstance = new UserManagerCompatVN(context.getApplicationContext());
     42                 } else if (Utilities.ATLEAST_MARSHMALLOW) {
     43                     sInstance = new UserManagerCompatVM(context.getApplicationContext());
     44                 } else {
     45                     sInstance = new UserManagerCompatVL(context.getApplicationContext());
     46                 }
     47             }
     48             return sInstance;
     49         }
     50     }
     51 
     52     /**
     53      * Creates a cache for users.
     54      */
     55     public abstract void enableAndResetCache();
     56 
     57     public abstract List<UserHandle> getUserProfiles();
     58     public abstract long getSerialNumberForUser(UserHandle user);
     59     public abstract UserHandle getUserForSerialNumber(long serialNumber);
     60     public abstract CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user);
     61     public abstract boolean isQuietModeEnabled(UserHandle user);
     62     public abstract boolean isUserUnlocked(UserHandle user);
     63 
     64     public abstract boolean isDemoUser();
     65     public abstract boolean requestQuietModeEnabled(boolean enableQuietMode, UserHandle user);
     66     public abstract boolean isAnyProfileQuietModeEnabled();
     67 }
     68