Loading cmds/pm/src/com/android/commands/pm/Pm.java +7 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.commands.pm; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; import android.accounts.IAccountManager; import android.app.ActivityManager; Loading Loading @@ -798,6 +798,10 @@ public final class Pm { flags |= UserInfo.FLAG_MANAGED_PROFILE; } else if ("--restricted".equals(opt)) { flags |= UserInfo.FLAG_RESTRICTED; } else if ("--ephemeral".equals(opt)) { flags |= UserInfo.FLAG_EPHEMERAL; } else if ("--guest".equals(opt)) { flags |= UserInfo.FLAG_GUEST; } else { System.err.println("Error: unknown option " + opt); return showUsage(); Loading Loading @@ -1356,7 +1360,7 @@ public final class Pm { System.err.println(" pm get-install-location"); System.err.println(" pm set-permission-enforced PERMISSION [true|false]"); System.err.println(" pm trim-caches DESIRED_FREE_SPACE [internal|UUID]"); System.err.println(" pm create-user [--profileOf USER_ID] [--managed] [--restricted] USER_NAME"); System.err.println(" pm create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral] [--guest] USER_NAME"); System.err.println(" pm remove-user USER_ID"); System.err.println(" pm get-max-users"); System.err.println(""); Loading core/java/android/content/pm/UserInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,12 @@ public class UserInfo implements Parcelable { public static final int FLAG_QUIET_MODE = 0x00000080; /** * Indicates that this user is ephemeral. I.e. the user will be removed after leaving * the foreground. */ public static final int FLAG_EPHEMERAL = 0x00000100; public static final int NO_PROFILE_GROUP_ID = UserHandle.USER_NULL; public int id; Loading Loading @@ -134,6 +140,11 @@ public class UserInfo implements Parcelable { public boolean isQuietModeEnabled() { return (flags & FLAG_QUIET_MODE) == FLAG_QUIET_MODE; } public boolean isEphemeral() { return (flags & FLAG_EPHEMERAL) == FLAG_EPHEMERAL; } /** * Returns true if the user is a split system user. * <p>If {@link UserManager#isSplitSystemUser split system user mode} is not enabled, Loading core/java/android/os/UserManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -720,6 +720,25 @@ public class UserManager { return user != null ? user.isManagedProfile() : false; } /** * Checks if the calling app is running as an ephemeral user. * * @return whether the caller is an ephemeral user. * @hide */ public boolean isEphemeralUser() { return isUserEphemeral(UserHandle.myUserId()); } /** * Returns whether the specified user is ephemeral. * @hide */ public boolean isUserEphemeral(int userId) { final UserInfo user = getUserInfo(userId); return user != null && user.isEphemeral(); } /** * Return whether the given user is actively running. This means that * the user is in the "started" state, not "stopped" -- it is currently Loading core/java/android/os/storage/IMountService.java +14 −9 Original line number Diff line number Diff line Loading @@ -25,8 +25,6 @@ import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.RemoteException; import java.io.FileDescriptor; /** * WARNING! Update IMountService.h and IMountService.cpp if you change this * file. In particular, the ordering of the methods below must match the Loading Loading @@ -1202,13 +1200,15 @@ public interface IMountService extends IInterface { } @Override public void createUserKey(int userId, int serialNumber) throws RemoteException { public void createUserKey(int userId, int serialNumber, boolean ephemeral) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeInt(userId); _data.writeInt(serialNumber); _data.writeInt(ephemeral ? 1 : 0); mRemote.transact(Stub.TRANSACTION_createUserKey, _data, _reply, 0); _reply.readException(); } finally { Loading Loading @@ -1283,7 +1283,8 @@ public interface IMountService extends IInterface { } @Override public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) public void prepareUserStorage( String volumeUuid, int userId, int serialNumber, boolean ephemeral) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); Loading @@ -1292,6 +1293,7 @@ public interface IMountService extends IInterface { _data.writeString(volumeUuid); _data.writeInt(userId); _data.writeInt(serialNumber); _data.writeInt(ephemeral ? 1 : 0); mRemote.transact(Stub.TRANSACTION_prepareUserStorage, _data, _reply, 0); _reply.readException(); } finally { Loading Loading @@ -2012,7 +2014,8 @@ public interface IMountService extends IInterface { data.enforceInterface(DESCRIPTOR); int userId = data.readInt(); int serialNumber = data.readInt(); createUserKey(userId, serialNumber); boolean ephemeral = data.readInt() != 0; createUserKey(userId, serialNumber, ephemeral); reply.writeNoException(); return true; } Loading Loading @@ -2052,7 +2055,8 @@ public interface IMountService extends IInterface { String volumeUuid = data.readString(); int userId = data.readInt(); int serialNumber = data.readInt(); prepareUserStorage(volumeUuid, userId, serialNumber); boolean ephemeral = data.readInt() != 0; prepareUserStorage(volumeUuid, userId, serialNumber, ephemeral); reply.writeNoException(); return true; } Loading Loading @@ -2376,15 +2380,16 @@ public interface IMountService extends IInterface { public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback) throws RemoteException; public void createUserKey(int userId, int serialNumber) throws RemoteException; public void createUserKey(int userId, int serialNumber, boolean ephemeral) throws RemoteException; public void destroyUserKey(int userId) throws RemoteException; public void unlockUserKey(int userId, int serialNumber, byte[] token) throws RemoteException; public void lockUserKey(int userId) throws RemoteException; public boolean isUserKeyUnlocked(int userId) throws RemoteException; public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) throws RemoteException; public void prepareUserStorage(String volumeUuid, int userId, int serialNumber, boolean ephemeral) throws RemoteException; public ParcelFileDescriptor mountAppFuse(String name) throws RemoteException; } core/java/android/os/storage/StorageManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -966,9 +966,9 @@ public class StorageManager { } /** {@hide} */ public void createUserKey(int userId, int serialNumber) { public void createUserKey(int userId, int serialNumber, boolean ephemeral) { try { mMountService.createUserKey(userId, serialNumber); mMountService.createUserKey(userId, serialNumber, ephemeral); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading Loading @@ -1002,9 +1002,10 @@ public class StorageManager { } /** {@hide} */ public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) { public void prepareUserStorage( String volumeUuid, int userId, int serialNumber, boolean ephemeral) { try { mMountService.prepareUserStorage(volumeUuid, userId, serialNumber); mMountService.prepareUserStorage(volumeUuid, userId, serialNumber, ephemeral); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading Loading
cmds/pm/src/com/android/commands/pm/Pm.java +7 −3 Original line number Diff line number Diff line Loading @@ -16,11 +16,11 @@ package com.android.commands.pm; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER; import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED; import android.accounts.IAccountManager; import android.app.ActivityManager; Loading Loading @@ -798,6 +798,10 @@ public final class Pm { flags |= UserInfo.FLAG_MANAGED_PROFILE; } else if ("--restricted".equals(opt)) { flags |= UserInfo.FLAG_RESTRICTED; } else if ("--ephemeral".equals(opt)) { flags |= UserInfo.FLAG_EPHEMERAL; } else if ("--guest".equals(opt)) { flags |= UserInfo.FLAG_GUEST; } else { System.err.println("Error: unknown option " + opt); return showUsage(); Loading Loading @@ -1356,7 +1360,7 @@ public final class Pm { System.err.println(" pm get-install-location"); System.err.println(" pm set-permission-enforced PERMISSION [true|false]"); System.err.println(" pm trim-caches DESIRED_FREE_SPACE [internal|UUID]"); System.err.println(" pm create-user [--profileOf USER_ID] [--managed] [--restricted] USER_NAME"); System.err.println(" pm create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral] [--guest] USER_NAME"); System.err.println(" pm remove-user USER_ID"); System.err.println(" pm get-max-users"); System.err.println(""); Loading
core/java/android/content/pm/UserInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,12 @@ public class UserInfo implements Parcelable { public static final int FLAG_QUIET_MODE = 0x00000080; /** * Indicates that this user is ephemeral. I.e. the user will be removed after leaving * the foreground. */ public static final int FLAG_EPHEMERAL = 0x00000100; public static final int NO_PROFILE_GROUP_ID = UserHandle.USER_NULL; public int id; Loading Loading @@ -134,6 +140,11 @@ public class UserInfo implements Parcelable { public boolean isQuietModeEnabled() { return (flags & FLAG_QUIET_MODE) == FLAG_QUIET_MODE; } public boolean isEphemeral() { return (flags & FLAG_EPHEMERAL) == FLAG_EPHEMERAL; } /** * Returns true if the user is a split system user. * <p>If {@link UserManager#isSplitSystemUser split system user mode} is not enabled, Loading
core/java/android/os/UserManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -720,6 +720,25 @@ public class UserManager { return user != null ? user.isManagedProfile() : false; } /** * Checks if the calling app is running as an ephemeral user. * * @return whether the caller is an ephemeral user. * @hide */ public boolean isEphemeralUser() { return isUserEphemeral(UserHandle.myUserId()); } /** * Returns whether the specified user is ephemeral. * @hide */ public boolean isUserEphemeral(int userId) { final UserInfo user = getUserInfo(userId); return user != null && user.isEphemeral(); } /** * Return whether the given user is actively running. This means that * the user is in the "started" state, not "stopped" -- it is currently Loading
core/java/android/os/storage/IMountService.java +14 −9 Original line number Diff line number Diff line Loading @@ -25,8 +25,6 @@ import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.RemoteException; import java.io.FileDescriptor; /** * WARNING! Update IMountService.h and IMountService.cpp if you change this * file. In particular, the ordering of the methods below must match the Loading Loading @@ -1202,13 +1200,15 @@ public interface IMountService extends IInterface { } @Override public void createUserKey(int userId, int serialNumber) throws RemoteException { public void createUserKey(int userId, int serialNumber, boolean ephemeral) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(DESCRIPTOR); _data.writeInt(userId); _data.writeInt(serialNumber); _data.writeInt(ephemeral ? 1 : 0); mRemote.transact(Stub.TRANSACTION_createUserKey, _data, _reply, 0); _reply.readException(); } finally { Loading Loading @@ -1283,7 +1283,8 @@ public interface IMountService extends IInterface { } @Override public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) public void prepareUserStorage( String volumeUuid, int userId, int serialNumber, boolean ephemeral) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); Loading @@ -1292,6 +1293,7 @@ public interface IMountService extends IInterface { _data.writeString(volumeUuid); _data.writeInt(userId); _data.writeInt(serialNumber); _data.writeInt(ephemeral ? 1 : 0); mRemote.transact(Stub.TRANSACTION_prepareUserStorage, _data, _reply, 0); _reply.readException(); } finally { Loading Loading @@ -2012,7 +2014,8 @@ public interface IMountService extends IInterface { data.enforceInterface(DESCRIPTOR); int userId = data.readInt(); int serialNumber = data.readInt(); createUserKey(userId, serialNumber); boolean ephemeral = data.readInt() != 0; createUserKey(userId, serialNumber, ephemeral); reply.writeNoException(); return true; } Loading Loading @@ -2052,7 +2055,8 @@ public interface IMountService extends IInterface { String volumeUuid = data.readString(); int userId = data.readInt(); int serialNumber = data.readInt(); prepareUserStorage(volumeUuid, userId, serialNumber); boolean ephemeral = data.readInt() != 0; prepareUserStorage(volumeUuid, userId, serialNumber, ephemeral); reply.writeNoException(); return true; } Loading Loading @@ -2376,15 +2380,16 @@ public interface IMountService extends IInterface { public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback) throws RemoteException; public void createUserKey(int userId, int serialNumber) throws RemoteException; public void createUserKey(int userId, int serialNumber, boolean ephemeral) throws RemoteException; public void destroyUserKey(int userId) throws RemoteException; public void unlockUserKey(int userId, int serialNumber, byte[] token) throws RemoteException; public void lockUserKey(int userId) throws RemoteException; public boolean isUserKeyUnlocked(int userId) throws RemoteException; public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) throws RemoteException; public void prepareUserStorage(String volumeUuid, int userId, int serialNumber, boolean ephemeral) throws RemoteException; public ParcelFileDescriptor mountAppFuse(String name) throws RemoteException; }
core/java/android/os/storage/StorageManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -966,9 +966,9 @@ public class StorageManager { } /** {@hide} */ public void createUserKey(int userId, int serialNumber) { public void createUserKey(int userId, int serialNumber, boolean ephemeral) { try { mMountService.createUserKey(userId, serialNumber); mMountService.createUserKey(userId, serialNumber, ephemeral); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading Loading @@ -1002,9 +1002,10 @@ public class StorageManager { } /** {@hide} */ public void prepareUserStorage(String volumeUuid, int userId, int serialNumber) { public void prepareUserStorage( String volumeUuid, int userId, int serialNumber, boolean ephemeral) { try { mMountService.prepareUserStorage(volumeUuid, userId, serialNumber); mMountService.prepareUserStorage(volumeUuid, userId, serialNumber, ephemeral); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } Loading