/** Stops Face Unlock and unbinds from the service. Called on the UI thread. */ public boolean stop() { if (DEBUG) Log.d(TAG, "stop()"); if (mHandler.getLooper() != Looper.myLooper()) { Log.e(TAG, "stop() called off of the UI thread"); } boolean mWasRunning = mIsRunning; stopUi(); if (mBoundToService) { if (mService != null) { try { mService.unregisterCallback(mFaceUnlockCallback); } catch (RemoteException e) { // Not much we can do } } Log.d(TAG, "Unbinding from Face Unlock service"); mContext.unbindService(mConnection); mBoundToService = false; } else { // This is usually not an error when this happens. Sometimes we will tell it to // unbind multiple times because it's called from both onWindowFocusChanged and // onDetachedFromWindow. if (DEBUG) Log.d(TAG, "Attempt to unbind from Face Unlock when not bound"); } mIsRunning = false; return mWasRunning; }
/** Frees up resources used by Face Unlock and stops it if it is still running. */ public void cleanUp() { if (DEBUG) Log.d(TAG, "cleanUp()"); if (mService != null) { try { mService.unregisterCallback(mFaceUnlockCallback); } catch (RemoteException e) { // Not much we can do } stopUi(); mService = null; } }