From 9128a5a37abfba7974d80222b0bf9db61705d85e Mon Sep 17 00:00:00 2001 From: Anthony Chen Date: Tue, 25 Jun 2019 09:50:56 -0700 Subject: [PATCH] Allow trust agents to actively unlock for automotive. This CL creates an exception for the default behavior of trust agents. After b/120871688, trust agents can only extend unlock. However, automotive still requires active unlock for its feature set. Fixes: 135931998 Test: Verify that an enrolled trust agent can dismiss the lock screen on automotive. Change-Id: Ie7c411ac2bfac9ba00c095532d6788d9e2e7af2f --- .../com/android/server/trust/TrustManagerService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java index d6a9f42738a17..7408dd40b5cad 100644 --- a/services/core/java/com/android/server/trust/TrustManagerService.java +++ b/services/core/java/com/android/server/trust/TrustManagerService.java @@ -199,6 +199,7 @@ public class TrustManagerService extends SystemService { private final Uri LOCK_SCREEN_WHEN_TRUST_LOST = Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST); + private final boolean mIsAutomotive; private final ContentResolver mContentResolver; private boolean mTrustAgentsExtendUnlock; private boolean mLockWhenTrustLost; @@ -210,6 +211,10 @@ public class TrustManagerService extends SystemService { */ SettingsObserver(Handler handler) { super(handler); + + PackageManager packageManager = getContext().getPackageManager(); + mIsAutomotive = packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); + mContentResolver = getContext().getContentResolver(); updateContentObserver(); } @@ -233,11 +238,15 @@ public class TrustManagerService extends SystemService { @Override public void onChange(boolean selfChange, Uri uri) { if (TRUST_AGENTS_EXTEND_UNLOCK.equals(uri)) { + // Smart lock should only extend unlock. The only exception is for automotive, + // where it can actively unlock the head unit. + int defaultValue = mIsAutomotive ? 0 : 1; + mTrustAgentsExtendUnlock = Settings.Secure.getIntForUser( mContentResolver, Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, - 1 /* default */, + defaultValue, mCurrentUser) != 0; } else if (LOCK_SCREEN_WHEN_TRUST_LOST.equals(uri)) { mLockWhenTrustLost =