From 6911cdad988bc9abdf32a34a5b3c60374dd4a9e4 Mon Sep 17 00:00:00 2001 From: Angus Kong Date: Fri, 13 Jul 2012 11:54:05 +0800 Subject: Add the method for hidden fields. bug:6698375 Change-Id: I5feb3fdd680fec0d745bd3176f4676c16484d4ed --- .../src/com/android/gallery3d/common/ApiHelper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gallerycommon') diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java index fd2488faf..753cacdf7 100644 --- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java +++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java @@ -25,6 +25,8 @@ import android.os.Build; import android.provider.MediaStore.MediaColumns; import android.view.View; +import java.lang.reflect.Field; + public class ApiHelper { public static interface VERSION_CODES { // These value are copied from Build.VERSION_CODES @@ -87,6 +89,19 @@ public class ApiHelper { public static final boolean HAS_GET_CAMERA_DISABLED = hasMethod(DevicePolicyManager.class, "getCameraDisabled", ComponentName.class); + public static final boolean HAS_MEDIA_ACTION_SOUND = + Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN; + + public static int getIntFieldIfExists(Class klass, String fieldName, + Class obj, int defaultVal) { + try { + Field f = klass.getDeclaredField(fieldName); + return f.getInt(obj); + } catch (Exception e) { + return defaultVal; + } + } + private static boolean hasField(Class klass, String fieldName) { try { klass.getDeclaredField(fieldName); -- cgit v1.2.3