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

Commit 957df516 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Fix Trust Agent discovery for FBE" into nyc-dev

parents 6bfac039 68771eb8
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.provider.Settings;
import android.service.trust.TrustAgentService;
import android.service.trust.TrustAgentService;
import android.util.ArraySet;
import android.util.ArraySet;
@@ -103,6 +104,7 @@ public class TrustManagerService extends SystemService {
    private static final int MSG_SWITCH_USER = 9;
    private static final int MSG_SWITCH_USER = 9;
    private static final int MSG_SET_DEVICE_LOCKED = 10;
    private static final int MSG_SET_DEVICE_LOCKED = 10;
    private static final int MSG_FLUSH_TRUST_USUALLY_MANAGED = 11;
    private static final int MSG_FLUSH_TRUST_USUALLY_MANAGED = 11;
    private static final int MSG_UNLOCK_USER = 12;


    private static final int TRUST_USUALLY_MANAGED_FLUSH_DELAY = 2 * 60 * 1000;
    private static final int TRUST_USUALLY_MANAGED_FLUSH_DELAY = 2 * 60 * 1000;


@@ -253,6 +255,7 @@ public class TrustManagerService extends SystemService {
            if (userInfo == null || userInfo.partial || !userInfo.isEnabled()
            if (userInfo == null || userInfo.partial || !userInfo.isEnabled()
                    || userInfo.guestToRemove) continue;
                    || userInfo.guestToRemove) continue;
            if (!userInfo.supportsSwitchToByUser()) continue;
            if (!userInfo.supportsSwitchToByUser()) continue;
            if (!StorageManager.isUserKeyUnlocked(userInfo.id)) continue;
            if (!mActivityManager.isUserRunning(userInfo.id)) continue;
            if (!mActivityManager.isUserRunning(userInfo.id)) continue;
            if (!lockPatternUtils.isSecure(userInfo.id)) continue;
            if (!lockPatternUtils.isSecure(userInfo.id)) continue;
            if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id)) continue;
            if (!mStrongAuthTracker.canAgentsRunForUser(userInfo.id)) continue;
@@ -527,7 +530,8 @@ public class TrustManagerService extends SystemService {


    private List<ResolveInfo> resolveAllowedTrustAgents(PackageManager pm, int userId) {
    private List<ResolveInfo> resolveAllowedTrustAgents(PackageManager pm, int userId) {
        List<ResolveInfo> resolveInfos = pm.queryIntentServicesAsUser(TRUST_AGENT_INTENT,
        List<ResolveInfo> resolveInfos = pm.queryIntentServicesAsUser(TRUST_AGENT_INTENT,
                0 /* flags */, userId);
                PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                userId);
        ArrayList<ResolveInfo> allowedAgents = new ArrayList<>(resolveInfos.size());
        ArrayList<ResolveInfo> allowedAgents = new ArrayList<>(resolveInfos.size());
        for (ResolveInfo resolveInfo : resolveInfos) {
        for (ResolveInfo resolveInfo : resolveInfos) {
            if (resolveInfo.serviceInfo == null) continue;
            if (resolveInfo.serviceInfo == null) continue;
@@ -664,6 +668,11 @@ public class TrustManagerService extends SystemService {
        mHandler.obtainMessage(MSG_SWITCH_USER, userId, 0, null).sendToTarget();
        mHandler.obtainMessage(MSG_SWITCH_USER, userId, 0, null).sendToTarget();
    }
    }


    @Override
    public void onUnlockUser(int userId) {
        mHandler.obtainMessage(MSG_UNLOCK_USER, userId, 0, null).sendToTarget();
    }

    // Plumbing
    // Plumbing


    private final IBinder mService = new ITrustManager.Stub() {
    private final IBinder mService = new ITrustManager.Stub() {
@@ -896,6 +905,7 @@ public class TrustManagerService extends SystemService {
                    break;
                    break;
                case MSG_START_USER:
                case MSG_START_USER:
                case MSG_CLEANUP_USER:
                case MSG_CLEANUP_USER:
                case MSG_UNLOCK_USER:
                    refreshAgentList(msg.arg1);
                    refreshAgentList(msg.arg1);
                    break;
                    break;
                case MSG_SWITCH_USER:
                case MSG_SWITCH_USER:
@@ -918,6 +928,7 @@ public class TrustManagerService extends SystemService {
                            mLockPatternUtils.setTrustUsuallyManaged(value, userId);
                            mLockPatternUtils.setTrustUsuallyManaged(value, userId);
                        }
                        }
                    }
                    }
                    break;
            }
            }
        }
        }
    };
    };