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

Commit 893a776e authored by Christopher N. Hesse's avatar Christopher N. Hesse Committed by LuK1337
Browse files

FaceDetect: Catch linker errors during initialization



Author: Christopher N. Hesse <raymanfx@gmail.com>
Date:   Wed Apr 26 18:21:39 2017 +0200

    FaceDetect: Catch linker errors during initialization

    Right now we only check if we can load the native
    functions from the JNI, but unsatisfied linker errors
    can still occur even if the lib is present.

    Change-Id: Id2ac36374eb8341b278949d120dc7674d6d62691
    Signed-off-by: default avatarAlex Naidis <alex.naidis@linux.com>

Author: Anas Karbila <anaskarbila@gmail.com>
Date:   Wed May 17 00:24:01 2017 +0900

    FaceDetect: Catch more linker errors during initialization

    Change-Id: I24d6afe0d3ba625aa8f6d42d9755a4553bad693d
    Signed-off-by: default avatarAlex Naidis <alex.naidis@linux.com>

Change-Id: I0fdde6b24dd75916449dcf1c7f3504130d958026
parent e2b592d5
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -42,7 +42,12 @@ public class FaceDetect {
     * initialize method,MUST called at first time.
     */
    public void initialize() {
        try {
            mHandle = native_create();
        } catch (UnsatisfiedLinkError e) {
            e.printStackTrace();
            Log.e(TAG, "could not link native handle for ts_detected_face_jni library!");
        }
    }

    public boolean isLibLoaded() {
@@ -54,8 +59,10 @@ public class FaceDetect {
     */

    public void uninitialize() {
        if (mHandle != 0) {
            native_destroy(mHandle);
        }
    }

    /**
     * dectectFeatures method,MUST called after initialize method and before
@@ -65,7 +72,18 @@ public class FaceDetect {
     * @return FaceInfo array if success, otherwise return null.
     */
    public FaceInfo[] dectectFeatures(Bitmap bmp) {
        int count = native_detect(mHandle, bmp);
        // check if the initialization failed
        if (mHandle == 0) {
            return null;
        }

        int count = 0;
        try {
            count = native_detect(mHandle, bmp);
        } catch (UnsatisfiedLinkError e) {
            e.printStackTrace();
            Log.e(TAG, "could not link native handle for ts_detected_face_jni library!");
        }
        if (count < 1) {
            return null;
        }