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