diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-05-13 16:30:04 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-05-13 16:35:56 -0700 |
commit | aa4d32add72fa728f9cfe4eeb014b26eb5d091c2 (patch) | |
tree | 3d18a2c573dc5d00a5e89512ba224909a85e8cf0 /services/core/java/com/android/server/fingerprint | |
parent | 827e0facfefd0c0033dcfb1747b4fa6f80f9e0e2 (diff) | |
download | frameworks_base-aa4d32add72fa728f9cfe4eeb014b26eb5d091c2.zip frameworks_base-aa4d32add72fa728f9cfe4eeb014b26eb5d091c2.tar.gz frameworks_base-aa4d32add72fa728f9cfe4eeb014b26eb5d091c2.tar.bz2 |
Fix fingerprint for multiuser
Change-Id: Iab18c4de9764da1a65490b186b33535f8e79e1e5
Diffstat (limited to 'services/core/java/com/android/server/fingerprint')
-rw-r--r-- | services/core/java/com/android/server/fingerprint/FingerprintService.java | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java index 0faccc6..2edfdf0 100644 --- a/services/core/java/com/android/server/fingerprint/FingerprintService.java +++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java @@ -17,13 +17,16 @@ package com.android.server.fingerprint; import android.app.ActivityManager; +import android.app.ActivityManagerNative; import android.app.AppOpsManager; +import android.app.IUserSwitchObserver; import android.content.ContentResolver; import android.content.Context; import android.os.Binder; import android.os.Environment; import android.os.Handler; import android.os.IBinder; +import android.os.IRemoteCallback; import android.os.Looper; import android.os.MessageQueue; import android.os.RemoteException; @@ -63,6 +66,7 @@ public class FingerprintService extends SystemService { private final AppOpsManager mAppOps; private static final int MSG_NOTIFY = 10; + private static final int MSG_USER_SWITCHING = 11; private static final int ENROLLMENT_TIMEOUT_MS = 60 * 1000; // 1 minute @@ -85,6 +89,10 @@ public class FingerprintService extends SystemService { handleNotify(m.type, m.arg1, m.arg2, m.arg3); break; + case MSG_USER_SWITCHING: + handleUserSwitching(msg.arg1); + break; + default: Slog.w(TAG, "Unknown message:" + msg.what); } @@ -144,7 +152,7 @@ public class FingerprintService extends SystemService { void handleNotify(int type, int arg1, int arg2, int arg3) { Slog.v(TAG, "handleNotify(type=" + type + ", arg1=" + arg1 + ", arg2=" + arg2 + ")" - + ", mAuthClients = " + mAuthClient + ", mEnrollClient = " + mEnrollClient); + + ", mAuthClients = " + mAuthClient + ", mEnrollClient = " + mEnrollClient); if (mEnrollClient != null) { final IBinder token = mEnrollClient.token; if (dispatchNotify(mEnrollClient, type, arg1, arg2, arg3)) { @@ -166,6 +174,10 @@ public class FingerprintService extends SystemService { } } + void handleUserSwitching(int userId) { + updateActiveGroup(userId); + } + /* * Dispatch notify events to clients. * @@ -633,11 +645,37 @@ public class FingerprintService extends SystemService { publishBinderService(Context.FINGERPRINT_SERVICE, new FingerprintServiceWrapper()); mHalDeviceId = nativeOpenHal(); if (mHalDeviceId != 0) { - int userId = ActivityManager.getCurrentUser(); - File path = Environment.getUserSystemDirectory(userId); - nativeSetActiveGroup(0, path.getAbsolutePath().getBytes()); + updateActiveGroup(ActivityManager.getCurrentUser()); } if (DEBUG) Slog.v(TAG, "Fingerprint HAL id: " + mHalDeviceId); + listenForUserSwitches(); } + private void updateActiveGroup(int userId) { + File path = Environment.getUserSystemDirectory(userId); + nativeSetActiveGroup(userId, path.getAbsolutePath().getBytes()); + } + + private void listenForUserSwitches() { + try { + ActivityManagerNative.getDefault().registerUserSwitchObserver( + new IUserSwitchObserver.Stub() { + @Override + public void onUserSwitching(int newUserId, IRemoteCallback reply) { + mHandler.obtainMessage(MSG_USER_SWITCHING, newUserId, 0 /* unused */) + .sendToTarget(); + } + @Override + public void onUserSwitchComplete(int newUserId) throws RemoteException { + // Ignore. + } + @Override + public void onForegroundProfileSwitch(int newProfileId) { + // Ignore. + } + }); + } catch (RemoteException e) { + Slog.w(TAG, "Failed to listen for user switching event" ,e); + } + } } |