diff --git a/app/src/main/java/net/sourceforge/opencamera/PropertyUtility.java b/app/src/main/java/net/sourceforge/opencamera/PropertyUtility.java new file mode 100644 index 0000000000000000000000000000000000000000..6037989d4dd8ff779fb2c657dfe287d81109c702 --- /dev/null +++ b/app/src/main/java/net/sourceforge/opencamera/PropertyUtility.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 E FOUNDATION + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.sourceforge.opencamera; + +import android.annotation.SuppressLint; +import android.util.Log; + +import androidx.annotation.Nullable; + +import java.lang.reflect.Method; + +public class PropertyUtility { + + private static final String TAG = PropertyUtility.class.getName(); + + /** + * Retrieve the property value from systemProperties + * @param key the property key + * @return value of the property, null if the value is not present + */ + @Nullable + public static String getProperty(String key) { + String value = null; + try { + @SuppressLint("PrivateApi") Class c = Class.forName("android.os.SystemProperties"); + Method get = c.getMethod("get", String.class); + + value = (String) get.invoke(c, key); + + } catch (Exception e) { + Log.e(TAG, e.getMessage()); + } + + return value; + } + + private PropertyUtility() { + } +} diff --git a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java index 380a35cb692d50daba14dbad5fb6c6c40b2f09d2..04ef327e644d7bd2aa0d56ca9c0c2fc868e32719 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java @@ -1,6 +1,7 @@ package net.sourceforge.opencamera.preview; import net.sourceforge.opencamera.MainActivity; +import net.sourceforge.opencamera.PropertyUtility; import net.sourceforge.opencamera.cameracontroller.RawImage; import net.sourceforge.opencamera.MyDebug; @@ -1470,7 +1471,10 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu //final boolean use_background_thread = false; //final boolean use_background_thread = true; - final boolean use_background_thread = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; + boolean use_background_thread = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; + if ("true".equalsIgnoreCase(PropertyUtility.getProperty("camera.load.sync"))) { + use_background_thread = true; + } /* Opening camera on background thread is important so that we don't block the UI thread: * - For old Camera API, this is recommended behaviour by Google for Camera.open(). - For Camera2, the manager.openCamera() call is asynchronous, but CameraController2