FaceUnlock.java revision 667b5d58b9e8b77221c87811c5c9aab1bfe44ffa
19431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna/* 2dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller * Copyright (C) 2012 The Android Open Source Project 39431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * 49431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * Licensed under the Apache License, Version 2.0 (the "License"); 59431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * you may not use this file except in compliance with the License. 69431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * You may obtain a copy of the License at 79431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * 89431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * http://www.apache.org/licenses/LICENSE-2.0 99431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * 109431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * Unless required by applicable law or agreed to in writing, software 119431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * distributed under the License is distributed on an "AS IS" BASIS, 129431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * See the License for the specific language governing permissions and 149431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna * limitations under the License. 159431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna */ 169431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 17dcb3d84b82cc2448d04e73359a716581bfb657dbJim Millerpackage com.android.internal.policy.impl.keyguard; 189431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 199431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport com.android.internal.policy.IFaceLockCallback; 209431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport com.android.internal.policy.IFaceLockInterface; 219431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport com.android.internal.widget.LockPatternUtils; 229431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 233223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonnaimport android.app.admin.DevicePolicyManager; 249431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.content.ComponentName; 259431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.content.Context; 269431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.content.Intent; 279431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.content.ServiceConnection; 289431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.os.Handler; 299431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.os.IBinder; 3022001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonnaimport android.os.Looper; 319431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.os.Message; 32acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Rossimport android.os.PowerManager; 339431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.os.RemoteException; 349431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.util.Log; 359431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonnaimport android.view.View; 369431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 373223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonnapublic class FaceUnlock implements BiometricSensorUnlock, Handler.Callback { 389431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 399431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private static final boolean DEBUG = false; 409431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private static final String TAG = "FULLockscreen"; 419431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 429431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private final Context mContext; 43ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna private final LockPatternUtils mLockPatternUtils; 449431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 45ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // TODO: is mServiceRunning needed or can we just use mIsRunning or check if mService is null? 46ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna private boolean mServiceRunning = false; 47257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // TODO: now that the code has been restructure to do almost all operations from a handler, this 48257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // lock may no longer be necessary. 49ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna private final Object mServiceRunningLock = new Object(); 509431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private IFaceLockInterface mService; 519431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private boolean mBoundToService = false; 52ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna private View mFaceUnlockView; 539431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 549431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private Handler mHandler; 5561413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett private final int MSG_SERVICE_CONNECTED = 0; 5661413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett private final int MSG_SERVICE_DISCONNECTED = 1; 5761413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett private final int MSG_UNLOCK = 2; 5861413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett private final int MSG_CANCEL = 3; 5961413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett private final int MSG_REPORT_FAILED_ATTEMPT = 4; 60667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna private final int MSG_POKE_WAKELOCK = 5; 619431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 62ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // TODO: This was added for the purpose of adhering to what the biometric interface expects 63ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // the isRunning() function to return. However, it is probably not necessary to have both 64ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // mRunning and mServiceRunning. I'd just rather wait to change that logic. 65257f2ecc97d294e95b069547466d2054926d960fBrian Colonna private volatile boolean mIsRunning = false; 669431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 67ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // So the user has a consistent amount of time when brought to the backup method from Face 68ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // Unlock 699431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private final int BACKUP_LOCK_TIMEOUT = 5000; 709431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 71dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller KeyguardSecurityCallback mKeyguardScreenCallback; 729431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 73257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 74257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Stores some of the structures that Face Unlock will need to access and creates the handler 75257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * will be used to execute messages on the UI thread. 76257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 77000464ac012471d301c6e48a8228291519915e17Jim Miller public FaceUnlock(Context context) { 789431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna mContext = context; 79dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller mLockPatternUtils = new LockPatternUtils(context); 809431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna mHandler = new Handler(this); 819431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 829431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 83000464ac012471d301c6e48a8228291519915e17Jim Miller public void setKeyguardCallback(KeyguardSecurityCallback keyguardScreenCallback) { 84000464ac012471d301c6e48a8228291519915e17Jim Miller mKeyguardScreenCallback = keyguardScreenCallback; 85000464ac012471d301c6e48a8228291519915e17Jim Miller } 86000464ac012471d301c6e48a8228291519915e17Jim Miller 87ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 88ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * Stores and displays the view that Face Unlock is allowed to draw within. 89ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * TODO: since the layout object will eventually be shared by multiple biometric unlock 90ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * methods, we will have to add our other views (background, cancel button) here. 91ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 92ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna public void initializeView(View biometricUnlockView) { 93257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.d(TAG, "initializeView()"); 94ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mFaceUnlockView = biometricUnlockView; 95ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna } 96ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna 97ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 98ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * Indicates whether Face Unlock is currently running. 99ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 1003223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna public boolean isRunning() { 101ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna return mIsRunning; 1023223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } 1033223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna 104ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 10561413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett * Dismisses face unlock and goes to the backup lock 106ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 10761413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett public void stopAndShowBackup() { 10861413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett if (DEBUG) Log.d(TAG, "stopAndShowBackup()"); 10961413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett mHandler.sendEmptyMessage(MSG_CANCEL); 1103223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } 1113223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna 112ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 113ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * Binds to the Face Unlock service. Face Unlock will be started when the bind completes. The 114257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Face Unlock view is displayed to hide the backup lock while the service is starting up. 11522001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna * Called on the UI thread. 116ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 117ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna public boolean start() { 118257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "start()"); 11922001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna if (mHandler.getLooper() != Looper.myLooper()) { 12022001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna Log.e(TAG, "start() called off of the UI thread"); 12122001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna } 12222001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna 123ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (mIsRunning) { 124ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna Log.w(TAG, "start() called when already running"); 125ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna } 126ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna 127ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (!mBoundToService) { 1284b4b954ddf34af51576441f0e3eca6d19150aadaAmith Yamasani Log.d(TAG, "Binding to Face Unlock service for user=" 1294b4b954ddf34af51576441f0e3eca6d19150aadaAmith Yamasani + mLockPatternUtils.getCurrentUser()); 130ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mContext.bindService(new Intent(IFaceLockInterface.class.getName()), 131ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mConnection, 132ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna Context.BIND_AUTO_CREATE, 133ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mLockPatternUtils.getCurrentUser()); 134ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mBoundToService = true; 135ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna } else { 136ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna Log.w(TAG, "Attempt to bind to Face Unlock when already bound"); 137ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna } 138ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna 139ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mIsRunning = true; 140ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna return true; 141ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna } 142ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna 143ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 14422001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna * Stops Face Unlock and unbinds from the service. Called on the UI thread. 145ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 1463223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna public boolean stop() { 147257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "stop()"); 14822001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna if (mHandler.getLooper() != Looper.myLooper()) { 149a71984f3da47c6e6e3164c170735362a3222d3adJim Miller Log.e(TAG, "stop() called from non-UI thread"); 15022001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna } 15122001c1f96984655f7205ecbc93dd982c47b4e97Brian Colonna 152ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna boolean mWasRunning = mIsRunning; 1531108a2cb412b054cc9e4acc48182c46c45180c0cDanielle Millett 154c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna stopUi(); 155c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna 156c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna if (mBoundToService) { 157c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna if (mService != null) { 158c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna try { 159ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mService.unregisterCallback(mFaceUnlockCallback); 160c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna } catch (RemoteException e) { 161c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna // Not much we can do 1623223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } 1639431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 164257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.d(TAG, "Unbinding from Face Unlock service"); 165c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna mContext.unbindService(mConnection); 166c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna mBoundToService = false; 167c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna } else { 168c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna // This is usually not an error when this happens. Sometimes we will tell it to 169c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna // unbind multiple times because it's called from both onWindowFocusChanged and 170c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna // onDetachedFromWindow. 171ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (DEBUG) Log.d(TAG, "Attempt to unbind from Face Unlock when not bound"); 1729431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 173ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mIsRunning = false; 174ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna return mWasRunning; 1759431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 1769431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 1773223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna /** 178ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * Frees up resources used by Face Unlock and stops it if it is still running. 1793223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna */ 1803223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna public void cleanUp() { 181257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "cleanUp()"); 1823223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna if (mService != null) { 1833223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna try { 184ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna mService.unregisterCallback(mFaceUnlockCallback); 1853223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } catch (RemoteException e) { 1863223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna // Not much we can do 1873223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } 1883223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna stopUi(); 1893223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna mService = null; 1909431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 1913223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna } 1923223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna 193ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 194ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna * Returns the Device Policy Manager quality for Face Unlock, which is BIOMETRIC_WEAK. 195ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 1963223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna public int getQuality() { 1973223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna return DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK; 1989431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 1999431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 200ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 201257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Handles messages such that everything happens on the UI thread in a deterministic order. 202257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Calls from the Face Unlock service come from binder threads. Calls from lockscreen typically 203257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * come from the UI thread. This makes sure there are no race conditions between those calls. 204ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 2059431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public boolean handleMessage(Message msg) { 2069431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna switch (msg.what) { 207257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_SERVICE_CONNECTED: 208257f2ecc97d294e95b069547466d2054926d960fBrian Colonna handleServiceConnected(); 209257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 210257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_SERVICE_DISCONNECTED: 211257f2ecc97d294e95b069547466d2054926d960fBrian Colonna handleServiceDisconnected(); 212257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 213257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_UNLOCK: 214257f2ecc97d294e95b069547466d2054926d960fBrian Colonna handleUnlock(); 215257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 216257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_CANCEL: 217257f2ecc97d294e95b069547466d2054926d960fBrian Colonna handleCancel(); 218257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 219257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_REPORT_FAILED_ATTEMPT: 220257f2ecc97d294e95b069547466d2054926d960fBrian Colonna handleReportFailedAttempt(); 221257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 222257f2ecc97d294e95b069547466d2054926d960fBrian Colonna case MSG_POKE_WAKELOCK: 223dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez handlePokeWakelock(msg.arg1); 224257f2ecc97d294e95b069547466d2054926d960fBrian Colonna break; 225257f2ecc97d294e95b069547466d2054926d960fBrian Colonna default: 226257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.e(TAG, "Unhandled message"); 227257f2ecc97d294e95b069547466d2054926d960fBrian Colonna return false; 2289431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 2299431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna return true; 2309431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 2319431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 232ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 233257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Tells the service to start its UI via an AIDL interface. Called when the 234257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * onServiceConnected() callback is received. 235257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 236257f2ecc97d294e95b069547466d2054926d960fBrian Colonna void handleServiceConnected() { 237c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna Log.d(TAG, "handleServiceConnected()"); 238c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna 239c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna // It is possible that an unbind has occurred in the time between the bind and when this 240c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna // function is reached. If an unbind has already occurred, proceeding on to call startUi() 241c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna // can result in a fatal error. Note that the onServiceConnected() callback is 242c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna // asynchronous, so this possibility would still exist if we executed this directly in 243c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna // onServiceConnected() rather than using a handler. 244c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna if (!mBoundToService) { 245c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna Log.d(TAG, "Dropping startUi() in handleServiceConnected() because no longer bound"); 246c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna return; 247c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna } 248c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna 249257f2ecc97d294e95b069547466d2054926d960fBrian Colonna try { 250257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mService.registerCallback(mFaceUnlockCallback); 251257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } catch (RemoteException e) { 252257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.e(TAG, "Caught exception connecting to Face Unlock: " + e.toString()); 253257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mService = null; 254257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mBoundToService = false; 255257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mIsRunning = false; 256257f2ecc97d294e95b069547466d2054926d960fBrian Colonna return; 257257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 258257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 259257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (mFaceUnlockView != null) { 260257f2ecc97d294e95b069547466d2054926d960fBrian Colonna IBinder windowToken = mFaceUnlockView.getWindowToken(); 261257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (windowToken != null) { 262dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez // When switching between portrait and landscape view while Face Unlock is running, 263dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez // the screen will eventually go dark unless we poke the wakelock when Face Unlock 264dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez // is restarted. 265dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller mKeyguardScreenCallback.userActivity(0); 266dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez 267257f2ecc97d294e95b069547466d2054926d960fBrian Colonna int[] position; 268257f2ecc97d294e95b069547466d2054926d960fBrian Colonna position = new int[2]; 269257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mFaceUnlockView.getLocationInWindow(position); 270257f2ecc97d294e95b069547466d2054926d960fBrian Colonna startUi(windowToken, position[0], position[1], mFaceUnlockView.getWidth(), 271257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mFaceUnlockView.getHeight()); 272257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } else { 273257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.e(TAG, "windowToken is null in handleServiceConnected()"); 274257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 275257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 276257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 277257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 278257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 279257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Called when the onServiceDisconnected() callback is received. This should not happen during 280257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * normal operation. It indicates an error has occurred. 281257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 282257f2ecc97d294e95b069547466d2054926d960fBrian Colonna void handleServiceDisconnected() { 283257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.e(TAG, "handleServiceDisconnected()"); 284257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // TODO: this lock may no longer be needed now that everything is being called from a 285257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // handler 286257f2ecc97d294e95b069547466d2054926d960fBrian Colonna synchronized (mServiceRunningLock) { 287257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mService = null; 288257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mServiceRunning = false; 289257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 290257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mBoundToService = false; 291257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mIsRunning = false; 292257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 293257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 294257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 29561413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett * Stops the Face Unlock service and tells the device to grant access to the user. 296257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 297257f2ecc97d294e95b069547466d2054926d960fBrian Colonna void handleUnlock() { 298257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "handleUnlock()"); 299257f2ecc97d294e95b069547466d2054926d960fBrian Colonna stop(); 300257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mKeyguardScreenCallback.reportSuccessfulUnlockAttempt(); 301dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller mKeyguardScreenCallback.dismiss(true); 302257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 303257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 304257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 30561413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett * Stops the Face Unlock service and goes to the backup lock. 306257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 307257f2ecc97d294e95b069547466d2054926d960fBrian Colonna void handleCancel() { 308257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "handleCancel()"); 309667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna // We are going to the backup method, so we don't want to see Face Unlock again until the 310667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna // next time the user visits keyguard. 311667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(false); 312667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna 31361413b5ed215accd7b4f3eaf80edeab2f330aa49Danielle Millett mKeyguardScreenCallback.showBackupSecurity(); 314257f2ecc97d294e95b069547466d2054926d960fBrian Colonna stop(); 315dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller mKeyguardScreenCallback.userActivity(BACKUP_LOCK_TIMEOUT); 316257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 317257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 318257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 3197019325e183ba1abf1869ccffc4b1ecd8c771a44Brian Colonna * Increments the number of failed Face Unlock attempts. 320257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 321257f2ecc97d294e95b069547466d2054926d960fBrian Colonna void handleReportFailedAttempt() { 322257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "handleReportFailedAttempt()"); 323667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna // We are going to the backup method, so we don't want to see Face Unlock again until the 324667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna // next time the user visits keyguard. 325667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(false); 326257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 327667b5d58b9e8b77221c87811c5c9aab1bfe44ffaBrian Colonna mKeyguardScreenCallback.reportFailedUnlockAttempt(); 328257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 329257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 330257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 331acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Ross * If the screen is on, pokes the wakelock to keep the screen alive and active for a specific 332acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Ross * amount of time. 333257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 334dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez void handlePokeWakelock(int millis) { 335acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Ross PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); 336acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Ross if (powerManager.isScreenOn()) { 337dcb3d84b82cc2448d04e73359a716581bfb657dbJim Miller mKeyguardScreenCallback.userActivity(millis); 338acbe41fc1316cf16f03de80c84ea311cc4f55ffbSteven Ross } 339257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } 340257f2ecc97d294e95b069547466d2054926d960fBrian Colonna 341257f2ecc97d294e95b069547466d2054926d960fBrian Colonna /** 342257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Implements service connection methods. 343257f2ecc97d294e95b069547466d2054926d960fBrian Colonna */ 3449431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna private ServiceConnection mConnection = new ServiceConnection() { 345ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 346257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Called when the Face Unlock service connects after calling bind(). 347ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 3489431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public void onServiceConnected(ComponentName className, IBinder iservice) { 349257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.d(TAG, "Connected to Face Unlock service"); 3509431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna mService = IFaceLockInterface.Stub.asInterface(iservice); 351257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mHandler.sendEmptyMessage(MSG_SERVICE_CONNECTED); 3529431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 3539431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 354ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 355257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Called if the Face Unlock service unexpectedly disconnects. This indicates an error. 356ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 3579431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public void onServiceDisconnected(ComponentName className) { 358257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.e(TAG, "Unexpected disconnect from Face Unlock service"); 359257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mHandler.sendEmptyMessage(MSG_SERVICE_DISCONNECTED); 3609431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 3619431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna }; 3629431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 363ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 364257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Tells the Face Unlock service to start displaying its UI and start processing. 365ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 3663223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna private void startUi(IBinder windowToken, int x, int y, int w, int h) { 367c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna if (DEBUG) Log.d(TAG, "startUi()"); 368c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna synchronized (mServiceRunningLock) { 369c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna if (!mServiceRunning) { 370c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna Log.d(TAG, "Starting Face Unlock"); 371c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna try { 3724fa995a932d876b98c393c909c4eb2e303783e59Uriel Rodriguez mService.startUi(windowToken, x, y, w, h, 3734fa995a932d876b98c393c909c4eb2e303783e59Uriel Rodriguez mLockPatternUtils.isBiometricWeakLivelinessEnabled()); 374c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna } catch (RemoteException e) { 375ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna Log.e(TAG, "Caught exception starting Face Unlock: " + e.toString()); 376c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna return; 3779431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 378c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna mServiceRunning = true; 379c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna } else { 380257f2ecc97d294e95b069547466d2054926d960fBrian Colonna Log.w(TAG, "startUi() attempted while running"); 3819431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 3829431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 3839431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 3849431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 385ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 386257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Tells the Face Unlock service to stop displaying its UI and stop processing. 387ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 3883223e2537d5f4e2eceeb321405dbd6da50df66b6Brian Colonna private void stopUi() { 389257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "stopUi()"); 390ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // Note that attempting to stop Face Unlock when it's not running is not an issue. 391ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna // Face Unlock can return, which stops it and then we try to stop it when the 392c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna // screen is turned off. That's why we check. 393c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna synchronized (mServiceRunningLock) { 394c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna if (mServiceRunning) { 395c266070aec3d99c9a4d422325fbceae44c37a4d3Brian Colonna Log.d(TAG, "Stopping Face Unlock"); 396c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna try { 397c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna mService.stopUi(); 398c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna } catch (RemoteException e) { 399ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna Log.e(TAG, "Caught exception stopping Face Unlock: " + e.toString()); 4009431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 401c169366f2cc44fc395dba76c763505ac2bd61640Brian Colonna mServiceRunning = false; 402257f2ecc97d294e95b069547466d2054926d960fBrian Colonna } else { 403257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // This is usually not an error when this happens. Sometimes we will tell it to 404257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // stop multiple times because it's called from both onWindowFocusChanged and 405257f2ecc97d294e95b069547466d2054926d960fBrian Colonna // onDetachedFromWindow. 406257f2ecc97d294e95b069547466d2054926d960fBrian Colonna if (DEBUG) Log.d(TAG, "stopUi() attempted while not running"); 4079431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4089431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4099431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4109431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 411ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 412257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Implements the AIDL biometric unlock service callback interface. 413ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 414ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna private final IFaceLockCallback mFaceUnlockCallback = new IFaceLockCallback.Stub() { 415ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 416257f2ecc97d294e95b069547466d2054926d960fBrian Colonna * Called when Face Unlock wants to grant access to the user. 417ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 4189431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public void unlock() { 419ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (DEBUG) Log.d(TAG, "unlock()"); 420257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mHandler.sendEmptyMessage(MSG_UNLOCK); 4219431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4229431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 423ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 4247019325e183ba1abf1869ccffc4b1ecd8c771a44Brian Colonna * Called when Face Unlock wants to go to the backup. 425ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 4269431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public void cancel() { 427ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (DEBUG) Log.d(TAG, "cancel()"); 428257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mHandler.sendEmptyMessage(MSG_CANCEL); 4299431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4309431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 431ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 4327019325e183ba1abf1869ccffc4b1ecd8c771a44Brian Colonna * Called when Face Unlock wants to increment the number of failed attempts. 433ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 4349431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna public void reportFailedAttempt() { 435ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna if (DEBUG) Log.d(TAG, "reportFailedAttempt()"); 436257f2ecc97d294e95b069547466d2054926d960fBrian Colonna mHandler.sendEmptyMessage(MSG_REPORT_FAILED_ATTEMPT); 4379431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 4389431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna 439ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna /** 440dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez * Called when Face Unlock wants to keep the screen alive and active for a specific amount 441dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez * of time. 442ea8441e22a4316cb6e78dd8bf461d3e658545b64Brian Colonna */ 443dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez public void pokeWakelock(int millis) { 444dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez if (DEBUG) Log.d(TAG, "pokeWakelock() for " + millis + "ms"); 445dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez Message message = mHandler.obtainMessage(MSG_POKE_WAKELOCK, millis, -1); 446dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez mHandler.sendMessage(message); 4479431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna } 448dff307697d7a7482efe4c10cb3b07b9249524a42Uriel Rodriguez 4499431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna }; 4509431366ecb4b6e4a87c0047c36548aa0bc23f2b1Brian Colonna} 451