summaryrefslogtreecommitdiffstats
path: root/camera2/portability/src/com/android/ex/camera2/portability/util
diff options
context:
space:
mode:
authorSol Boucher <solb@google.com>2014-08-04 23:42:50 -0700
committerSol Boucher <solb@google.com>2014-08-15 15:57:44 -0700
commit50f5b019ba3f333a09a1beb9667fd7290082dc31 (patch)
treef5286250ee22217fe1758003aed319125e746ad4 /camera2/portability/src/com/android/ex/camera2/portability/util
parentd4e5286bb4145e0371b783158fc8411565429c9b (diff)
downloadandroid_frameworks_ex-50f5b019ba3f333a09a1beb9667fd7290082dc31.tar.gz
android_frameworks_ex-50f5b019ba3f333a09a1beb9667fd7290082dc31.tar.bz2
android_frameworks_ex-50f5b019ba3f333a09a1beb9667fd7290082dc31.zip
camera2-portability: Make factory offer choice of backing API
This allows apps using the library to decide whether to jump to the new API. Users of the library may choose to use the Camera class, the camera2 API, or have the choice made automatically based on the device's API level. The choice may also be globally overridden by means of a system property. Bug: 16875535 Change-Id: I92e4be96fbd04057be61ceb8a0c58935770022f6
Diffstat (limited to 'camera2/portability/src/com/android/ex/camera2/portability/util')
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/util/SystemProperties.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/util/SystemProperties.java b/camera2/portability/src/com/android/ex/camera2/portability/util/SystemProperties.java
new file mode 100644
index 0000000..81493f3
--- /dev/null
+++ b/camera2/portability/src/com/android/ex/camera2/portability/util/SystemProperties.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ex.camera2.portability.util;
+
+import com.android.ex.camera2.portability.debug.Log;
+
+import java.lang.reflect.Method;
+
+/**
+ * Mirrors hidden class {@link android.os.SystemProperties} (available since API Level 1).
+ */
+public final class SystemProperties {
+ private static final Log.Tag TAG = new Log.Tag("SysProps");
+
+ /**
+ * Gets system properties set by <code>adb shell setprop <em>key</em> <em>value</em></code>
+ *
+ * @param key the property key.
+ * @param defaultValue the value to return if the property is undefined or empty (this parameter
+ * may be {@code null}).
+ * @return the system property value or the default value.
+ */
+ public static String get(String key, String defaultValue) {
+ try {
+ final Class<?> systemProperties = Class.forName("android.os.SystemProperties");
+ final Method get = systemProperties.getMethod("get", String.class, String.class);
+ return (String) get.invoke(null, key, defaultValue);
+ } catch (Exception e) {
+ // This should never happen
+ Log.e(TAG, "Exception while getting system property: ", e);
+ return defaultValue;
+ }
+ }
+
+ private SystemProperties() {
+ }
+}