1/*
2 * Copyright (C) 2016 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
17package android.support.v4.os;
18
19import android.os.Build.VERSION;
20
21/**
22 * This class contains additional platform version checking methods for targeting pre-release
23 * versions of Android.
24 */
25public class BuildCompat {
26    private BuildCompat() {
27    }
28
29    /**
30     * Checks if the device is running on the Android N release or newer.
31     *
32     * @return {@code true} if N APIs are available for use
33     * @deprecated Android N is a finalized release and this method is no longer necessary. It will
34     *             be removed in a future release of the Support Library. Instead, use
35     *             {@code Build.SDK_INT >= Build.VERSION_CODES#N}.
36     */
37    @Deprecated
38    public static boolean isAtLeastN() {
39        return VERSION.SDK_INT >= 24;
40    }
41
42    /**
43     * Checks if the device is running on the Android N MR1 release or newer.
44     *
45     * @return {@code true} if N MR1 APIs are available for use
46     * @deprecated Android N MR1 is a finalized release and this method is no longer necessary. It
47     *             will be removed in a future release of the Support Library. Instead, use
48     *             {@code Build.SDK_INT >= Build.VERSION_CODES#N_MR1}.
49     */
50    @Deprecated
51    public static boolean isAtLeastNMR1() {
52        return VERSION.SDK_INT >= 25;
53    }
54
55    /**
56     * Checks if the device is running on a pre-release version of Android O or newer.
57     * <p>
58     * @return {@code true} if O APIs are available for use, {@code false} otherwise
59     * @deprecated Android O is a finalized release and this method is no longer necessary. It will
60     *             be removed in a future release of the Support Library. Instead use
61     *             {@code Build.SDK_INT >= Build.VERSION_CODES#O}.
62     */
63    @Deprecated
64    public static boolean isAtLeastO() {
65        return VERSION.SDK_INT >= 26;
66    }
67
68    /**
69     * Checks if the device is running on a pre-release version of Android O MR1 or newer.
70     * <p>
71     * @return {@code true} if O MR1 APIs are available for use, {@code false} otherwise
72     * @deprecated Android O MR1 is a finalized release and this method is no longer necessary. It
73     *             will be removed in a future release of the Support Library. Instead, use
74     *             {@code Build.SDK_INT >= Build.VERSION_CODES#O_MR1}.
75     */
76    @Deprecated
77    public static boolean isAtLeastOMR1() {
78        return VERSION.SDK_INT >= 27;
79    }
80
81    /**
82     * Checks if the device is running on a pre-release version of Android P or newer.
83     * <p>
84     * <strong>Note:</strong> This method will return {@code false} on devices running release
85     * versions of Android. When Android P is finalized for release, this method will be deprecated
86     * and all calls should be replaced with {@code Build.SDK_INT >= Build.VERSION_CODES#P}.
87     *
88     * @return {@code true} if P APIs are available for use, {@code false} otherwise
89     */
90    public static boolean isAtLeastP() {
91        return VERSION.CODENAME.equals("P");
92    }
93}
94