Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a3bf7c4 authored by Adrian Roos's avatar Adrian Roos
Browse files

Allow LockPatternUtils usage on non-looper threads

Fixes an issue where LPU could no longer
be used on a non-looper thread even though
the looper is only used for a certain callback.

Now only using that callback mechanism is fatal
on a non-looper thread.

Change-Id: I2d766bd6c913e345ed6a3500b486263c8bc12b07
Fixes: 30076804
parent a8b4e732
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ public class LockPatternUtils {
    private DevicePolicyManager mDevicePolicyManager;
    private ILockSettings mLockSettingsService;
    private UserManager mUserManager;
    private final Handler mHandler = new Handler();
    private final Handler mHandler;

    /**
     * Use {@link TrustManager#isTrustUsuallyManaged(int)}.
@@ -231,6 +231,9 @@ public class LockPatternUtils {
    public LockPatternUtils(Context context) {
        mContext = context;
        mContentResolver = context.getContentResolver();

        Looper looper = Looper.myLooper();
        mHandler = looper != null ? new Handler(looper) : null;
    }

    private ILockSettings getLockSettings() {
@@ -1506,6 +1509,10 @@ public class LockPatternUtils {
        if (callback == null) {
            return null;
        } else {
            if (mHandler == null) {
                throw new IllegalStateException("Must construct LockPatternUtils on a looper thread"
                        + " to use progress callbacks.");
            }
            return new ICheckCredentialProgressCallback.Stub() {

                @Override