faceunlock: Prevent NPE in CameraService
03-30 22:59:30.191 1180 1416 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: FaceUnlockService
03-30 22:59:30.191 1180 1416 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.HandlerThread.quitSafely()' on a null object reference
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at com.libremobileos.faceunlock.server.CameraService.stopBackgroundThread(CameraService.java:124)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at com.libremobileos.faceunlock.server.FaceUnlockServer$1.lambda$cancel$1(FaceUnlockServer.java:198)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at com.libremobileos.faceunlock.server.FaceUnlockServer$1.$r8$lambda$GfAUAII6twpKpdUUA5p5-HnSTbA(Unknown Source:0)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at com.libremobileos.faceunlock.server.FaceUnlockServer$1$$ExternalSyntheticLambda2.run(Unknown Source:2)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
03-30 22:59:30.191 1180 1416 E AndroidRuntime: at com.android.server.ServiceThread.run(ServiceThread.java:44)
Change-Id: Ica6f0af262970ce63c70aea1766b2699af47db19
diff --git a/framework/server/com/libremobileos/faceunlock/server/CameraService.java b/framework/server/com/libremobileos/faceunlock/server/CameraService.java
index 1690907..0a4e4ae 100644
--- a/framework/server/com/libremobileos/faceunlock/server/CameraService.java
+++ b/framework/server/com/libremobileos/faceunlock/server/CameraService.java
@@ -121,6 +121,8 @@
public synchronized void stopBackgroundThread() {
closeCamera();
+ if (mBackgroundThread == null) return;
+
mBackgroundThread.quitSafely();
try {
mBackgroundThread.join();