Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Kevin Chyn | 2ffadb3 | 2018-06-19 11:29:38 -0700 | [diff] [blame] | 17 | package com.android.server.biometrics.face; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 18 | |
| 19 | import static android.Manifest.permission.INTERACT_ACROSS_USERS; |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 20 | import static android.Manifest.permission.MANAGE_BIOMETRIC; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 21 | import static android.Manifest.permission.RESET_FACE_LOCKOUT; |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 22 | import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 23 | |
| 24 | import android.app.ActivityManager; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 25 | import android.app.AppOpsManager; |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 26 | import android.app.Notification; |
| 27 | import android.app.NotificationChannel; |
| 28 | import android.app.NotificationManager; |
| 29 | import android.app.PendingIntent; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 30 | import android.content.Context; |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 31 | import android.content.Intent; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 32 | import android.content.pm.UserInfo; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 33 | import android.hardware.biometrics.BiometricAuthenticator; |
| 34 | import android.hardware.biometrics.BiometricConstants; |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 35 | import android.hardware.biometrics.BiometricsProtoEnums; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 36 | import android.hardware.biometrics.IBiometricServiceLockoutResetCallback; |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 37 | import android.hardware.biometrics.IBiometricServiceReceiverInternal; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 38 | import android.hardware.biometrics.face.V1_0.IBiometricsFace; |
| 39 | import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback; |
Kevin Chyn | b95f152 | 2019-03-04 16:45:15 -0800 | [diff] [blame] | 40 | import android.hardware.biometrics.face.V1_0.OptionalBool; |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 41 | import android.hardware.biometrics.face.V1_0.Status; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 42 | import android.hardware.face.Face; |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 43 | import android.hardware.face.FaceManager; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 44 | import android.hardware.face.IFaceService; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 45 | import android.hardware.face.IFaceServiceReceiver; |
| 46 | import android.os.Binder; |
Joe Onorato | bf955d2 | 2019-03-25 00:16:58 -0700 | [diff] [blame] | 47 | import android.os.Build; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 48 | import android.os.Environment; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 49 | import android.os.IBinder; |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 50 | import android.os.NativeHandle; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 51 | import android.os.RemoteException; |
| 52 | import android.os.SELinux; |
Joe Onorato | 108413a | 2019-04-03 18:20:52 -0700 | [diff] [blame] | 53 | import android.os.SystemProperties; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 54 | import android.os.UserHandle; |
| 55 | import android.os.UserManager; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 56 | import android.util.Slog; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 57 | |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 58 | import com.android.internal.R; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 59 | import com.android.internal.annotations.GuardedBy; |
| 60 | import com.android.internal.logging.MetricsLogger; |
| 61 | import com.android.internal.util.DumpUtils; |
| 62 | import com.android.server.SystemServerInitThreadPool; |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 63 | import com.android.server.biometrics.AuthenticationClient; |
Kevin Chyn | 355c6bf | 2018-09-20 22:14:19 -0700 | [diff] [blame] | 64 | import com.android.server.biometrics.BiometricServiceBase; |
Kevin Chyn | 836f2cf | 2018-08-27 11:06:39 -0700 | [diff] [blame] | 65 | import com.android.server.biometrics.BiometricUtils; |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 66 | import com.android.server.biometrics.Constants; |
Kevin Chyn | 0ce7085 | 2019-05-10 10:29:18 -0700 | [diff] [blame] | 67 | import com.android.server.biometrics.EnumerateClient; |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 68 | import com.android.server.biometrics.RemovalClient; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 69 | |
| 70 | import org.json.JSONArray; |
| 71 | import org.json.JSONException; |
| 72 | import org.json.JSONObject; |
| 73 | |
| 74 | import java.io.File; |
| 75 | import java.io.FileDescriptor; |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 76 | import java.io.FileOutputStream; |
| 77 | import java.io.IOException; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 78 | import java.io.PrintWriter; |
| 79 | import java.util.ArrayList; |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 80 | import java.util.Arrays; |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 81 | import java.util.HashMap; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 82 | import java.util.List; |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 83 | import java.util.Map; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * A service to manage multiple clients that want to access the face HAL API. |
| 87 | * The service is responsible for maintaining a list of clients and dispatching all |
Kevin Chyn | 51676d2 | 2018-11-05 18:00:43 -0800 | [diff] [blame] | 88 | * face-related events. |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 89 | * |
| 90 | * @hide |
| 91 | */ |
Kevin Chyn | 355c6bf | 2018-09-20 22:14:19 -0700 | [diff] [blame] | 92 | public class FaceService extends BiometricServiceBase { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 93 | |
| 94 | protected static final String TAG = "FaceService"; |
| 95 | private static final boolean DEBUG = true; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 96 | private static final String FACE_DATA_DIR = "facedata"; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 97 | private static final String ACTION_LOCKOUT_RESET = |
Kevin Chyn | 2ffadb3 | 2018-06-19 11:29:38 -0700 | [diff] [blame] | 98 | "com.android.server.biometrics.face.ACTION_LOCKOUT_RESET"; |
Kevin Chyn | e46a216 | 2018-09-20 18:43:01 -0700 | [diff] [blame] | 99 | private static final int CHALLENGE_TIMEOUT_SEC = 600; // 10 minutes |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 100 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 101 | private static final String NOTIFICATION_TAG = "FaceService"; |
| 102 | private static final int NOTIFICATION_ID = 1; |
| 103 | |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 104 | /** |
| 105 | * Events for bugreports. |
| 106 | */ |
| 107 | public static final class AuthenticationEvent { |
| 108 | private long mStartTime; |
| 109 | private long mLatency; |
| 110 | // Only valid if mError is 0 |
| 111 | private boolean mAuthenticated; |
| 112 | private int mError; |
| 113 | // Only valid if mError is ERROR_VENDOR |
| 114 | private int mVendorError; |
| 115 | |
| 116 | AuthenticationEvent(long startTime, long latency, boolean authenticated, int error, |
| 117 | int vendorError) { |
| 118 | mStartTime = startTime; |
| 119 | mLatency = latency; |
| 120 | mAuthenticated = authenticated; |
| 121 | mError = error; |
| 122 | mVendorError = vendorError; |
| 123 | } |
| 124 | |
| 125 | public String toString(Context context) { |
| 126 | return "Start: " + mStartTime |
| 127 | + "\tLatency: " + mLatency |
| 128 | + "\tAuthenticated: " + mAuthenticated |
| 129 | + "\tError: " + mError |
| 130 | + "\tVendorCode: " + mVendorError |
| 131 | + "\t" + FaceManager.getErrorString(context, mError, mVendorError); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Keep a short historical buffer of stats, with an aggregated usage time. |
| 137 | */ |
| 138 | private class UsageStats { |
| 139 | static final int EVENT_LOG_SIZE = 100; |
| 140 | |
| 141 | Context mContext; |
| 142 | List<AuthenticationEvent> mAuthenticationEvents; |
| 143 | |
| 144 | int acceptCount; |
| 145 | int rejectCount; |
| 146 | Map<Integer, Integer> mErrorCount; |
| 147 | |
| 148 | long acceptLatency; |
| 149 | long rejectLatency; |
| 150 | Map<Integer, Long> mErrorLatency; |
| 151 | |
| 152 | UsageStats(Context context) { |
| 153 | mAuthenticationEvents = new ArrayList<>(); |
| 154 | mErrorCount = new HashMap<>(); |
| 155 | mErrorLatency = new HashMap<>(); |
| 156 | mContext = context; |
| 157 | } |
| 158 | |
| 159 | void addEvent(AuthenticationEvent event) { |
| 160 | if (mAuthenticationEvents.size() >= EVENT_LOG_SIZE) { |
| 161 | mAuthenticationEvents.remove(0); |
| 162 | } |
| 163 | mAuthenticationEvents.add(event); |
| 164 | |
| 165 | if (event.mAuthenticated) { |
| 166 | acceptCount++; |
| 167 | acceptLatency += event.mLatency; |
| 168 | } else if (event.mError == 0) { |
| 169 | rejectCount++; |
| 170 | rejectLatency += event.mLatency; |
| 171 | } else { |
| 172 | mErrorCount.put(event.mError, mErrorCount.getOrDefault(event.mError, 0) + 1); |
| 173 | mErrorLatency.put(event.mError, |
| 174 | mErrorLatency.getOrDefault(event.mError, 0l) + event.mLatency); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | void print(PrintWriter pw) { |
| 179 | pw.println("Events since last reboot: " + mAuthenticationEvents.size()); |
| 180 | for (int i = 0; i < mAuthenticationEvents.size(); i++) { |
| 181 | pw.println(mAuthenticationEvents.get(i).toString(mContext)); |
| 182 | } |
| 183 | |
| 184 | // Dump aggregated usage stats |
| 185 | // TODO: Remove or combine with json dump in a future release |
| 186 | pw.println("Accept\tCount: " + acceptCount + "\tLatency: " + acceptLatency |
| 187 | + "\tAverage: " + (acceptCount > 0 ? acceptLatency / acceptCount : 0)); |
| 188 | pw.println("Reject\tCount: " + rejectCount + "\tLatency: " + rejectLatency |
| 189 | + "\tAverage: " + (rejectCount > 0 ? rejectLatency / rejectCount : 0)); |
| 190 | |
| 191 | for (Integer key : mErrorCount.keySet()) { |
| 192 | final int count = mErrorCount.get(key); |
| 193 | pw.println("Error" + key + "\tCount: " + count |
| 194 | + "\tLatency: " + mErrorLatency.getOrDefault(key, 0l) |
| 195 | + "\tAverage: " + (count > 0 ? mErrorLatency.getOrDefault(key, 0l) / count |
| 196 | : 0) |
| 197 | + "\t" + FaceManager.getErrorString(mContext, key, 0 /* vendorCode */)); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 202 | private final class FaceAuthClient extends AuthenticationClientImpl { |
Kevin Chyn | 0ce7085 | 2019-05-10 10:29:18 -0700 | [diff] [blame] | 203 | private int mLastAcquire; |
| 204 | |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 205 | public FaceAuthClient(Context context, |
| 206 | DaemonWrapper daemon, long halDeviceId, IBinder token, |
| 207 | ServiceListener listener, int targetUserId, int groupId, long opId, |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 208 | boolean restricted, String owner, int cookie, boolean requireConfirmation) { |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 209 | super(context, daemon, halDeviceId, token, listener, targetUserId, groupId, opId, |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 210 | restricted, owner, cookie, requireConfirmation); |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 211 | } |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 212 | |
| 213 | @Override |
| 214 | protected int statsModality() { |
| 215 | return FaceService.this.statsModality(); |
| 216 | } |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 217 | |
| 218 | @Override |
| 219 | public boolean shouldFrameworkHandleLockout() { |
| 220 | return false; |
| 221 | } |
Kevin Chyn | 56d6b07 | 2019-02-13 18:39:01 -0800 | [diff] [blame] | 222 | |
| 223 | @Override |
Kevin Chyn | 0ce7085 | 2019-05-10 10:29:18 -0700 | [diff] [blame] | 224 | public boolean wasUserDetected() { |
| 225 | return mLastAcquire != FaceManager.FACE_ACQUIRED_NOT_DETECTED; |
| 226 | } |
| 227 | |
| 228 | @Override |
Kevin Chyn | 56d6b07 | 2019-02-13 18:39:01 -0800 | [diff] [blame] | 229 | public boolean onAuthenticated(BiometricAuthenticator.Identifier identifier, |
| 230 | boolean authenticated, ArrayList<Byte> token) { |
| 231 | final boolean result = super.onAuthenticated(identifier, authenticated, token); |
| 232 | |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 233 | mUsageStats.addEvent(new AuthenticationEvent( |
| 234 | getStartTimeMs(), |
| 235 | System.currentTimeMillis() - getStartTimeMs() /* latency */, |
| 236 | authenticated, |
| 237 | 0 /* error */, |
| 238 | 0 /* vendorError */)); |
| 239 | |
Kevin Chyn | 56d6b07 | 2019-02-13 18:39:01 -0800 | [diff] [blame] | 240 | // For face, the authentication lifecycle ends either when |
| 241 | // 1) Authenticated == true |
| 242 | // 2) Error occurred |
| 243 | // 3) Authenticated == false |
| 244 | // Fingerprint currently does not end when the third condition is met which is a bug, |
| 245 | // but let's leave it as-is for now. |
| 246 | return result || !authenticated; |
| 247 | } |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 248 | |
| 249 | @Override |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 250 | public boolean onError(long deviceId, int error, int vendorCode) { |
| 251 | mUsageStats.addEvent(new AuthenticationEvent( |
| 252 | getStartTimeMs(), |
| 253 | System.currentTimeMillis() - getStartTimeMs() /* latency */, |
| 254 | false /* authenticated */, |
| 255 | error, |
| 256 | vendorCode)); |
| 257 | |
| 258 | return super.onError(deviceId, error, vendorCode); |
| 259 | } |
| 260 | |
| 261 | @Override |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 262 | public int[] getAcquireIgnorelist() { |
| 263 | if (isBiometricPrompt()) { |
| 264 | return mBiometricPromptIgnoreList; |
| 265 | } else { |
| 266 | // Keyguard |
| 267 | return mKeyguardIgnoreList; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | @Override |
| 272 | public int[] getAcquireVendorIgnorelist() { |
| 273 | if (isBiometricPrompt()) { |
| 274 | return mBiometricPromptIgnoreListVendor; |
| 275 | } else { |
| 276 | // Keyguard |
| 277 | return mKeyguardIgnoreListVendor; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | @Override |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 282 | public boolean onAcquired(int acquireInfo, int vendorCode) { |
| 283 | |
Kevin Chyn | 0ce7085 | 2019-05-10 10:29:18 -0700 | [diff] [blame] | 284 | mLastAcquire = acquireInfo; |
| 285 | |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 286 | if (acquireInfo == FaceManager.FACE_ACQUIRED_RECALIBRATE) { |
| 287 | final String name = |
| 288 | getContext().getString(R.string.face_recalibrate_notification_name); |
| 289 | final String title = |
| 290 | getContext().getString(R.string.face_recalibrate_notification_title); |
| 291 | final String content = |
| 292 | getContext().getString(R.string.face_recalibrate_notification_content); |
| 293 | |
| 294 | final Intent intent = new Intent("android.settings.FACE_SETTINGS"); |
| 295 | intent.setPackage("com.android.settings"); |
| 296 | |
| 297 | final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(getContext(), |
| 298 | 0 /* requestCode */, intent, 0 /* flags */, null /* options */, |
| 299 | UserHandle.CURRENT); |
| 300 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 301 | final String channelName = "FaceEnrollNotificationChannel"; |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 302 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 303 | NotificationChannel channel = new NotificationChannel(channelName, name, |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 304 | NotificationManager.IMPORTANCE_HIGH); |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 305 | Notification notification = new Notification.Builder(getContext(), channelName) |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 306 | .setSmallIcon(R.drawable.ic_lock) |
| 307 | .setContentTitle(title) |
| 308 | .setContentText(content) |
| 309 | .setSubText(name) |
| 310 | .setOnlyAlertOnce(true) |
| 311 | .setLocalOnly(true) |
| 312 | .setAutoCancel(true) |
| 313 | .setCategory(Notification.CATEGORY_SYSTEM) |
| 314 | .setContentIntent(pendingIntent) |
Kevin Chyn | 0c3a998 | 2019-06-11 19:09:27 -0700 | [diff] [blame] | 315 | .setVisibility(Notification.VISIBILITY_SECRET) |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 316 | .build(); |
| 317 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 318 | mNotificationManager.createNotificationChannel(channel); |
| 319 | mNotificationManager.notifyAsUser(NOTIFICATION_TAG, NOTIFICATION_ID, notification, |
| 320 | UserHandle.CURRENT); |
Kevin Chyn | 56e4c3d | 2019-04-23 11:28:43 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | return super.onAcquired(acquireInfo, vendorCode); |
| 324 | } |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 327 | /** |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 328 | * Receives the incoming binder calls from FaceManager. |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 329 | */ |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 330 | private final class FaceServiceWrapper extends IFaceService.Stub { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * The following methods contain common code which is shared in biometrics/common. |
| 334 | */ |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 335 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 336 | @Override // Binder call |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 337 | public long generateChallenge(IBinder token) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 338 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 339 | return startGenerateChallenge(token); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | @Override // Binder call |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 343 | public int revokeChallenge(IBinder token) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 344 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 345 | return startRevokeChallenge(token); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | @Override // Binder call |
Kevin Chyn | 1f16c2d | 2018-12-07 13:06:08 -0800 | [diff] [blame] | 349 | public void enroll(final IBinder token, final byte[] cryptoToken, |
| 350 | final IFaceServiceReceiver receiver, final String opPackageName, |
| 351 | final int[] disabledFeatures) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 352 | checkPermission(MANAGE_BIOMETRIC); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 353 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 354 | mNotificationManager.cancelAsUser(NOTIFICATION_TAG, NOTIFICATION_ID, |
| 355 | UserHandle.CURRENT); |
| 356 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 357 | final boolean restricted = isRestricted(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 358 | final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper, |
| 359 | mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId, |
Kevin Chyn | 1429a31 | 2019-01-28 16:08:09 -0800 | [diff] [blame] | 360 | 0 /* groupId */, cryptoToken, restricted, opPackageName, disabledFeatures) { |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 361 | |
| 362 | @Override |
| 363 | public int[] getAcquireIgnorelist() { |
| 364 | return mEnrollIgnoreList; |
| 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public int[] getAcquireVendorIgnorelist() { |
| 369 | return mEnrollIgnoreListVendor; |
| 370 | } |
| 371 | |
Kevin Chyn | 1429a31 | 2019-01-28 16:08:09 -0800 | [diff] [blame] | 372 | @Override |
| 373 | public boolean shouldVibrate() { |
| 374 | return false; |
| 375 | } |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 376 | |
| 377 | @Override |
| 378 | protected int statsModality() { |
| 379 | return FaceService.this.statsModality(); |
| 380 | } |
Kevin Chyn | 1429a31 | 2019-01-28 16:08:09 -0800 | [diff] [blame] | 381 | }; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 382 | |
Kevin Chyn | 1a878c1 | 2019-04-04 15:50:11 -0700 | [diff] [blame] | 383 | enrollInternal(client, mCurrentUserId); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | @Override // Binder call |
| 387 | public void cancelEnrollment(final IBinder token) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 388 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 389 | cancelEnrollmentInternal(token); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | @Override // Binder call |
Kevin Chyn | 747e29b | 2019-01-11 17:01:53 -0800 | [diff] [blame] | 393 | public void authenticate(final IBinder token, final long opId, int userId, |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 394 | final IFaceServiceReceiver receiver, final int flags, |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 395 | final String opPackageName) { |
| 396 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | 747e29b | 2019-01-11 17:01:53 -0800 | [diff] [blame] | 397 | updateActiveGroup(userId, opPackageName); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 398 | final boolean restricted = isRestricted(); |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 399 | final AuthenticationClientImpl client = new FaceAuthClient(getContext(), |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 400 | mDaemonWrapper, mHalDeviceId, token, new ServiceListenerImpl(receiver), |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 401 | mCurrentUserId, 0 /* groupId */, opId, restricted, opPackageName, |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 402 | 0 /* cookie */, false /* requireConfirmation */); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 403 | authenticateInternal(client, opId, opPackageName); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | @Override // Binder call |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 407 | public void prepareForAuthentication(boolean requireConfirmation, IBinder token, long opId, |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 408 | int groupId, IBiometricServiceReceiverInternal wrapperReceiver, |
| 409 | String opPackageName, int cookie, int callingUid, int callingPid, |
| 410 | int callingUserId) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 411 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | 41a8090 | 2019-02-06 08:12:15 -0800 | [diff] [blame] | 412 | updateActiveGroup(groupId, opPackageName); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 413 | final boolean restricted = true; // BiometricPrompt is always restricted |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 414 | final AuthenticationClientImpl client = new FaceAuthClient(getContext(), |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 415 | mDaemonWrapper, mHalDeviceId, token, |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 416 | new BiometricPromptServiceListenerImpl(wrapperReceiver), |
| 417 | mCurrentUserId, 0 /* groupId */, opId, restricted, opPackageName, cookie, |
Kevin Chyn | 158fefb | 2019-01-03 18:59:05 -0800 | [diff] [blame] | 418 | requireConfirmation); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 419 | authenticateInternal(client, opId, opPackageName, callingUid, callingPid, |
| 420 | callingUserId); |
| 421 | } |
| 422 | |
| 423 | @Override // Binder call |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 424 | public void startPreparedClient(int cookie) { |
| 425 | checkPermission(MANAGE_BIOMETRIC); |
| 426 | startCurrentClient(cookie); |
| 427 | } |
| 428 | |
| 429 | @Override // Binder call |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 430 | public void cancelAuthentication(final IBinder token, final String opPackageName) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 431 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 432 | cancelAuthenticationInternal(token, opPackageName); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | @Override // Binder call |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 436 | public void cancelAuthenticationFromService(final IBinder token, final String opPackageName, |
Kevin Chyn | e92cdae | 2018-11-21 16:35:04 -0800 | [diff] [blame] | 437 | int callingUid, int callingPid, int callingUserId, boolean fromClient) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 438 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | e92cdae | 2018-11-21 16:35:04 -0800 | [diff] [blame] | 439 | cancelAuthenticationInternal(token, opPackageName, callingUid, callingPid, |
| 440 | callingUserId, fromClient); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | @Override // Binder call |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 444 | public void setActiveUser(final int userId) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 445 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 446 | setActiveUserInternal(userId); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | @Override // Binder call |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 450 | public void remove(final IBinder token, final int faceId, final int userId, |
| 451 | final IFaceServiceReceiver receiver) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 452 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 453 | |
| 454 | if (token == null) { |
| 455 | Slog.w(TAG, "remove(): token is null"); |
| 456 | return; |
| 457 | } |
| 458 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 459 | final boolean restricted = isRestricted(); |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 460 | final RemovalClient client = new RemovalClient(getContext(), getConstants(), |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 461 | mDaemonWrapper, mHalDeviceId, token, new ServiceListenerImpl(receiver), faceId, |
| 462 | 0 /* groupId */, userId, restricted, token.toString(), getBiometricUtils()) { |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 463 | @Override |
| 464 | protected int statsModality() { |
| 465 | return FaceService.this.statsModality(); |
| 466 | } |
| 467 | }; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 468 | removeInternal(client); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 469 | } |
| 470 | |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 471 | @Override |
| 472 | public void enumerate(final IBinder token, final int userId, |
| 473 | final IFaceServiceReceiver receiver) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 474 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 475 | |
| 476 | final boolean restricted = isRestricted(); |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 477 | final EnumerateClient client = new EnumerateClient(getContext(), getConstants(), |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 478 | mDaemonWrapper, mHalDeviceId, token, new ServiceListenerImpl(receiver), userId, |
| 479 | userId, restricted, getContext().getOpPackageName()) { |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 480 | @Override |
| 481 | protected int statsModality() { |
| 482 | return FaceService.this.statsModality(); |
| 483 | } |
| 484 | }; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 485 | enumerateInternal(client); |
| 486 | } |
| 487 | |
| 488 | @Override |
| 489 | public void addLockoutResetCallback(final IBiometricServiceLockoutResetCallback callback) |
| 490 | throws RemoteException { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 491 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 492 | FaceService.super.addLockoutResetCallback(callback); |
| 493 | } |
| 494 | |
| 495 | @Override // Binder call |
| 496 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 497 | if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) { |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | final long ident = Binder.clearCallingIdentity(); |
| 502 | try { |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 503 | if (args.length > 1 && "--hal".equals(args[0])) { |
| 504 | dumpHal(fd, Arrays.copyOfRange(args, 1, args.length, args.getClass())); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 505 | } else { |
| 506 | dumpInternal(pw); |
| 507 | } |
| 508 | } finally { |
| 509 | Binder.restoreCallingIdentity(ident); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * The following methods don't use any common code from BiometricService |
| 515 | */ |
| 516 | |
| 517 | // TODO: refactor out common code here |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 518 | @Override // Binder call |
| 519 | public boolean isHardwareDetected(long deviceId, String opPackageName) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 520 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 521 | if (!canUseBiometric(opPackageName, false /* foregroundOnly */, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 522 | Binder.getCallingUid(), Binder.getCallingPid(), |
| 523 | UserHandle.getCallingUserId())) { |
| 524 | return false; |
| 525 | } |
| 526 | |
| 527 | final long token = Binder.clearCallingIdentity(); |
| 528 | try { |
| 529 | IBiometricsFace daemon = getFaceDaemon(); |
| 530 | return daemon != null && mHalDeviceId != 0; |
| 531 | } finally { |
| 532 | Binder.restoreCallingIdentity(token); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | @Override // Binder call |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 537 | public void rename(final int faceId, final String name) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 538 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 539 | if (!isCurrentUserOrProfile(UserHandle.getCallingUserId())) { |
| 540 | return; |
| 541 | } |
| 542 | mHandler.post(new Runnable() { |
| 543 | @Override |
| 544 | public void run() { |
| 545 | getBiometricUtils().renameBiometricForUser(getContext(), mCurrentUserId, |
| 546 | faceId, name); |
| 547 | } |
| 548 | }); |
| 549 | } |
| 550 | |
| 551 | @Override // Binder call |
| 552 | public List<Face> getEnrolledFaces(int userId, String opPackageName) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 553 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 554 | if (!canUseBiometric(opPackageName, false /* foregroundOnly */, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 555 | Binder.getCallingUid(), Binder.getCallingPid(), |
| 556 | UserHandle.getCallingUserId())) { |
| 557 | return null; |
| 558 | } |
| 559 | |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 560 | return FaceService.this.getEnrolledTemplates(userId); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | @Override // Binder call |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 564 | public boolean hasEnrolledFaces(int userId, String opPackageName) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 565 | checkPermission(USE_BIOMETRIC_INTERNAL); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 566 | if (!canUseBiometric(opPackageName, false /* foregroundOnly */, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 567 | Binder.getCallingUid(), Binder.getCallingPid(), |
| 568 | UserHandle.getCallingUserId())) { |
| 569 | return false; |
| 570 | } |
| 571 | |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 572 | return FaceService.this.hasEnrolledBiometrics(userId); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | @Override // Binder call |
| 576 | public long getAuthenticatorId(String opPackageName) { |
| 577 | // In this method, we're not checking whether the caller is permitted to use face |
| 578 | // API because current authenticator ID is leaked (in a more contrived way) via Android |
| 579 | // Keystore (android.security.keystore package): the user of that API can create a key |
| 580 | // which requires face authentication for its use, and then query the key's |
| 581 | // characteristics (hidden API) which returns, among other things, face |
| 582 | // authenticator ID which was active at key creation time. |
| 583 | // |
| 584 | // Reason: The part of Android Keystore which runs inside an app's process invokes this |
| 585 | // method in certain cases. Those cases are not always where the developer demonstrates |
| 586 | // explicit intent to use face functionality. Thus, to avoiding throwing an |
| 587 | // unexpected SecurityException this method does not check whether its caller is |
| 588 | // permitted to use face API. |
| 589 | // |
| 590 | // The permission check should be restored once Android Keystore no longer invokes this |
| 591 | // method from inside app processes. |
| 592 | |
| 593 | return FaceService.this.getAuthenticatorId(opPackageName); |
| 594 | } |
| 595 | |
| 596 | @Override // Binder call |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 597 | public void resetLockout(byte[] token) { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 598 | checkPermission(MANAGE_BIOMETRIC); |
Kevin Chyn | 1d6a286 | 2019-04-02 16:20:21 -0700 | [diff] [blame] | 599 | |
| 600 | if (!FaceService.this.hasEnrolledBiometrics(mCurrentUserId)) { |
| 601 | Slog.w(TAG, "Ignoring lockout reset, no templates enrolled"); |
| 602 | return; |
| 603 | } |
| 604 | |
Kevin Chyn | be67ce0 | 2019-06-10 16:14:22 -0700 | [diff] [blame] | 605 | Slog.d(TAG, "Resetting lockout for user: " + mCurrentUserId); |
| 606 | |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 607 | try { |
| 608 | mDaemonWrapper.resetLockout(token); |
| 609 | } catch (RemoteException e) { |
| 610 | Slog.e(getTag(), "Unable to reset lockout", e); |
| 611 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 612 | } |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 613 | |
| 614 | @Override |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 615 | public void setFeature(int feature, boolean enabled, final byte[] token, |
| 616 | IFaceServiceReceiver receiver) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 617 | checkPermission(MANAGE_BIOMETRIC); |
| 618 | |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 619 | mHandler.post(() -> { |
| 620 | if (!FaceService.this.hasEnrolledBiometrics(mCurrentUserId)) { |
| 621 | Slog.e(TAG, "No enrolled biometrics while setting feature: " + feature); |
| 622 | return; |
Kevin Chyn | b95f152 | 2019-03-04 16:45:15 -0800 | [diff] [blame] | 623 | } |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 624 | |
| 625 | final ArrayList<Byte> byteToken = new ArrayList<>(); |
| 626 | for (int i = 0; i < token.length; i++) { |
| 627 | byteToken.add(token[i]); |
| 628 | } |
| 629 | |
| 630 | // TODO: Support multiple faces |
| 631 | final int faceId = getFirstTemplateForUser(mCurrentUserId); |
| 632 | |
| 633 | if (mDaemon != null) { |
| 634 | try { |
| 635 | final int result = mDaemon.setFeature(feature, enabled, byteToken, faceId); |
| 636 | receiver.onFeatureSet(result == Status.OK, feature); |
| 637 | } catch (RemoteException e) { |
| 638 | Slog.e(getTag(), "Unable to set feature: " + feature |
| 639 | + " to enabled:" + enabled, e); |
| 640 | } |
| 641 | } |
| 642 | }); |
| 643 | |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | @Override |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 647 | public void getFeature(int feature, IFaceServiceReceiver receiver) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 648 | checkPermission(MANAGE_BIOMETRIC); |
| 649 | |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 650 | mHandler.post(() -> { |
| 651 | // This should ideally return tri-state, but the user isn't shown settings unless |
| 652 | // they are enrolled so it's fine for now. |
| 653 | if (!FaceService.this.hasEnrolledBiometrics(mCurrentUserId)) { |
| 654 | Slog.e(TAG, "No enrolled biometrics while getting feature: " + feature); |
| 655 | return; |
Kevin Chyn | b95f152 | 2019-03-04 16:45:15 -0800 | [diff] [blame] | 656 | } |
Kevin Chyn | e62749a | 2019-04-02 19:33:56 -0700 | [diff] [blame] | 657 | |
| 658 | // TODO: Support multiple faces |
| 659 | final int faceId = getFirstTemplateForUser(mCurrentUserId); |
| 660 | |
| 661 | if (mDaemon != null) { |
| 662 | try { |
| 663 | OptionalBool result = mDaemon.getFeature(feature, faceId); |
| 664 | receiver.onFeatureGet(result.status == Status.OK, feature, result.value); |
| 665 | } catch (RemoteException e) { |
| 666 | Slog.e(getTag(), "Unable to getRequireAttention", e); |
| 667 | } |
| 668 | } |
| 669 | }); |
| 670 | |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 671 | } |
Kevin Chyn | 57f119b | 2018-10-25 12:03:41 -0700 | [diff] [blame] | 672 | |
| 673 | @Override |
| 674 | public void userActivity() { |
| 675 | checkPermission(MANAGE_BIOMETRIC); |
| 676 | |
| 677 | if (mDaemon != null) { |
| 678 | try { |
| 679 | mDaemon.userActivity(); |
| 680 | } catch (RemoteException e) { |
| 681 | Slog.e(getTag(), "Unable to send userActivity", e); |
| 682 | } |
| 683 | } |
| 684 | } |
Kevin Chyn | b95f152 | 2019-03-04 16:45:15 -0800 | [diff] [blame] | 685 | |
| 686 | // TODO: Support multiple faces |
| 687 | private int getFirstTemplateForUser(int user) { |
| 688 | final List<Face> faces = FaceService.this.getEnrolledTemplates(user); |
| 689 | if (!faces.isEmpty()) { |
| 690 | return faces.get(0).getBiometricId(); |
| 691 | } |
| 692 | return 0; |
| 693 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | /** |
| 697 | * Receives callbacks from the ClientMonitor implementations. The results are forwarded to |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 698 | * BiometricPrompt. |
| 699 | */ |
Kevin Chyn | e92cdae | 2018-11-21 16:35:04 -0800 | [diff] [blame] | 700 | private class BiometricPromptServiceListenerImpl extends BiometricServiceListener { |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 701 | BiometricPromptServiceListenerImpl(IBiometricServiceReceiverInternal wrapperReceiver) { |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 702 | super(wrapperReceiver); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | @Override |
| 706 | public void onAcquired(long deviceId, int acquiredInfo, int vendorCode) |
| 707 | throws RemoteException { |
| 708 | /** |
| 709 | * Map the acquired codes onto existing {@link BiometricConstants} acquired codes. |
| 710 | */ |
Kevin Chyn | e92cdae | 2018-11-21 16:35:04 -0800 | [diff] [blame] | 711 | if (getWrapperReceiver() != null) { |
| 712 | getWrapperReceiver().onAcquired( |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 713 | FaceManager.getMappedAcquiredInfo(acquiredInfo, vendorCode), |
| 714 | FaceManager.getAcquiredString(getContext(), acquiredInfo, vendorCode)); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | |
| 718 | @Override |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 719 | public void onError(long deviceId, int error, int vendorCode, int cookie) |
| 720 | throws RemoteException { |
Kevin Chyn | e92cdae | 2018-11-21 16:35:04 -0800 | [diff] [blame] | 721 | if (getWrapperReceiver() != null) { |
Kevin Chyn | 23289ef | 2018-11-28 16:32:36 -0800 | [diff] [blame] | 722 | getWrapperReceiver().onError(cookie, error, |
| 723 | FaceManager.getErrorString(getContext(), error, vendorCode)); |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 724 | } |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * Receives callbacks from the ClientMonitor implementations. The results are forwarded to |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 730 | * the FaceManager. |
| 731 | */ |
| 732 | private class ServiceListenerImpl implements ServiceListener { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 733 | private IFaceServiceReceiver mFaceServiceReceiver; |
| 734 | |
| 735 | public ServiceListenerImpl(IFaceServiceReceiver receiver) { |
| 736 | mFaceServiceReceiver = receiver; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | @Override |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 740 | public void onEnrollResult(BiometricAuthenticator.Identifier identifier, int remaining) |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 741 | throws RemoteException { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 742 | if (mFaceServiceReceiver != null) { |
| 743 | mFaceServiceReceiver.onEnrollResult(identifier.getDeviceId(), |
| 744 | identifier.getBiometricId(), |
| 745 | remaining); |
| 746 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 747 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 748 | |
| 749 | @Override |
| 750 | public void onAcquired(long deviceId, int acquiredInfo, int vendorCode) |
| 751 | throws RemoteException { |
| 752 | if (mFaceServiceReceiver != null) { |
| 753 | mFaceServiceReceiver.onAcquired(deviceId, acquiredInfo, vendorCode); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | @Override |
| 758 | public void onAuthenticationSucceeded(long deviceId, |
| 759 | BiometricAuthenticator.Identifier biometric, int userId) |
| 760 | throws RemoteException { |
| 761 | if (mFaceServiceReceiver != null) { |
Kevin Chyn | 628b718 | 2018-11-13 12:00:48 -0800 | [diff] [blame] | 762 | if (biometric == null || biometric instanceof Face) { |
Kevin Chyn | 8d2694a | 2019-04-11 18:30:40 -0700 | [diff] [blame] | 763 | mFaceServiceReceiver.onAuthenticationSucceeded(deviceId, (Face) biometric, |
| 764 | userId); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 765 | } else { |
| 766 | Slog.e(TAG, "onAuthenticationSucceeded received non-face biometric"); |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | @Override |
| 772 | public void onAuthenticationFailed(long deviceId) throws RemoteException { |
| 773 | if (mFaceServiceReceiver != null) { |
| 774 | mFaceServiceReceiver.onAuthenticationFailed(deviceId); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | @Override |
Kevin Chyn | 87f257a | 2018-11-27 16:26:07 -0800 | [diff] [blame] | 779 | public void onError(long deviceId, int error, int vendorCode, int cookie) |
| 780 | throws RemoteException { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 781 | if (mFaceServiceReceiver != null) { |
| 782 | mFaceServiceReceiver.onError(deviceId, error, vendorCode); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | @Override |
| 787 | public void onRemoved(BiometricAuthenticator.Identifier identifier, |
| 788 | int remaining) throws RemoteException { |
| 789 | if (mFaceServiceReceiver != null) { |
| 790 | mFaceServiceReceiver.onRemoved(identifier.getDeviceId(), |
| 791 | identifier.getBiometricId(), remaining); |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | @Override |
| 796 | public void onEnumerated(BiometricAuthenticator.Identifier identifier, int remaining) |
| 797 | throws RemoteException { |
| 798 | if (mFaceServiceReceiver != null) { |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 799 | mFaceServiceReceiver.onEnumerated(identifier.getDeviceId(), |
| 800 | identifier.getBiometricId(), remaining); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | } |
| 804 | |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 805 | private final FaceConstants mFaceConstants = new FaceConstants(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 806 | |
| 807 | @GuardedBy("this") |
| 808 | private IBiometricsFace mDaemon; |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 809 | private UsageStats mUsageStats; |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 810 | // One of the AuthenticationClient constants |
| 811 | private int mCurrentUserLockoutMode; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 812 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 813 | private NotificationManager mNotificationManager; |
| 814 | |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 815 | private int[] mBiometricPromptIgnoreList; |
| 816 | private int[] mBiometricPromptIgnoreListVendor; |
| 817 | private int[] mKeyguardIgnoreList; |
| 818 | private int[] mKeyguardIgnoreListVendor; |
| 819 | private int[] mEnrollIgnoreList; |
| 820 | private int[] mEnrollIgnoreListVendor; |
| 821 | |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 822 | /** |
| 823 | * Receives callbacks from the HAL. |
| 824 | */ |
| 825 | private IBiometricsFaceClientCallback mDaemonCallback = |
| 826 | new IBiometricsFaceClientCallback.Stub() { |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 827 | @Override |
| 828 | public void onEnrollResult(final long deviceId, int faceId, int userId, |
| 829 | int remaining) { |
| 830 | mHandler.post(() -> { |
| 831 | final Face face = new Face(getBiometricUtils() |
| 832 | .getUniqueName(getContext(), userId), faceId, deviceId); |
| 833 | FaceService.super.handleEnrollResult(face, remaining); |
Kevin Chyn | 576811e | 2019-06-12 14:50:35 -0700 | [diff] [blame] | 834 | |
| 835 | // Enrollment changes the authenticatorId, so update it here. |
| 836 | IBiometricsFace daemon = getFaceDaemon(); |
| 837 | if (remaining == 0 && daemon != null) { |
| 838 | try { |
| 839 | mAuthenticatorIds.put(userId, |
| 840 | hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value |
| 841 | : 0L); |
| 842 | } catch (RemoteException e) { |
| 843 | Slog.e(TAG, "Unable to get authenticatorId", e); |
| 844 | } |
| 845 | } |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 846 | }); |
| 847 | } |
| 848 | |
| 849 | @Override |
| 850 | public void onAcquired(final long deviceId, final int userId, |
| 851 | final int acquiredInfo, |
| 852 | final int vendorCode) { |
| 853 | mHandler.post(() -> { |
| 854 | FaceService.super.handleAcquired(deviceId, acquiredInfo, vendorCode); |
| 855 | }); |
| 856 | } |
| 857 | |
| 858 | @Override |
| 859 | public void onAuthenticated(final long deviceId, final int faceId, final int userId, |
| 860 | ArrayList<Byte> token) { |
| 861 | mHandler.post(() -> { |
| 862 | Face face = new Face("", faceId, deviceId); |
| 863 | FaceService.super.handleAuthenticated(face, token); |
| 864 | }); |
| 865 | } |
| 866 | |
| 867 | @Override |
| 868 | public void onError(final long deviceId, final int userId, final int error, |
| 869 | final int vendorCode) { |
| 870 | mHandler.post(() -> { |
| 871 | FaceService.super.handleError(deviceId, error, vendorCode); |
| 872 | |
| 873 | // TODO: this chunk of code should be common to all biometric services |
| 874 | if (error == BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE) { |
| 875 | // If we get HW_UNAVAILABLE, try to connect again later... |
| 876 | Slog.w(TAG, "Got ERROR_HW_UNAVAILABLE; try reconnecting next client."); |
| 877 | synchronized (this) { |
| 878 | mDaemon = null; |
| 879 | mHalDeviceId = 0; |
| 880 | mCurrentUserId = UserHandle.USER_NULL; |
| 881 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 882 | } |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 883 | }); |
| 884 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 885 | |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 886 | @Override |
Kevin Chyn | 31ae8d2 | 2019-03-11 14:12:32 -0700 | [diff] [blame] | 887 | public void onRemoved(final long deviceId, ArrayList<Integer> faceIds, final int userId) { |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 888 | mHandler.post(() -> { |
Kevin Chyn | 31ae8d2 | 2019-03-11 14:12:32 -0700 | [diff] [blame] | 889 | if (!faceIds.isEmpty()) { |
| 890 | for (int i = 0; i < faceIds.size(); i++) { |
| 891 | final Face face = new Face("", faceIds.get(i), deviceId); |
| 892 | // Convert to old behavior |
| 893 | FaceService.super.handleRemoved(face, faceIds.size() - i - 1); |
| 894 | } |
| 895 | } else { |
| 896 | final Face face = new Face("", 0 /* identifier */, deviceId); |
| 897 | FaceService.super.handleRemoved(face, 0 /* remaining */); |
| 898 | } |
| 899 | |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 900 | }); |
| 901 | } |
| 902 | |
| 903 | @Override |
| 904 | public void onEnumerate(long deviceId, ArrayList<Integer> faceIds, int userId) |
| 905 | throws RemoteException { |
| 906 | mHandler.post(() -> { |
| 907 | if (!faceIds.isEmpty()) { |
| 908 | for (int i = 0; i < faceIds.size(); i++) { |
| 909 | final Face face = new Face("", faceIds.get(i), deviceId); |
| 910 | // Convert to old old behavior |
| 911 | FaceService.super.handleEnumerate(face, faceIds.size() - i - 1); |
| 912 | } |
| 913 | } else { |
| 914 | // For face, the HIDL contract is to receive an empty list when there are no |
| 915 | // templates enrolled. Send a null identifier since we don't consume them |
| 916 | // anywhere, and send remaining == 0 to plumb this with existing common code. |
| 917 | FaceService.super.handleEnumerate(null /* identifier */, 0); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 918 | } |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 919 | }); |
| 920 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 921 | |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 922 | @Override |
| 923 | public void onLockoutChanged(long duration) { |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 924 | Slog.d(TAG, "onLockoutChanged: " + duration); |
| 925 | if (duration == 0) { |
| 926 | mCurrentUserLockoutMode = AuthenticationClient.LOCKOUT_NONE; |
| 927 | } else if (duration == Long.MAX_VALUE) { |
| 928 | mCurrentUserLockoutMode = AuthenticationClient.LOCKOUT_PERMANENT; |
| 929 | } else { |
| 930 | mCurrentUserLockoutMode = AuthenticationClient.LOCKOUT_TIMED; |
| 931 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 932 | |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 933 | mHandler.post(() -> { |
| 934 | if (duration == 0) { |
| 935 | notifyLockoutResetMonitors(); |
| 936 | } |
| 937 | }); |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 938 | } |
| 939 | }; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 940 | |
| 941 | /** |
| 942 | * Wraps the HAL-specific code and is passed to the ClientMonitor implementations so that they |
| 943 | * can be shared between the multiple biometric services. |
| 944 | */ |
| 945 | private final DaemonWrapper mDaemonWrapper = new DaemonWrapper() { |
| 946 | @Override |
| 947 | public int authenticate(long operationId, int groupId) throws RemoteException { |
| 948 | IBiometricsFace daemon = getFaceDaemon(); |
| 949 | if (daemon == null) { |
| 950 | Slog.w(TAG, "authenticate(): no face HAL!"); |
| 951 | return ERROR_ESRCH; |
| 952 | } |
| 953 | return daemon.authenticate(operationId); |
| 954 | } |
| 955 | |
| 956 | @Override |
| 957 | public int cancel() throws RemoteException { |
| 958 | IBiometricsFace daemon = getFaceDaemon(); |
| 959 | if (daemon == null) { |
| 960 | Slog.w(TAG, "cancel(): no face HAL!"); |
| 961 | return ERROR_ESRCH; |
| 962 | } |
| 963 | return daemon.cancel(); |
| 964 | } |
| 965 | |
| 966 | @Override |
| 967 | public int remove(int groupId, int biometricId) throws RemoteException { |
| 968 | IBiometricsFace daemon = getFaceDaemon(); |
| 969 | if (daemon == null) { |
| 970 | Slog.w(TAG, "remove(): no face HAL!"); |
| 971 | return ERROR_ESRCH; |
| 972 | } |
| 973 | return daemon.remove(biometricId); |
| 974 | } |
| 975 | |
| 976 | @Override |
| 977 | public int enumerate() throws RemoteException { |
| 978 | IBiometricsFace daemon = getFaceDaemon(); |
| 979 | if (daemon == null) { |
| 980 | Slog.w(TAG, "enumerate(): no face HAL!"); |
| 981 | return ERROR_ESRCH; |
| 982 | } |
| 983 | return daemon.enumerate(); |
| 984 | } |
| 985 | |
| 986 | @Override |
Kevin Chyn | 1f16c2d | 2018-12-07 13:06:08 -0800 | [diff] [blame] | 987 | public int enroll(byte[] cryptoToken, int groupId, int timeout, |
| 988 | ArrayList<Integer> disabledFeatures) throws RemoteException { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 989 | IBiometricsFace daemon = getFaceDaemon(); |
| 990 | if (daemon == null) { |
| 991 | Slog.w(TAG, "enroll(): no face HAL!"); |
| 992 | return ERROR_ESRCH; |
| 993 | } |
| 994 | final ArrayList<Byte> token = new ArrayList<>(); |
| 995 | for (int i = 0; i < cryptoToken.length; i++) { |
| 996 | token.add(cryptoToken[i]); |
| 997 | } |
Kevin Chyn | 1f16c2d | 2018-12-07 13:06:08 -0800 | [diff] [blame] | 998 | return daemon.enroll(token, timeout, disabledFeatures); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 999 | } |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 1000 | |
| 1001 | @Override |
| 1002 | public void resetLockout(byte[] cryptoToken) throws RemoteException { |
| 1003 | IBiometricsFace daemon = getFaceDaemon(); |
| 1004 | if (daemon == null) { |
| 1005 | Slog.w(TAG, "resetLockout(): no face HAL!"); |
| 1006 | return; |
| 1007 | } |
| 1008 | final ArrayList<Byte> token = new ArrayList<>(); |
| 1009 | for (int i = 0; i < cryptoToken.length; i++) { |
| 1010 | token.add(cryptoToken[i]); |
| 1011 | } |
| 1012 | daemon.resetLockout(token); |
| 1013 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1014 | }; |
| 1015 | |
| 1016 | |
| 1017 | public FaceService(Context context) { |
| 1018 | super(context); |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 1019 | |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 1020 | mUsageStats = new UsageStats(context); |
| 1021 | |
Kevin Chyn | dbfbed4 | 2019-06-13 17:01:30 -0700 | [diff] [blame] | 1022 | mNotificationManager = getContext().getSystemService(NotificationManager.class); |
| 1023 | |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 1024 | mBiometricPromptIgnoreList = getContext().getResources() |
| 1025 | .getIntArray(R.array.config_face_acquire_biometricprompt_ignorelist); |
| 1026 | mBiometricPromptIgnoreListVendor = getContext().getResources() |
| 1027 | .getIntArray(R.array.config_face_acquire_vendor_biometricprompt_ignorelist); |
| 1028 | mKeyguardIgnoreList = getContext().getResources() |
| 1029 | .getIntArray(R.array.config_face_acquire_keyguard_ignorelist); |
| 1030 | mKeyguardIgnoreListVendor = getContext().getResources() |
| 1031 | .getIntArray(R.array.config_face_acquire_vendor_keyguard_ignorelist); |
| 1032 | mEnrollIgnoreList = getContext().getResources() |
| 1033 | .getIntArray(R.array.config_face_acquire_enroll_ignorelist); |
| 1034 | mEnrollIgnoreListVendor = getContext().getResources() |
| 1035 | .getIntArray(R.array.config_face_acquire_vendor_enroll_ignorelist); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | @Override |
| 1039 | public void onStart() { |
Kevin Chyn | 5a2ff5d | 2018-08-29 19:07:30 -0700 | [diff] [blame] | 1040 | super.onStart(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1041 | publishBinderService(Context.FACE_SERVICE, new FaceServiceWrapper()); |
Kevin Chyn | 8398a71 | 2019-06-13 16:44:50 -0700 | [diff] [blame] | 1042 | // Get the face daemon on FaceService's on thread so SystemServerInitThreadPool isn't |
| 1043 | // blocked |
| 1044 | SystemServerInitThreadPool.get().submit(() -> mHandler.post(this::getFaceDaemon), |
| 1045 | TAG + ".onStart"); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | @Override |
| 1049 | public String getTag() { |
| 1050 | return TAG; |
| 1051 | } |
| 1052 | |
| 1053 | @Override |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 1054 | protected DaemonWrapper getDaemonWrapper() { |
| 1055 | return mDaemonWrapper; |
| 1056 | } |
| 1057 | |
| 1058 | @Override |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1059 | protected BiometricUtils getBiometricUtils() { |
| 1060 | return FaceUtils.getInstance(); |
| 1061 | } |
| 1062 | |
| 1063 | @Override |
Kevin Chyn | 4cc49f7 | 2019-04-24 13:53:35 -0700 | [diff] [blame] | 1064 | protected Constants getConstants() { |
| 1065 | return mFaceConstants; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | @Override |
| 1069 | protected boolean hasReachedEnrollmentLimit(int userId) { |
| 1070 | final int limit = getContext().getResources().getInteger( |
Kevin Chyn | 017e76e | 2018-06-27 18:35:06 -0700 | [diff] [blame] | 1071 | com.android.internal.R.integer.config_faceMaxTemplatesPerUser); |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 1072 | final int enrolled = FaceService.this.getEnrolledTemplates(userId).size(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1073 | if (enrolled >= limit) { |
Kevin Chyn | 1a878c1 | 2019-04-04 15:50:11 -0700 | [diff] [blame] | 1074 | Slog.w(TAG, "Too many faces registered, user: " + userId); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1075 | return true; |
| 1076 | } |
| 1077 | return false; |
| 1078 | } |
| 1079 | |
| 1080 | @Override |
Kevin Chyn | 9ba9991 | 2019-01-16 16:24:36 -0800 | [diff] [blame] | 1081 | public void serviceDied(long cookie) { |
| 1082 | super.serviceDied(cookie); |
| 1083 | mDaemon = null; |
Jim Miller | 7b78b22 | 2019-02-07 16:47:38 -0800 | [diff] [blame] | 1084 | |
| 1085 | mCurrentUserId = UserHandle.USER_NULL; // Force updateActiveGroup() to re-evaluate |
Kevin Chyn | 9ba9991 | 2019-01-16 16:24:36 -0800 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | @Override |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1089 | protected void updateActiveGroup(int userId, String clientPackage) { |
| 1090 | IBiometricsFace daemon = getFaceDaemon(); |
| 1091 | |
| 1092 | if (daemon != null) { |
| 1093 | try { |
| 1094 | userId = getUserOrWorkProfileId(clientPackage, userId); |
| 1095 | if (userId != mCurrentUserId) { |
Kevin Chyn | 27e33d0 | 2019-04-30 01:37:32 +0000 | [diff] [blame] | 1096 | final File baseDir = Environment.getDataVendorDeDirectory(userId); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1097 | final File faceDir = new File(baseDir, FACE_DATA_DIR); |
| 1098 | if (!faceDir.exists()) { |
| 1099 | if (!faceDir.mkdir()) { |
| 1100 | Slog.v(TAG, "Cannot make directory: " + faceDir.getAbsolutePath()); |
| 1101 | return; |
| 1102 | } |
| 1103 | // Calling mkdir() from this process will create a directory with our |
| 1104 | // permissions (inherited from the containing dir). This command fixes |
| 1105 | // the label. |
| 1106 | if (!SELinux.restorecon(faceDir)) { |
| 1107 | Slog.w(TAG, "Restorecons failed. Directory will have wrong label."); |
| 1108 | return; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | daemon.setActiveUser(userId, faceDir.getAbsolutePath()); |
| 1113 | mCurrentUserId = userId; |
Kevin Chyn | 576811e | 2019-06-12 14:50:35 -0700 | [diff] [blame] | 1114 | mAuthenticatorIds.put(userId, |
| 1115 | hasEnrolledBiometrics(userId) ? daemon.getAuthenticatorId().value : 0L); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1116 | } |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1117 | } catch (RemoteException e) { |
| 1118 | Slog.e(TAG, "Failed to setActiveUser():", e); |
| 1119 | } |
| 1120 | } |
| 1121 | } |
| 1122 | |
| 1123 | @Override |
| 1124 | protected String getLockoutResetIntent() { |
| 1125 | return ACTION_LOCKOUT_RESET; |
| 1126 | } |
| 1127 | |
| 1128 | @Override |
| 1129 | protected String getLockoutBroadcastPermission() { |
| 1130 | return RESET_FACE_LOCKOUT; |
| 1131 | } |
| 1132 | |
| 1133 | @Override |
| 1134 | protected long getHalDeviceId() { |
| 1135 | return mHalDeviceId; |
| 1136 | } |
| 1137 | |
| 1138 | @Override |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 1139 | protected void handleUserSwitching(int userId) { |
| 1140 | super.handleUserSwitching(userId); |
| 1141 | // Will be updated when we get the callback from HAL |
| 1142 | mCurrentUserLockoutMode = AuthenticationClient.LOCKOUT_NONE; |
| 1143 | } |
| 1144 | |
| 1145 | @Override |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1146 | protected boolean hasEnrolledBiometrics(int userId) { |
| 1147 | if (userId != UserHandle.getCallingUserId()) { |
| 1148 | checkPermission(INTERACT_ACROSS_USERS); |
| 1149 | } |
| 1150 | return getBiometricUtils().getBiometricsForUser(getContext(), userId).size() > 0; |
| 1151 | } |
| 1152 | |
| 1153 | @Override |
| 1154 | protected String getManageBiometricPermission() { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1155 | return MANAGE_BIOMETRIC; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | @Override |
| 1159 | protected void checkUseBiometricPermission() { |
Kevin Chyn | a24e9fd | 2018-08-27 12:39:17 -0700 | [diff] [blame] | 1160 | // noop for Face. The permission checks are all done on the incoming binder call. |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | @Override |
Kevin Chyn | b3c05aa | 2018-09-21 16:50:32 -0700 | [diff] [blame] | 1164 | protected boolean checkAppOps(int uid, String opPackageName) { |
| 1165 | return mAppOps.noteOp(AppOpsManager.OP_USE_BIOMETRIC, uid, opPackageName) |
| 1166 | == AppOpsManager.MODE_ALLOWED; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | @Override |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 1170 | protected List<Face> getEnrolledTemplates(int userId) { |
| 1171 | return getBiometricUtils().getBiometricsForUser(getContext(), userId); |
| 1172 | } |
| 1173 | |
| 1174 | @Override |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1175 | protected void notifyClientActiveCallbacks(boolean isActive) { |
| 1176 | // noop for Face. |
| 1177 | } |
| 1178 | |
Kevin Chyn | 7782d14 | 2019-01-18 12:51:33 -0800 | [diff] [blame] | 1179 | @Override |
| 1180 | protected int statsModality() { |
| 1181 | return BiometricsProtoEnums.MODALITY_FACE; |
| 1182 | } |
| 1183 | |
Kevin Chyn | a38653c | 2019-02-11 17:46:21 -0800 | [diff] [blame] | 1184 | @Override |
| 1185 | protected int getLockoutMode() { |
| 1186 | return mCurrentUserLockoutMode; |
| 1187 | } |
| 1188 | |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1189 | /** Gets the face daemon */ |
| 1190 | private synchronized IBiometricsFace getFaceDaemon() { |
| 1191 | if (mDaemon == null) { |
| 1192 | Slog.v(TAG, "mDaemon was null, reconnect to face"); |
| 1193 | try { |
| 1194 | mDaemon = IBiometricsFace.getService(); |
| 1195 | } catch (java.util.NoSuchElementException e) { |
| 1196 | // Service doesn't exist or cannot be opened. Logged below. |
| 1197 | } catch (RemoteException e) { |
| 1198 | Slog.e(TAG, "Failed to get biometric interface", e); |
| 1199 | } |
| 1200 | if (mDaemon == null) { |
| 1201 | Slog.w(TAG, "face HIDL not available"); |
| 1202 | return null; |
| 1203 | } |
| 1204 | |
| 1205 | mDaemon.asBinder().linkToDeath(this, 0); |
| 1206 | |
| 1207 | try { |
| 1208 | mHalDeviceId = mDaemon.setCallback(mDaemonCallback).value; |
| 1209 | } catch (RemoteException e) { |
| 1210 | Slog.e(TAG, "Failed to open face HAL", e); |
| 1211 | mDaemon = null; // try again later! |
| 1212 | } |
| 1213 | |
| 1214 | if (DEBUG) Slog.v(TAG, "Face HAL id: " + mHalDeviceId); |
| 1215 | if (mHalDeviceId != 0) { |
| 1216 | loadAuthenticatorIds(); |
| 1217 | updateActiveGroup(ActivityManager.getCurrentUser(), null); |
Kevin Chyn | 6737c57 | 2019-02-08 16:10:54 -0800 | [diff] [blame] | 1218 | doTemplateCleanupForUser(ActivityManager.getCurrentUser()); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1219 | } else { |
| 1220 | Slog.w(TAG, "Failed to open Face HAL!"); |
| 1221 | MetricsLogger.count(getContext(), "faced_openhal_error", 1); |
| 1222 | mDaemon = null; |
| 1223 | } |
| 1224 | } |
| 1225 | return mDaemon; |
| 1226 | } |
| 1227 | |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1228 | private long startGenerateChallenge(IBinder token) { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1229 | IBiometricsFace daemon = getFaceDaemon(); |
| 1230 | if (daemon == null) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1231 | Slog.w(TAG, "startGenerateChallenge: no face HAL!"); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1232 | return 0; |
| 1233 | } |
| 1234 | try { |
Kevin Chyn | e46a216 | 2018-09-20 18:43:01 -0700 | [diff] [blame] | 1235 | return daemon.generateChallenge(CHALLENGE_TIMEOUT_SEC).value; |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1236 | } catch (RemoteException e) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1237 | Slog.e(TAG, "startGenerateChallenge failed", e); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1238 | } |
| 1239 | return 0; |
| 1240 | } |
| 1241 | |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1242 | private int startRevokeChallenge(IBinder token) { |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1243 | IBiometricsFace daemon = getFaceDaemon(); |
| 1244 | if (daemon == null) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1245 | Slog.w(TAG, "startRevokeChallenge: no face HAL!"); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1246 | return 0; |
| 1247 | } |
| 1248 | try { |
Kevin Chyn | 96c9297 | 2018-08-31 16:09:31 -0700 | [diff] [blame] | 1249 | return daemon.revokeChallenge(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1250 | } catch (RemoteException e) { |
Kevin Chyn | d79e24e | 2018-09-25 12:06:59 -0700 | [diff] [blame] | 1251 | Slog.e(TAG, "startRevokeChallenge failed", e); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1252 | } |
| 1253 | return 0; |
| 1254 | } |
| 1255 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1256 | private void dumpInternal(PrintWriter pw) { |
| 1257 | JSONObject dump = new JSONObject(); |
| 1258 | try { |
| 1259 | dump.put("service", "Face Manager"); |
| 1260 | |
| 1261 | JSONArray sets = new JSONArray(); |
| 1262 | for (UserInfo user : UserManager.get(getContext()).getUsers()) { |
| 1263 | final int userId = user.getUserHandle().getIdentifier(); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1264 | final int N = getBiometricUtils().getBiometricsForUser(getContext(), userId).size(); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1265 | PerformanceStats stats = mPerformanceMap.get(userId); |
| 1266 | PerformanceStats cryptoStats = mCryptoPerformanceMap.get(userId); |
| 1267 | JSONObject set = new JSONObject(); |
| 1268 | set.put("id", userId); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1269 | set.put("count", N); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1270 | set.put("accept", (stats != null) ? stats.accept : 0); |
| 1271 | set.put("reject", (stats != null) ? stats.reject : 0); |
| 1272 | set.put("acquire", (stats != null) ? stats.acquire : 0); |
| 1273 | set.put("lockout", (stats != null) ? stats.lockout : 0); |
| 1274 | set.put("permanentLockout", (stats != null) ? stats.permanentLockout : 0); |
| 1275 | // cryptoStats measures statistics about secure face transactions |
| 1276 | // (e.g. to unlock password storage, make secure purchases, etc.) |
| 1277 | set.put("acceptCrypto", (cryptoStats != null) ? cryptoStats.accept : 0); |
| 1278 | set.put("rejectCrypto", (cryptoStats != null) ? cryptoStats.reject : 0); |
| 1279 | set.put("acquireCrypto", (cryptoStats != null) ? cryptoStats.acquire : 0); |
| 1280 | set.put("lockoutCrypto", (cryptoStats != null) ? cryptoStats.lockout : 0); |
Kevin Chyn | a56dff7 | 2018-06-19 18:41:12 -0700 | [diff] [blame] | 1281 | set.put("permanentLockoutCrypto", |
| 1282 | (cryptoStats != null) ? cryptoStats.permanentLockout : 0); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1283 | sets.put(set); |
| 1284 | } |
| 1285 | |
| 1286 | dump.put("prints", sets); |
| 1287 | } catch (JSONException e) { |
| 1288 | Slog.e(TAG, "dump formatting failure", e); |
| 1289 | } |
| 1290 | pw.println(dump); |
Kevin Chyn | 9bc1d49 | 2019-06-21 15:31:50 -0700 | [diff] [blame] | 1291 | pw.println("HAL deaths since last reboot: " + mHALDeathCount); |
| 1292 | |
| 1293 | mUsageStats.print(pw); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 1294 | } |
| 1295 | |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 1296 | private void dumpHal(FileDescriptor fd, String[] args) { |
Joe Onorato | bf955d2 | 2019-03-25 00:16:58 -0700 | [diff] [blame] | 1297 | // WARNING: CDD restricts image data from leaving TEE unencrypted on |
| 1298 | // production devices: |
| 1299 | // [C-1-10] MUST not allow unencrypted access to identifiable biometric |
| 1300 | // data or any data derived from it (such as embeddings) to the |
| 1301 | // Application Processor outside the context of the TEE. |
| 1302 | // As such, this API should only be enabled for testing purposes on |
| 1303 | // engineering and userdebug builds. All modules in the software stack |
| 1304 | // MUST enforce final build products do NOT have this functionality. |
| 1305 | // Additionally, the following check MUST NOT be removed. |
| 1306 | if (!(Build.IS_ENG || Build.IS_USERDEBUG)) { |
| 1307 | return; |
| 1308 | } |
| 1309 | |
Joe Onorato | 108413a | 2019-04-03 18:20:52 -0700 | [diff] [blame] | 1310 | // Additionally, this flag allows turning off face for a device |
| 1311 | // (either permanently through the build or on an individual device). |
| 1312 | if (SystemProperties.getBoolean("ro.face.disable_debug_data", false) |
| 1313 | || SystemProperties.getBoolean("persist.face.disable_debug_data", false)) { |
| 1314 | return; |
| 1315 | } |
| 1316 | |
Joe Onorato | db39600 | 2019-04-05 19:49:27 -0700 | [diff] [blame] | 1317 | // The debug method takes two file descriptors. The first is for text |
| 1318 | // output, which we will drop. The second is for binary data, which |
| 1319 | // will be the protobuf data. |
| 1320 | final IBiometricsFace daemon = getFaceDaemon(); |
| 1321 | if (daemon != null) { |
| 1322 | FileOutputStream devnull = null; |
| 1323 | try { |
| 1324 | devnull = new FileOutputStream("/dev/null"); |
| 1325 | final NativeHandle handle = new NativeHandle( |
| 1326 | new FileDescriptor[] { devnull.getFD(), fd }, |
| 1327 | new int[0], false); |
| 1328 | daemon.debug(handle, new ArrayList<String>(Arrays.asList(args))); |
| 1329 | } catch (IOException | RemoteException ex) { |
| 1330 | Slog.d(TAG, "error while reading face debugging data", ex); |
| 1331 | } finally { |
| 1332 | if (devnull != null) { |
| 1333 | try { |
| 1334 | devnull.close(); |
| 1335 | } catch (IOException ex) { |
| 1336 | } |
| 1337 | } |
| 1338 | } |
Joe Onorato | bf955d2 | 2019-03-25 00:16:58 -0700 | [diff] [blame] | 1339 | } |
Joe Onorato | bf955d2 | 2019-03-25 00:16:58 -0700 | [diff] [blame] | 1340 | } |
Kevin Chyn | 8b7a037 | 2018-09-17 15:06:05 -0700 | [diff] [blame] | 1341 | } |