diff options
author | Christopher N. Hesse <raymanfx@gmail.com> | 2017-04-26 18:21:39 +0200 |
---|---|---|
committer | LuK1337 <priv.luk@gmail.com> | 2019-10-21 21:40:56 +0200 |
commit | 893a776ec8cdb0ac83692ee9b1dc329c11471cee (patch) | |
tree | 25f6c26ea9277ff0b0db016ad60538d9fff5dd1c | |
parent | e2b592d51e25f0cfda51d1814e259f138afcbfdd (diff) | |
download | android_packages_apps_Gallery2-893a776ec8cdb0ac83692ee9b1dc329c11471cee.tar.gz android_packages_apps_Gallery2-893a776ec8cdb0ac83692ee9b1dc329c11471cee.tar.bz2 android_packages_apps_Gallery2-893a776ec8cdb0ac83692ee9b1dc329c11471cee.zip |
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: Alex 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: Alex Naidis <alex.naidis@linux.com>
Change-Id: I0fdde6b24dd75916449dcf1c7f3504130d958026
-rw-r--r-- | src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java b/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java index 90ccc59dc..a37ca09bb 100644 --- a/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java +++ b/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java @@ -42,7 +42,12 @@ public class FaceDetect { * initialize method,MUST called at first time. */ public void initialize() { - mHandle = native_create(); + 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,7 +59,9 @@ public class FaceDetect { */ public void uninitialize() { - native_destroy(mHandle); + if (mHandle != 0) { + native_destroy(mHandle); + } } /** @@ -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; } |