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

Commit 07ec93e0 authored by Christopher N. Hesse's avatar Christopher N. Hesse Committed by Arne Coucheron
Browse files

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
(cherry picked from commit c44c4c3555bc7eadb0f0d35cd082ed90ef5731e2)
Signed-off-by: default avatarAlex Naidis <alex.naidis@linux.com>
parent 173aeb5a
Loading
Loading
Loading
Loading
+14 −2
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,6 +72,11 @@ public class FaceDetect {
     * @return FaceInfo array if success, otherwise return null.
     */
    public FaceInfo[] dectectFeatures(Bitmap bmp) {
        // check if the initialization failed
        if (mHandle == 0) {
            return null;
        }

        int count = native_detect(mHandle, bmp);
        if (count < 1) {
            return null;