From 62fab425c13a88f286c6b21be4b23d0bca6d1540 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 13 Jun 2022 11:28:00 +0600 Subject: [PATCH 1/2] WIP: 5555-Camera_not_working_on_fp3 test with sync camera initialization --- .../main/java/net/sourceforge/opencamera/preview/Preview.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 380a35cb6..f8be36bb0 100644 --- a/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java +++ b/app/src/main/java/net/sourceforge/opencamera/preview/Preview.java @@ -1470,7 +1470,7 @@ 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; + final boolean use_background_thread = false;//Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; /* 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 -- GitLab From 5ed9e1f7c5d21eada1f635aa7a8c3874f74bb059 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 20 Jun 2022 12:14:04 +0600 Subject: [PATCH 2/2] 5555-Camera_not_working_on_fp3 issue: https://gitlab.e.foundation/e/backlog/-/issues/5555 Camera app has loading issue for fp3-q build devices. This issue seems to resolved when loading cameraController in mainThread. This commit read the `camera.load.sync` property from system. If it present & true then it will load camera in the main thread. This property will be set in the https://gitlab.e.foundation/e/devices/android_device_fairphone_FP3/-/blob/v1-q/system.prop --- .../opencamera/PropertyUtility.java | 53 +++++++++++++++++++ .../opencamera/preview/Preview.java | 6 ++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/net/sourceforge/opencamera/PropertyUtility.java 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 000000000..6037989d4 --- /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 f8be36bb0..04ef327e6 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 = false;//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 -- GitLab