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

Commit 747bb66d authored by Eric Biggers's avatar Eric Biggers Committed by Automerger Merge Worker
Browse files

Merge changes I57de36ba,I75d58e09 into main am: cd00f7a7 am: 420ee299 am:...

Merge changes I57de36ba,I75d58e09 into main am: cd00f7a7 am: 420ee299 am: a354379a am: 7b64191b

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2729596



Change-Id: I890e5d92c00d9fe01b6e8c5497cd4d39a397d05a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents cbd11891 7b64191b
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -120,9 +120,6 @@ public class TrustAgentWrapper {
    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();
+10 −89
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import android.os.Message;
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;
@@ -165,10 +164,6 @@ public class TrustManagerService extends SystemService {
    @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
@@ -569,69 +564,6 @@ public class TrustManagerService extends SystemService {
            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)
@@ -2265,17 +2197,12 @@ public class TrustManagerService extends SystemService {

        @Override
        public void handleAlarm() {
            TrustableTimeoutAlarmListener otherAlarm;
            boolean otherAlarmPresent;
            if (ENABLE_ACTIVE_UNLOCK_FLAG) {
                otherAlarm = mTrustableTimeoutAlarmListenerForUser.get(mUserId);
                otherAlarmPresent = (otherAlarm != null) && otherAlarm.isQueued();
                if (otherAlarmPresent) {
            TrustableTimeoutAlarmListener otherAlarm =
                    mTrustableTimeoutAlarmListenerForUser.get(mUserId);
            if (otherAlarm != null && otherAlarm.isQueued()) {
                synchronized (mAlarmLock) {
                    disableNonrenewableTrustWhileRenewableTrustIsPresent();
                }
                    return;
                }
            }
        }

@@ -2299,18 +2226,12 @@ public class TrustManagerService extends SystemService {

        @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) {
            TrustedTimeoutAlarmListener otherAlarm = mTrustTimeoutAlarmListenerForUser.get(mUserId);
            if (otherAlarm != null && otherAlarm.isQueued()) {
                synchronized (mAlarmLock) {
                    disableRenewableTrustWhileNonrenewableTrustIsPresent();
                }
                    return;
                }
            }
        }