diff options
author | Alex Klyubin <klyubin@google.com> | 2015-04-30 13:30:48 -0700 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2015-04-30 13:34:58 -0700 |
commit | 24e9e966a85c416a94482fcd10dbdd10ceeb9e6c (patch) | |
tree | 3903d86307cd2a647e327ffccbb818b96ca35ea4 | |
parent | 033dc46bb949a9a5e42ed51bbff1e055a7c58ca2 (diff) | |
download | frameworks_base-24e9e966a85c416a94482fcd10dbdd10ceeb9e6c.zip frameworks_base-24e9e966a85c416a94482fcd10dbdd10ceeb9e6c.tar.gz frameworks_base-24e9e966a85c416a94482fcd10dbdd10ceeb9e6c.tar.bz2 |
Fix thread affinity of FingerprintManager.
FingerprintManager internally creates a Handler which needs to be
bound to a Looper thread. Prior to this CL the Handler was bound to
the Looper of the current thread. This caused issues:
* Different instances of FingerprintManager could be bound to
different Looper threads.
* Callbacks from FingerprintManager were invoked on arbitrary
threads (or not at all if the Looper was there but wasn't running).
* FingerprintManager couldn't be obtained by apps on most non-main
threads leading to java.lang.RuntimeException: Can't create handler
inside thread that has not called Looper.prepare().
This CL fixes the issue by binding the FingerprintManager's Handler to
the Looper running on the main thread.
Bug: 20725228
Change-Id: I4a0382d6e11df9f23b8db9f0deec77369af31b5e
-rw-r--r-- | core/java/android/hardware/fingerprint/FingerprintManager.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index 779448b..cf96145 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -626,7 +626,13 @@ public class FingerprintManager { return 0; } - private Handler mHandler = new Handler() { + private Handler mHandler; + + private class MyHandler extends Handler { + private MyHandler(Context context) { + super(context.getMainLooper()); + } + public void handleMessage(android.os.Message msg) { switch(msg.what) { case MSG_ENROLL_RESULT: @@ -711,6 +717,7 @@ public class FingerprintManager { if (mService == null) { Slog.v(TAG, "FingerprintManagerService was null"); } + mHandler = new MyHandler(context); } private int getCurrentUserId() { |