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

Commit 9d8a1048 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Handle non-encryption-aware accounts and sync.

The system can now boot in a "locked" state where only encryption
aware (EA) components can be safely started.  When in this state,
PackageManager already filters away non-EA components, but system
services like AccountManager and SyncManager need to carefully handle
these temporarily "missing" components.

As a guiding principle, all known Accounts are still present when
the device is locked, but communication with underlying non-EA
authenticators is blocked.

To keep things simple for now, all SyncManager requests are kept
dormant until the user enters the unlocked state.

The core of this logic is that RegisteredServicesCache now works
with all components regardless of EA status, which prevents us from
accidentally thinking a service was removed when the user is locked.

Bug: 25945136
Change-Id: I8714121f6236b00821769023c4df7de1c8a99944
parent d19c5c14
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -28068,8 +28068,9 @@ package android.os {
    method public boolean isSystemUser();
    method public boolean isUserAGoat();
    method public boolean isUserRunning(android.os.UserHandle);
    method public boolean isUserRunningAndLocked(android.os.UserHandle);
    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
    method public boolean isUserRunningOrStopping(android.os.UserHandle);
    method public boolean isUserRunningUnlocked(android.os.UserHandle);
    method public deprecated boolean setRestrictionsChallenge(java.lang.String);
    method public deprecated void setUserRestriction(java.lang.String, boolean);
    method public deprecated void setUserRestrictions(android.os.Bundle);
+2 −1
Original line number Diff line number Diff line
@@ -30053,8 +30053,9 @@ package android.os {
    method public boolean isSystemUser();
    method public boolean isUserAGoat();
    method public boolean isUserRunning(android.os.UserHandle);
    method public boolean isUserRunningAndLocked(android.os.UserHandle);
    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
    method public boolean isUserRunningOrStopping(android.os.UserHandle);
    method public boolean isUserRunningUnlocked(android.os.UserHandle);
    method public deprecated boolean setRestrictionsChallenge(java.lang.String);
    method public deprecated void setUserRestriction(java.lang.String, boolean);
    method public deprecated void setUserRestrictions(android.os.Bundle);
+2 −1
Original line number Diff line number Diff line
@@ -28068,8 +28068,9 @@ package android.os {
    method public boolean isSystemUser();
    method public boolean isUserAGoat();
    method public boolean isUserRunning(android.os.UserHandle);
    method public boolean isUserRunningAndLocked(android.os.UserHandle);
    method public boolean isUserRunningAndUnlocked(android.os.UserHandle);
    method public boolean isUserRunningOrStopping(android.os.UserHandle);
    method public boolean isUserRunningUnlocked(android.os.UserHandle);
    method public deprecated boolean setRestrictionsChallenge(java.lang.String);
    method public deprecated void setUserRestriction(java.lang.String, boolean);
    method public deprecated void setUserRestrictions(android.os.Bundle);
+22 −2
Original line number Diff line number Diff line
@@ -3108,9 +3108,29 @@ public class ActivityManager {
     * @param userid the user's id. Zero indicates the default user.
     * @hide
     */
    public boolean isUserRunning(int userid) {
    public boolean isUserRunning(int userId) {
        try {
            return ActivityManagerNative.getDefault().isUserRunning(userid, 0);
            return ActivityManagerNative.getDefault().isUserRunning(userId, 0);
        } catch (RemoteException e) {
            return false;
        }
    }

    /** {@hide} */
    public boolean isUserRunningAndLocked(int userId) {
        try {
            return ActivityManagerNative.getDefault().isUserRunning(userId,
                    ActivityManager.FLAG_AND_LOCKED);
        } catch (RemoteException e) {
            return false;
        }
    }

    /** {@hide} */
    public boolean isUserRunningAndUnlocked(int userId) {
        try {
            return ActivityManagerNative.getDefault().isUserRunning(userId,
                    ActivityManager.FLAG_AND_UNLOCKED);
        } catch (RemoteException e) {
            return false;
        }
+8 −7
Original line number Diff line number Diff line
@@ -294,14 +294,16 @@ public abstract class RegisteredServicesCache<V> {
     */
    public static class ServiceInfo<V> {
        public final V type;
        public final ComponentInfo componentInfo;
        public final ComponentName componentName;
        public final int uid;

        /** @hide */
        public ServiceInfo(V type, ComponentName componentName, int uid) {
        public ServiceInfo(V type, ComponentInfo componentInfo, ComponentName componentName) {
            this.type = type;
            this.componentInfo = componentInfo;
            this.componentName = componentName;
            this.uid = uid;
            this.uid = (componentInfo != null) ? componentInfo.applicationInfo.uid : -1;
        }

        @Override
@@ -362,8 +364,9 @@ public abstract class RegisteredServicesCache<V> {
    @VisibleForTesting
    protected List<ResolveInfo> queryIntentServices(int userId) {
        final PackageManager pm = mContext.getPackageManager();
        return pm.queryIntentServicesAsUser(
                new Intent(mInterfaceName), PackageManager.GET_META_DATA, userId);
        return pm.queryIntentServicesAsUser(new Intent(mInterfaceName),
                PackageManager.GET_META_DATA | PackageManager.GET_ENCRYPTION_UNAWARE_COMPONENTS,
                userId);
    }

    /**
@@ -563,9 +566,7 @@ public abstract class RegisteredServicesCache<V> {
                return null;
            }
            final android.content.pm.ServiceInfo serviceInfo = service.serviceInfo;
            final ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
            final int uid = applicationInfo.uid;
            return new ServiceInfo<V>(v, componentName, uid);
            return new ServiceInfo<V>(v, serviceInfo, componentName);
        } catch (NameNotFoundException e) {
            throw new XmlPullParserException(
                    "Unable to load resources for pacakge " + si.packageName);
Loading