Home | History | Annotate | Download | only in compat
      1 /*
      2  * Copyright (C) 2015 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.contacts.compat;
     18 
     19 import android.os.Build;
     20 import android.provider.ContactsContract.ProviderStatus;
     21 
     22 import com.android.contacts.common.compat.CompatUtils;
     23 import com.android.contacts.common.compat.SdkVersionOverride;
     24 
     25 /**
     26  * This class contains constants from the pre-M version of ContactsContract.ProviderStatus class
     27  * and also the mappings between pre-M constants and M constants for compatibility purpose,
     28  * because ProviderStatus class constant names and values changed and the class became visible in
     29  * API level 23.
     30  */
     31 public class ProviderStatusCompat {
     32     /**
     33      * Not instantiable.
     34      */
     35     private ProviderStatusCompat() {
     36     }
     37 
     38     public static final boolean USE_CURRENT_VERSION = CompatUtils.isMarshmallowCompatible();
     39 
     40     public static final int STATUS_EMPTY = USE_CURRENT_VERSION ?
     41             ProviderStatus.STATUS_EMPTY : ProviderStatusCompat.STATUS_NO_ACCOUNTS_NO_CONTACTS;
     42 
     43     public static final int STATUS_BUSY = USE_CURRENT_VERSION ?
     44             ProviderStatus.STATUS_BUSY : ProviderStatusCompat.STATUS_UPGRADING;
     45 
     46     /**
     47      * Default status of the provider, using the actual constant to guard against errors
     48      */
     49     public static final int STATUS_NORMAL = ProviderStatus.STATUS_NORMAL;
     50 
     51     /**
     52      * The following three constants are from pre-M.
     53      *
     54      * The status used when the provider is in the process of upgrading.  Contacts
     55      * are temporarily unaccessible.
     56      */
     57     private static final int STATUS_UPGRADING = 1;
     58 
     59     /**
     60      * The status used during a locale change.
     61      */
     62     public static final int STATUS_CHANGING_LOCALE = 3;
     63 
     64     /**
     65      * The status that indicates that there are no accounts and no contacts
     66      * on the device.
     67      */
     68     private static final int STATUS_NO_ACCOUNTS_NO_CONTACTS = 4;
     69 }
     70