summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-07-24 14:34:07 +0800
committerOwen Lin <owenlin@google.com>2012-07-24 14:34:07 +0800
commitd5bcc6bf262edfc2bc736e5ed1d636b30a1c44fe (patch)
tree7a427ca5d04a0a0b93ee261cddb765fce96b1b69 /gallerycommon/src
parent6332c9943afd4b708ab84a82023b3aaec900971c (diff)
downloadandroid_packages_apps_Snap-d5bcc6bf262edfc2bc736e5ed1d636b30a1c44fe.tar.gz
android_packages_apps_Snap-d5bcc6bf262edfc2bc736e5ed1d636b30a1c44fe.tar.bz2
android_packages_apps_Snap-d5bcc6bf262edfc2bc736e5ed1d636b30a1c44fe.zip
Avoid using class defined in API level 14.
Change-Id: Ia6385f98b048292de70c6e8aa628a2e6fc629485
Diffstat (limited to 'gallerycommon/src')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/ApiHelper.java33
1 files changed, 15 insertions, 18 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
index d586ca47f..2937ed2cd 100644
--- a/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
+++ b/gallerycommon/src/com/android/gallery3d/common/ApiHelper.java
@@ -20,7 +20,6 @@ import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.hardware.Camera;
-import android.hardware.Camera.FaceDetectionListener;
import android.os.Build;
import android.provider.MediaStore.MediaColumns;
import android.view.View;
@@ -82,12 +81,21 @@ public class ApiHelper {
public static final boolean HAS_SET_SYSTEM_UI_VISIBILITY =
hasMethod(View.class, "setSystemUiVisibility", int.class);
- public static final boolean HAS_FACE_DETECTION =
- hasClass(Camera.class, "android.hardware.Camera$FaceDetectionListener") &&
- hasMethod(Camera.class, "setFaceDetectionListener", FaceDetectionListener.class) &&
- hasMethod(Camera.class, "startFaceDetection") &&
- hasMethod(Camera.class, "stopFaceDetection") &&
- hasMethod(Camera.Parameters.class, "getMaxNumDetectedFaces");
+ public static final boolean HAS_FACE_DETECTION;
+ static {
+ boolean hasFaceDetection = false;
+ try {
+ Class<?> listenerClass = Class.forName(
+ "android.hardware.Camera$FaceDetectionListener");
+ hasFaceDetection =
+ hasMethod(Camera.class, "setFaceDetectionListener", listenerClass) &&
+ hasMethod(Camera.class, "startFaceDetection") &&
+ hasMethod(Camera.class, "stopFaceDetection") &&
+ hasMethod(Camera.Parameters.class, "getMaxNumDetectedFaces");
+ } catch (Throwable t) {
+ }
+ HAS_FACE_DETECTION = hasFaceDetection;
+ }
public static final boolean HAS_GET_CAMERA_DISABLED =
hasMethod(DevicePolicyManager.class, "getCameraDisabled", ComponentName.class);
@@ -146,15 +154,4 @@ public class ApiHelper {
return false;
}
}
-
- private static boolean hasClass(Class<?> klass, String className) {
- Class<?>[] klasses = klass.getClasses();
- for (int i = 0; i < klasses.length; ++i) {
- if (klasses[i].getName().equals(className)) {
- return true;
- }
- }
- return false;
- }
-
}