Add FingerprintDialog API and related plumbing
This commit adds the plumbing which sends the signals from the API
to the component in SysUI. The dialog will be implemented in another
CL in this topic.
Bug: 67497360
Test: Modify Settings to use the new API
Test: FingerprintDialogImpl is able to notify FingerprintDialog clients
of user events
Test: System dialog is dismissed when client application is killed
unexpectedly
Test: Open FP settings, lock device, authenticate, authenticate. Repeat
Change-Id: Id28ec9691646bed765dc069cceb4678d9f6db92e
diff --git a/packages/SystemUI/Android.mk b/packages/SystemUI/Android.mk
index 73fcdd7..251ae2d 100644
--- a/packages/SystemUI/Android.mk
+++ b/packages/SystemUI/Android.mk
@@ -27,7 +27,12 @@
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
+RELATIVE_FINGERPRINT_PATH := ../../core/java/android/hardware/fingerprint
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src) \
+ $(call all-Iaidl-files-under, src) \
+ $(call all-Iaidl-files-under, $(RELATIVE_FINGERPRINT_PATH))
LOCAL_STATIC_ANDROID_LIBRARIES := \
SystemUIPluginLib \
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index b33f857..6768470 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -350,6 +350,7 @@
<item>com.android.systemui.globalactions.GlobalActionsComponent</item>
<item>com.android.systemui.RoundedCorners</item>
<item>com.android.systemui.EmulatedDisplayCutout</item>
+ <item>com.android.systemui.fingerprint.FingerprintDialogImpl</item>
</string-array>
<!-- SystemUI vender service, used in config_systemUIServiceComponents. -->
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 19afcf5..9e4b405 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -1257,7 +1257,8 @@
mFingerprintCancelSignal.cancel();
}
mFingerprintCancelSignal = new CancellationSignal();
- mFpm.authenticate(null, mFingerprintCancelSignal, 0, mAuthenticationCallback, null, userId);
+ mFpm.authenticate(null, mFingerprintCancelSignal, 0, mAuthenticationCallback, null,
+ userId);
setFingerprintRunningState(FINGERPRINT_STATE_RUNNING);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java
new file mode 100644
index 0000000..8b6f95c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.fingerprint;
+
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.IFingerprintDialogReceiver;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.android.systemui.SystemUI;
+import com.android.systemui.statusbar.CommandQueue;
+
+public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Callbacks {
+ private static final String TAG = "FingerprintDialogImpl";
+ private static final boolean DEBUG = false;
+
+ @Override
+ public void start() {
+ if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
+ return;
+ }
+ getComponent(CommandQueue.class).addCallbacks(this);
+ }
+
+ @Override
+ public void showFingerprintDialog(Bundle bundle, IFingerprintDialogReceiver receiver) {
+ if (DEBUG) Log.d(TAG, "show fingerprint dialog");
+ }
+
+ @Override
+ public void onFingerprintAuthenticated() {
+ if (DEBUG) Log.d(TAG, "onFingerprintAuthenticated");
+ }
+
+ @Override
+ public void onFingerprintHelp(String message) {
+ if (DEBUG) Log.d(TAG, "onFingerprintHelp: " + message);
+ }
+
+ @Override
+ public void onFingerprintError(String error) {
+ if (DEBUG) Log.d(TAG, "onFingerprintError: " + error);
+ }
+
+ @Override
+ public void hideFingerprintDialog() {
+ if (DEBUG) Log.d(TAG, "hideFingerprintDialog");
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index c6abcf2..00bc62e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -18,6 +18,7 @@
import android.content.ComponentName;
import android.graphics.Rect;
+import android.hardware.fingerprint.IFingerprintDialogReceiver;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -83,6 +84,11 @@
private static final int MSG_SHOW_SHUTDOWN_UI = 36 << MSG_SHIFT;
private static final int MSG_SET_TOP_APP_HIDES_STATUS_BAR = 37 << MSG_SHIFT;
private static final int MSG_ROTATION_PROPOSAL = 38 << MSG_SHIFT;
+ private static final int MSG_FINGERPRINT_SHOW = 39 << MSG_SHIFT;
+ private static final int MSG_FINGERPRINT_AUTHENTICATED = 40 << MSG_SHIFT;
+ private static final int MSG_FINGERPRINT_HELP = 41 << MSG_SHIFT;
+ private static final int MSG_FINGERPRINT_ERROR = 42 << MSG_SHIFT;
+ private static final int MSG_FINGERPRINT_HIDE = 43 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -145,6 +151,12 @@
default void handleShowShutdownUi(boolean isReboot, String reason) { }
default void onRotationProposal(int rotation, boolean isValid) { }
+
+ default void showFingerprintDialog(Bundle bundle, IFingerprintDialogReceiver receiver) { }
+ default void onFingerprintAuthenticated() { }
+ default void onFingerprintHelp(String message) { }
+ default void onFingerprintError(String error) { }
+ default void hideFingerprintDialog() { }
}
@VisibleForTesting
@@ -470,6 +482,45 @@
}
}
+ @Override
+ public void showFingerprintDialog(Bundle bundle, IFingerprintDialogReceiver receiver) {
+ synchronized (mLock) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = bundle;
+ args.arg2 = receiver;
+ mHandler.obtainMessage(MSG_FINGERPRINT_SHOW, args)
+ .sendToTarget();
+ }
+ }
+
+ @Override
+ public void onFingerprintAuthenticated() {
+ synchronized (mLock) {
+ mHandler.obtainMessage(MSG_FINGERPRINT_AUTHENTICATED).sendToTarget();
+ }
+ }
+
+ @Override
+ public void onFingerprintHelp(String message) {
+ synchronized (mLock) {
+ mHandler.obtainMessage(MSG_FINGERPRINT_HELP, message).sendToTarget();
+ }
+ }
+
+ @Override
+ public void onFingerprintError(String error) {
+ synchronized (mLock) {
+ mHandler.obtainMessage(MSG_FINGERPRINT_ERROR, error).sendToTarget();
+ }
+ }
+
+ @Override
+ public void hideFingerprintDialog() {
+ synchronized (mLock) {
+ mHandler.obtainMessage(MSG_FINGERPRINT_HIDE).sendToTarget();
+ }
+ }
+
private final class H extends Handler {
private H(Looper l) {
super(l);
@@ -671,6 +722,35 @@
mCallbacks.get(i).onRotationProposal(msg.arg1, msg.arg2 != 0);
}
break;
+ case MSG_FINGERPRINT_SHOW:
+ mHandler.removeMessages(MSG_FINGERPRINT_ERROR);
+ mHandler.removeMessages(MSG_FINGERPRINT_HELP);
+ mHandler.removeMessages(MSG_FINGERPRINT_AUTHENTICATED);
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).showFingerprintDialog(
+ (Bundle)((SomeArgs)msg.obj).arg1,
+ (IFingerprintDialogReceiver)((SomeArgs)msg.obj).arg2);
+ }
+ break;
+ case MSG_FINGERPRINT_AUTHENTICATED:
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onFingerprintAuthenticated();
+ }
+ break;
+ case MSG_FINGERPRINT_HELP:
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onFingerprintHelp((String) msg.obj);
+ }
+ break;
+ case MSG_FINGERPRINT_ERROR:
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).onFingerprintError((String) msg.obj);
+ }
+ break;
+ case MSG_FINGERPRINT_HIDE:
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ mCallbacks.get(i).hideFingerprintDialog();
+ }
}
}
}