OSDN Git Service

Add check for the device having "feature face" before requesting the service
authorMady Mellor <madym@google.com>
Tue, 25 Jun 2019 21:31:19 +0000 (14:31 -0700)
committerMady Mellor <madym@google.com>
Tue, 25 Jun 2019 21:44:42 +0000 (14:44 -0700)
Personally, I think it'd be better for the service to return null rather
than throwing an error if it doesn't exisit but according to b/ throwing
is WAI.

Test: try running any test that might use ExandableNotificationRow on a
      device without face service and see that an exception isn't thrown
Bug: 135475155
Change-Id: I6cf7f3d39f411dc88d5fd75da0adb2c612acf880

packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt

index 58d1462..3f1cb6c 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.systemui.statusbar.phone
 
 import android.content.Context
+import android.content.pm.PackageManager
 import android.hardware.biometrics.BiometricSourceType
 import android.hardware.face.FaceManager
 import android.provider.Settings
@@ -73,6 +74,9 @@ class KeyguardBypassController {
                 }
             }
         })
+        if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
+            return
+        }
         val faceManager = context.getSystemService(FaceManager::class.java)
         if (faceManager?.isHardwareDetected != true) {
             return