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

Commit ab420232 authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Merge remote-tracking branch 'origin/lineage-16.0' into v1-pie

parents 49052a40 a179062a
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
    private final LockPatternUtils mLockPatternUtils;
    private final StateCallback mCallback;

    private IUsbRestrict mUsbRestrictor;
    private IUsbRestrict mUsbRestrictor = null;
    private ContentResolver mContentResolver;

    IKeystoreService mKeystoreService;
@@ -77,12 +77,6 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
        } catch (RemoteException e) {
            Slog.w(TAG, "Remote Exception", e);
        }

        try {
            mUsbRestrictor = IUsbRestrict.getService();
        } catch (NoSuchElementException | RemoteException ignored) {
            // Ignore, the hal is not available
        }
    }

    public boolean isShowing() {
@@ -116,6 +110,20 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
            Slog.e(TAG, "Error informing keystore of screen lock", e);
        }

        if (mUsbRestrictor == null) {
            try {
                mUsbRestrictor = IUsbRestrict.getService();
            } catch (NoSuchElementException | RemoteException ignored) {
                // Ignore, the hal is not available
                return;
            }
        }

        if (mUsbRestrictor == null) {
            // Return for now and retry on next time
            return;
        }

        boolean shouldRestrictUsb = LineageSettings.Secure.getInt(mContentResolver,
                LineageSettings.Secure.TRUST_RESTRICT_USB_KEYGUARD, 0) == 1;
        if (shouldRestrictUsb) {