Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 529d949b authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

5555-Camera_not_working_on_fp3

issue: e/backlog#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
parent c1dca1ca
Loading
Loading
Loading
Loading
+53 −0
Original line number Original line Diff line number Diff line
/*
 * 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 <https://www.gnu.org/licenses/>.
 */

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() {
    }
}
+5 −1
Original line number Original line Diff line number Diff line
package net.sourceforge.opencamera.preview;
package net.sourceforge.opencamera.preview;


import net.sourceforge.opencamera.MainActivity;
import net.sourceforge.opencamera.MainActivity;
import net.sourceforge.opencamera.PropertyUtility;
import net.sourceforge.opencamera.cameracontroller.RawImage;
import net.sourceforge.opencamera.cameracontroller.RawImage;
import net.sourceforge.opencamera.MyDebug;
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 = false;
        //final boolean use_background_thread = true;
        //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:
		/* 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 old Camera API, this is recommended behaviour by Google for Camera.open().
		     - For Camera2, the manager.openCamera() call is asynchronous, but CameraController2
		     - For Camera2, the manager.openCamera() call is asynchronous, but CameraController2