Home | History | Annotate | Download | only in compat
      1 
      2 /*
      3  * Copyright (C) 2015 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 package com.android.contacts.compat;
     19 
     20 import android.provider.ContactsContract.ProviderStatus;
     21 
     22 /**
     23  * This class contains constants from the pre-M version of ContactsContract.ProviderStatus class
     24  * and also the mappings between pre-M constants and M constants for compatibility purpose,
     25  * because ProviderStatus class constant names and values changed and the class became visible in
     26  * API level 23.
     27  */
     28 public class ProviderStatusCompat {
     29     /**
     30      * Not instantiable.
     31      */
     32     private ProviderStatusCompat() {
     33     }
     34 
     35     public static final boolean USE_CURRENT_VERSION = CompatUtils.isMarshmallowCompatible();
     36 
     37     public static final int STATUS_EMPTY = USE_CURRENT_VERSION ?
     38             ProviderStatus.STATUS_EMPTY : ProviderStatusCompat.STATUS_NO_ACCOUNTS_NO_CONTACTS;
     39 
     40     public static final int STATUS_BUSY = USE_CURRENT_VERSION ?
     41             ProviderStatus.STATUS_BUSY : ProviderStatusCompat.STATUS_UPGRADING;
     42 
     43     /**
     44      * Default status of the provider, using the actual constant to guard against errors
     45      */
     46     public static final int STATUS_NORMAL = ProviderStatus.STATUS_NORMAL;
     47 
     48     /**
     49      * The following three constants are from pre-M.
     50      *
     51      * The status used when the provider is in the process of upgrading.  Contacts
     52      * are temporarily unaccessible.
     53      */
     54     private static final int STATUS_UPGRADING = 1;
     55 
     56     /**
     57      * The status used during a locale change.
     58      */
     59     public static final int STATUS_CHANGING_LOCALE = 3;
     60 
     61     /**
     62      * The status that indicates that there are no accounts and no contacts
     63      * on the device.
     64      */
     65     private static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4;
     66 }
     67