TrustManagerService: remove ENABLE_ACTIVE_UNLOCK_FLAG
The system property fw.enable_active_unlock_flag defaults to true, and I
can't find any evidence that anyone is setting it. Therefore, the code
that handles the false case seems to be dead code. Remove this code.
Bug: 215724686
Test: atest TrustTests
Change-Id: I57de36bade75c457dc7f86225817899f70dc4e48
diff --git a/services/core/java/com/android/server/trust/TrustAgentWrapper.java b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
index 36293d5..86eb36c93 100644
--- a/services/core/java/com/android/server/trust/TrustAgentWrapper.java
+++ b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
@@ -120,9 +120,6 @@
private final BroadcastReceiver mTrustableDowngradeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (!TrustManagerService.ENABLE_ACTIVE_UNLOCK_FLAG) {
- return;
- }
// are these the broadcasts we want to listen to
if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
downgradeToTrustable();
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 1f0066b..dfd87ed 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -57,7 +57,6 @@
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.SystemClock;
-import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -161,10 +160,6 @@
@GuardedBy("mUserIsTrusted")
private final SparseBooleanArray mUserIsTrusted = new SparseBooleanArray();
- //TODO(b/215724686): remove flag
- public static final boolean ENABLE_ACTIVE_UNLOCK_FLAG = SystemProperties.getBoolean(
- "fw.enable_active_unlock_flag", true);
-
private enum TrustState {
UNTRUSTED, // the phone is not unlocked by any trustagents
TRUSTABLE, // the phone is in a semi-locked state that can be unlocked if
@@ -538,69 +533,6 @@
int flags,
boolean isFromUnlock,
@Nullable AndroidFuture<GrantTrustResult> resultCallback) {
- if (ENABLE_ACTIVE_UNLOCK_FLAG) {
- updateTrustWithRenewableUnlock(userId, flags, isFromUnlock, resultCallback);
- } else {
- updateTrustWithNonrenewableTrust(userId, flags, isFromUnlock);
- }
- }
-
- private void updateTrustWithNonrenewableTrust(int userId, int flags, boolean isFromUnlock) {
- boolean managed = aggregateIsTrustManaged(userId);
- dispatchOnTrustManagedChanged(managed, userId);
- if (mStrongAuthTracker.isTrustAllowedForUser(userId)
- && isTrustUsuallyManagedInternal(userId) != managed) {
- updateTrustUsuallyManaged(userId, managed);
- }
-
- boolean trusted = aggregateIsTrusted(userId);
- IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
- boolean showingKeyguard = true;
- try {
- showingKeyguard = wm.isKeyguardLocked();
- } catch (RemoteException e) {
- }
-
- boolean changed;
- synchronized (mUserIsTrusted) {
- if (mSettingsObserver.getTrustAgentsNonrenewableTrust()) {
- // For non-renewable trust agents can only set the device to trusted if it already
- // trusted or the device is unlocked. Attempting to set the device as trusted
- // when the device is locked will be ignored.
- changed = mUserIsTrusted.get(userId) != trusted;
- trusted = trusted
- && (!showingKeyguard || isFromUnlock || !changed)
- && userId == mCurrentUser;
- if (DEBUG) {
- Slog.d(TAG, "Extend unlock setting trusted as " + Boolean.toString(trusted)
- + " && " + Boolean.toString(!showingKeyguard)
- + " && " + Boolean.toString(userId == mCurrentUser));
- }
- }
- changed = mUserIsTrusted.get(userId) != trusted;
- mUserIsTrusted.put(userId, trusted);
- }
- dispatchOnTrustChanged(
- trusted,
- false /* newlyUnlocked */,
- userId,
- flags,
- getTrustGrantedMessages(userId));
- if (changed) {
- refreshDeviceLockedForUser(userId);
- if (!trusted) {
- maybeLockScreen(userId);
- } else {
- scheduleTrustTimeout(false /* override */, false /* isTrustableTimeout*/);
- }
- }
- }
-
- private void updateTrustWithRenewableUnlock(
- int userId,
- int flags,
- boolean isFromUnlock,
- @Nullable AndroidFuture<GrantTrustResult> resultCallback) {
boolean managed = aggregateIsTrustManaged(userId);
dispatchOnTrustManagedChanged(managed, userId);
if (mStrongAuthTracker.isTrustAllowedForUser(userId)
@@ -2144,16 +2076,11 @@
@Override
public void handleAlarm() {
- TrustableTimeoutAlarmListener otherAlarm;
- boolean otherAlarmPresent;
- if (ENABLE_ACTIVE_UNLOCK_FLAG) {
- otherAlarm = mTrustableTimeoutAlarmListenerForUser.get(mUserId);
- otherAlarmPresent = (otherAlarm != null) && otherAlarm.isQueued();
- if (otherAlarmPresent) {
- synchronized (mAlarmLock) {
- disableNonrenewableTrustWhileRenewableTrustIsPresent();
- }
- return;
+ TrustableTimeoutAlarmListener otherAlarm =
+ mTrustableTimeoutAlarmListenerForUser.get(mUserId);
+ if (otherAlarm != null && otherAlarm.isQueued()) {
+ synchronized (mAlarmLock) {
+ disableNonrenewableTrustWhileRenewableTrustIsPresent();
}
}
}
@@ -2178,17 +2105,11 @@
@Override
public void handleAlarm() {
- TrustedTimeoutAlarmListener otherAlarm;
- boolean otherAlarmPresent;
- if (ENABLE_ACTIVE_UNLOCK_FLAG) {
- cancelBothTrustableAlarms(mUserId);
- otherAlarm = mTrustTimeoutAlarmListenerForUser.get(mUserId);
- otherAlarmPresent = (otherAlarm != null) && otherAlarm.isQueued();
- if (otherAlarmPresent) {
- synchronized (mAlarmLock) {
- disableRenewableTrustWhileNonrenewableTrustIsPresent();
- }
- return;
+ cancelBothTrustableAlarms(mUserId);
+ TrustedTimeoutAlarmListener otherAlarm = mTrustTimeoutAlarmListenerForUser.get(mUserId);
+ if (otherAlarm != null && otherAlarm.isQueued()) {
+ synchronized (mAlarmLock) {
+ disableRenewableTrustWhileNonrenewableTrustIsPresent();
}
}
}