Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 1 | /* |
Angus Kong | b50b5cb | 2013-08-09 14:55:20 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 The Android Open Source Project |
Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 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 | |
Angus Kong | b50b5cb | 2013-08-09 14:55:20 -0700 | [diff] [blame] | 17 | package com.android.camera.util; |
Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 18 | |
Owen Lin | 76bfd87 | 2012-06-27 19:01:21 +0800 | [diff] [blame] | 19 | import android.os.Build; |
Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 20 | |
Angus Kong | 708bfce | 2012-07-13 11:54:05 +0800 | [diff] [blame] | 21 | import java.lang.reflect.Field; |
| 22 | |
Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 23 | public class ApiHelper { |
Bobby Georgescu | 8f69397 | 2013-03-07 14:15:57 -0800 | [diff] [blame] | 24 | public static final boolean AT_LEAST_16 = Build.VERSION.SDK_INT >= 16; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 25 | |
Mangesh Ghiware | 5df64b0 | 2013-09-18 18:25:26 -0700 | [diff] [blame] | 26 | public static final boolean HAS_APP_GALLERY = |
| 27 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 28 | |
| 29 | public static final boolean HAS_ANNOUNCE_FOR_ACCESSIBILITY = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 30 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
Chih-Chung Chang | 9341cc2 | 2012-07-04 16:54:02 +0800 | [diff] [blame] | 31 | public static final boolean HAS_AUTO_FOCUS_MOVE_CALLBACK = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 32 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
Angus Kong | 708bfce | 2012-07-13 11:54:05 +0800 | [diff] [blame] | 33 | public static final boolean HAS_MEDIA_ACTION_SOUND = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 34 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 35 | public static final boolean HAS_MEDIA_COLUMNS_WIDTH_AND_HEIGHT = |
| 36 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
| 37 | public static final boolean HAS_SET_BEAM_PUSH_URIS = |
| 38 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
Angus Kong | fbf6dba | 2012-08-07 17:15:14 +0800 | [diff] [blame] | 39 | public static final boolean HAS_SURFACE_TEXTURE_RECORDING = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 40 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 41 | |
Sascha Haeberling | 9bf0fd6 | 2013-10-03 12:10:48 -0700 | [diff] [blame] | 42 | public static final boolean HAS_CAMERA_HDR_PLUS = isKitKatOrHigher(); |
Wu-cheng Li | ea1d1d2 | 2012-08-25 21:10:04 +0800 | [diff] [blame] | 43 | public static final boolean HAS_CAMERA_HDR = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 44 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 45 | public static final boolean HAS_DISPLAY_LISTENER = |
| 46 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; |
Michael Kolb | 6afdb17 | 2013-02-25 19:43:56 -0800 | [diff] [blame] | 47 | |
Michael Kolb | d1e0a6e | 2013-04-15 11:35:52 -0700 | [diff] [blame] | 48 | public static final boolean HAS_ORIENTATION_LOCK = |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 49 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; |
Mangesh Ghiware | a5682ab | 2013-09-19 09:24:23 -0700 | [diff] [blame] | 50 | public static final boolean HAS_ROTATION_ANIMATION = |
| 51 | Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2; |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 52 | |
| 53 | public static final boolean HAS_HIDEYBARS = isKitKatOrHigher(); |
Doris Liu | f479c0d | 2013-05-03 10:26:01 -0700 | [diff] [blame] | 54 | |
Wu-cheng Li | 36d16bc | 2012-08-21 15:05:17 +0800 | [diff] [blame] | 55 | public static int getIntFieldIfExists(Class<?> klass, String fieldName, |
| 56 | Class<?> obj, int defaultVal) { |
| 57 | try { |
| 58 | Field f = klass.getDeclaredField(fieldName); |
| 59 | return f.getInt(obj); |
| 60 | } catch (Exception e) { |
| 61 | return defaultVal; |
| 62 | } |
| 63 | } |
| 64 | |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 65 | public static boolean isKitKatOrHigher() { |
| 66 | // TODO: Remove CODENAME check as soon as VERSION_CODES.KITKAT is final. |
| 67 | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT |
| 68 | || "KeyLimePie".equals(Build.VERSION.CODENAME); |
Owen Lin | b4cadaf | 2012-07-04 15:48:59 +0800 | [diff] [blame] | 69 | } |
Owen Lin | 9199c4d | 2012-06-20 16:54:24 +0800 | [diff] [blame] | 70 | } |