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

Commit e17ac156 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

More APIs for encryption-aware apps.

Apps can mark manifest components as being encryption-aware, which
means they can safely be run before the credential encrypted storage
is available.

Start adding filtering logic so that we only return these components
when a user is running "with amnesia."  That is to say, only device
encrypted storage is available, so the user is running but with only
partial knowledge of its data.

To avoid calling into ActivityManager with the PackageManager lock
held, we quickly determine user state and splice the state into the
flags for later per-component evaluation.

Bug: 22358539
Change-Id: Idc56ec29f1ef04da8963e004314d7f5e47400997
parent 15447798
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -9062,6 +9062,7 @@ package android.content.pm {
    field public android.content.pm.ApplicationInfo applicationInfo;
    field public int descriptionRes;
    field public boolean enabled;
    field public boolean encryptionAware;
    field public boolean exported;
    field public java.lang.String processName;
  }
@@ -9483,6 +9484,7 @@ package android.content.pm {
    field public static final int GET_CONFIGURATIONS = 16384; // 0x4000
    field public static final int GET_DISABLED_COMPONENTS = 512; // 0x200
    field public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 32768; // 0x8000
    field public static final int GET_ENCRYPTION_UNAWARE_COMPONENTS = 262144; // 0x40000
    field public static final int GET_GIDS = 256; // 0x100
    field public static final int GET_INSTRUMENTATION = 16; // 0x10
    field public static final int GET_INTENT_FILTERS = 32; // 0x20
+2 −0
Original line number Diff line number Diff line
@@ -9322,6 +9322,7 @@ package android.content.pm {
    field public android.content.pm.ApplicationInfo applicationInfo;
    field public int descriptionRes;
    field public boolean enabled;
    field public boolean encryptionAware;
    field public boolean exported;
    field public java.lang.String processName;
  }
@@ -9780,6 +9781,7 @@ package android.content.pm {
    field public static final int GET_CONFIGURATIONS = 16384; // 0x4000
    field public static final int GET_DISABLED_COMPONENTS = 512; // 0x200
    field public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 32768; // 0x8000
    field public static final int GET_ENCRYPTION_UNAWARE_COMPONENTS = 262144; // 0x40000
    field public static final int GET_GIDS = 256; // 0x100
    field public static final int GET_INSTRUMENTATION = 16; // 0x10
    field public static final int GET_INTENT_FILTERS = 32; // 0x20
+6 −1
Original line number Diff line number Diff line
@@ -2952,6 +2952,11 @@ public class ActivityManager {
        }
    }

    /** {@hide} */
    public static final int FLAG_OR_STOPPED = 1 << 0;
    /** {@hide} */
    public static final int FLAG_WITH_AMNESIA = 1 << 1;

    /**
     * Return whether the given user is actively running.  This means that
     * the user is in the "started" state, not "stopped" -- it is currently
@@ -2963,7 +2968,7 @@ public class ActivityManager {
     */
    public boolean isUserRunning(int userid) {
        try {
            return ActivityManagerNative.getDefault().isUserRunning(userid, false);
            return ActivityManagerNative.getDefault().isUserRunning(userid, 0);
        } catch (RemoteException e) {
            return false;
        }
+4 −4
Original line number Diff line number Diff line
@@ -1984,8 +1984,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
        case IS_USER_RUNNING_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int userid = data.readInt();
            boolean orStopping = data.readInt() != 0;
            boolean result = isUserRunning(userid, orStopping);
            int _flags = data.readInt();
            boolean result = isUserRunning(userid, _flags);
            reply.writeNoException();
            reply.writeInt(result ? 1 : 0);
            return true;
@@ -5265,12 +5265,12 @@ class ActivityManagerProxy implements IActivityManager
        return userInfo;
    }

    public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException {
    public boolean isUserRunning(int userid, int flags) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(userid);
        data.writeInt(orStopping ? 1 : 0);
        data.writeInt(flags);
        mRemote.transact(IS_USER_RUNNING_TRANSACTION, data, reply, 0);
        reply.readException();
        boolean result = reply.readInt() != 0;
+1 −1
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ public interface IActivityManager extends IInterface {
    public boolean startUserInBackground(int userid) throws RemoteException;
    public int stopUser(int userid, IStopUserCallback callback) throws RemoteException;
    public UserInfo getCurrentUser() throws RemoteException;
    public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException;
    public boolean isUserRunning(int userid, int flags) throws RemoteException;
    public int[] getRunningUserIds() throws RemoteException;

    public boolean removeTask(int taskId) throws RemoteException;
Loading