diff options
| author | 2023-10-10 19:35:22 +0000 | |
|---|---|---|
| committer | 2023-10-10 19:35:22 +0000 | |
| commit | 728bbd56b709a6ffe3585d12ccada1a1f81eb00c (patch) | |
| tree | a8721b139b69e387e73ac72e0828eb5eca4a2344 | |
| parent | 163336f273dd9eea247d31ba389082be843968ef (diff) | |
| parent | 3b12b17ea4dfede30e8cf4414ff042abd361bf7e (diff) | |
Merge "Remove obsolete Smart Lock developer settings" into main am: a1bb1ff8ff am: 3b12b17ea4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2731260
Change-Id: Ia820723201df013e9572574aceafcc16cf9d5a6a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
4 files changed, 7 insertions, 131 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index baeb1aa71207..9cdb9cefdc43 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -10442,20 +10442,6 @@ public final class Settings { "assist_long_press_home_enabled"; /** - * Control whether Trust Agents are in active unlock or extend unlock mode. - * @hide - */ - @Readable - public static final String TRUST_AGENTS_EXTEND_UNLOCK = "trust_agents_extend_unlock"; - - /** - * Control whether the screen locks when trust is lost. - * @hide - */ - @Readable - public static final String LOCK_SCREEN_WHEN_TRUST_LOST = "lock_screen_when_trust_lost"; - - /** * Control whether Night display is currently activated. * @hide */ diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java index 3efb41dbfe5c..cf26937cbd88 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java @@ -163,12 +163,10 @@ public class SecureSettings { Settings.Secure.CHARGING_VIBRATION_ENABLED, Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, - Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, Settings.Secure.UI_NIGHT_MODE, Settings.Secure.UI_NIGHT_MODE_CUSTOM_TYPE, Settings.Secure.DARK_THEME_CUSTOM_START_TIME, Settings.Secure.DARK_THEME_CUSTOM_END_TIME, - Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, Settings.Secure.SKIP_DIRECTION, Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT, diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index f6c2f6918739..f78f2028d7b6 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -242,9 +242,7 @@ public class SecureSettingsValidators { Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, NON_NEGATIVE_INTEGER_VALIDATOR); VALIDATORS.put(Secure.USER_SETUP_COMPLETE, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.ASSIST_GESTURE_SETUP_COMPLETE, BOOLEAN_VALIDATOR); - VALIDATORS.put(Secure.TRUST_AGENTS_EXTEND_UNLOCK, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE, JSON_OBJECT_VALIDATOR); - VALIDATORS.put(Secure.LOCK_SCREEN_WHEN_TRUST_LOST, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.SKIP_GESTURE, BOOLEAN_VALIDATOR); /* * Only used if FeatureFlag "settings_skip_direction_mutable" is enabled. diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java index 21bfdd87195d..635e11be3a16 100644 --- a/services/core/java/com/android/server/trust/TrustManagerService.java +++ b/services/core/java/com/android/server/trust/TrustManagerService.java @@ -31,7 +31,6 @@ import android.app.trust.ITrustListener; import android.app.trust.ITrustManager; import android.content.BroadcastReceiver; import android.content.ComponentName; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -42,11 +41,9 @@ import android.content.pm.UserInfo; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; -import android.database.ContentObserver; import android.graphics.drawable.Drawable; import android.hardware.biometrics.BiometricManager; import android.hardware.biometrics.BiometricSourceType; -import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Bundle; @@ -237,7 +234,6 @@ public class TrustManagerService extends SystemService { mIdleTrustableTimeoutAlarmListenerForUser = new SparseArray<>(); private AlarmManager mAlarmManager; private final Object mAlarmLock = new Object(); - private final SettingsObserver mSettingsObserver; private final StrongAuthTracker mStrongAuthTracker; @@ -279,7 +275,6 @@ public class TrustManagerService extends SystemService { mLockPatternUtils = injector.getLockPatternUtils(); mStrongAuthTracker = new StrongAuthTracker(context, injector.getLooper()); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); - mSettingsObserver = new SettingsObserver(mHandler); } @Override @@ -307,103 +302,10 @@ public class TrustManagerService extends SystemService { } } - // Extend unlock config and logic - private final class SettingsObserver extends ContentObserver { - private final Uri TRUST_AGENTS_EXTEND_UNLOCK = - Settings.Secure.getUriFor(Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK); - - 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 mTrustAgentsNonrenewableTrust; - private boolean mLockWhenTrustLost; - - /** - * Creates a settings observer - * - * @param handler The handler to run {@link #onChange} on, or null if none. - */ - SettingsObserver(Handler handler) { - super(handler); - - PackageManager packageManager = getContext().getPackageManager(); - mIsAutomotive = packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); - - mContentResolver = getContext().getContentResolver(); - updateContentObserver(); - } - - void updateContentObserver() { - mContentResolver.unregisterContentObserver(this); - mContentResolver.registerContentObserver(TRUST_AGENTS_EXTEND_UNLOCK, - false /* notifyForDescendents */, - this /* observer */, - mCurrentUser); - mContentResolver.registerContentObserver(LOCK_SCREEN_WHEN_TRUST_LOST, - false /* notifyForDescendents */, - this /* observer */, - mCurrentUser); - - // Update the value immediately - onChange(true /* selfChange */, TRUST_AGENTS_EXTEND_UNLOCK); - onChange(true /* selfChange */, LOCK_SCREEN_WHEN_TRUST_LOST); - } - - @Override - public void onChange(boolean selfChange, Uri uri) { - if (TRUST_AGENTS_EXTEND_UNLOCK.equals(uri)) { - // Smart lock should only grant non-renewable trust. The only exception is for - // automotive, where it can actively unlock the head unit. - int defaultValue = mIsAutomotive ? 0 : 1; - - mTrustAgentsNonrenewableTrust = - Settings.Secure.getIntForUser( - mContentResolver, - Settings.Secure.TRUST_AGENTS_EXTEND_UNLOCK, - defaultValue, - mCurrentUser) != 0; - } else if (LOCK_SCREEN_WHEN_TRUST_LOST.equals(uri)) { - mLockWhenTrustLost = - Settings.Secure.getIntForUser( - mContentResolver, - Settings.Secure.LOCK_SCREEN_WHEN_TRUST_LOST, - 0 /* default */, - mCurrentUser) != 0; - } - } - - boolean getTrustAgentsNonrenewableTrust() { - return mTrustAgentsNonrenewableTrust; - } - - boolean getLockWhenTrustLost() { - return mLockWhenTrustLost; - } - } - - private void maybeLockScreen(int userId) { - if (userId != mCurrentUser) { - return; - } - - if (mSettingsObserver.getLockWhenTrustLost()) { - if (DEBUG) Slog.d(TAG, "Locking device because trust was lost"); - try { - WindowManagerGlobal.getWindowManagerService().lockNow(null); - } catch (RemoteException e) { - Slog.e(TAG, "Error locking screen when trust was lost"); - } - - // If active unlocking is not allowed, cancel any pending trust timeouts because the - // screen is already locked. - TrustedTimeoutAlarmListener alarm = mTrustTimeoutAlarmListenerForUser.get(userId); - if (alarm != null && mSettingsObserver.getTrustAgentsNonrenewableTrust()) { - mAlarmManager.cancel(alarm); - alarm.setQueued(false /* isQueued */); - } - } + // Automotive head units can be unlocked by a trust agent, even when the agent doesn't use + // FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE. + private boolean isAutomotive() { + return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } private void scheduleTrustTimeout(boolean override, boolean isTrustableTimeout) { @@ -600,12 +502,10 @@ public class TrustManagerService extends SystemService { synchronized (mUserTrustState) { wasTrusted = (mUserTrustState.get(userId) == TrustState.TRUSTED); wasTrustable = (mUserTrustState.get(userId) == TrustState.TRUSTABLE); - boolean isAutomotive = getContext().getPackageManager().hasSystemFeature( - PackageManager.FEATURE_AUTOMOTIVE); boolean renewingTrust = wasTrustable && ( (flags & TrustAgentService.FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) != 0); boolean canMoveToTrusted = - alreadyUnlocked || isFromUnlock || renewingTrust || isAutomotive; + alreadyUnlocked || isFromUnlock || renewingTrust || isAutomotive(); boolean upgradingTrustForCurrentUser = (userId == mCurrentUser); if (trustedByAtLeastOneAgent && wasTrusted) { @@ -632,9 +532,7 @@ public class TrustManagerService extends SystemService { isNowTrusted, newlyUnlocked, userId, flags, getTrustGrantedMessages(userId)); if (isNowTrusted != wasTrusted) { refreshDeviceLockedForUser(userId); - if (!isNowTrusted) { - maybeLockScreen(userId); - } else { + if (isNowTrusted) { boolean isTrustableTimeout = (flags & FLAG_GRANT_TRUST_TEMPORARY_AND_RENEWABLE) != 0; // Every time we grant renewable trust we should override the idle trustable @@ -1855,9 +1753,7 @@ public class TrustManagerService extends SystemService { synchronized(mUsersUnlockedByBiometric) { mUsersUnlockedByBiometric.put(userId, true); } - // In non-renewable trust mode we need to refresh trust state here, which will call - // refreshDeviceLockedForUser() - int updateTrustOnUnlock = mSettingsObserver.getTrustAgentsNonrenewableTrust() ? 1 : 0; + int updateTrustOnUnlock = isAutomotive() ? 0 : 1; mHandler.obtainMessage(MSG_REFRESH_DEVICE_LOCKED_FOR_USER, userId, updateTrustOnUnlock).sendToTarget(); mHandler.obtainMessage(MSG_REFRESH_TRUSTABLE_TIMERS_AFTER_AUTH, userId).sendToTarget(); @@ -1966,7 +1862,6 @@ public class TrustManagerService extends SystemService { break; case MSG_SWITCH_USER: mCurrentUser = msg.arg1; - mSettingsObserver.updateContentObserver(); refreshDeviceLockedForUser(UserHandle.USER_ALL); break; case MSG_STOP_USER: @@ -2196,7 +2091,6 @@ public class TrustManagerService extends SystemService { mLockPatternUtils.requireStrongAuth( mStrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED, mUserId); } - maybeLockScreen(mUserId); } protected abstract void handleAlarm(); |