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

Commit 8d6e18c8 authored by Alex Chau's avatar Alex Chau
Browse files

Add DevicePolicyManager.isEphemeralUser

Bug: 67580550
Test: The AP returns false in primary user.
Test: Create ephemeral user with createAndManageUser, ensure the API return true.
Change-Id: I1e670ca8a8c6171ddb94a1e4b1cb1a958f12919d
parent 0b62766d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6393,6 +6393,7 @@ package android.app.admin {
    method public boolean isBackupServiceEnabled(android.content.ComponentName);
    method public deprecated boolean isCallerApplicationRestrictionsManagingPackage();
    method public boolean isDeviceOwnerApp(java.lang.String);
    method public boolean isEphemeralUser(android.content.ComponentName);
    method public boolean isLockTaskPermitted(java.lang.String);
    method public boolean isLogoutEnabled();
    method public boolean isManagedProfile(android.content.ComponentName);
+15 −0
Original line number Diff line number Diff line
@@ -6356,6 +6356,21 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Checks if the profile owner is running in an ephemeral user.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @return whether the profile owner is running in an ephemeral user.
     */
    public boolean isEphemeralUser(@NonNull ComponentName admin) {
        throwIfParentInstance("isEphemeralUser");
        try {
            return mService.isEphemeralUser(admin);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Retrieves the application restrictions for a given target application running in the calling
     * user.
+1 −0
Original line number Diff line number Diff line
@@ -357,6 +357,7 @@ interface IDevicePolicyManager {
        IApplicationThread caller, IBinder token, in Intent service,
        IServiceConnection connection, int flags, int targetUserId);
    List<UserHandle> getBindDeviceAdminTargetUsers(in ComponentName admin);
    boolean isEphemeralUser(in ComponentName admin);

    long getLastSecurityLogRetrievalTime();
    long getLastBugReportRequestTime();
+16 −0
Original line number Diff line number Diff line
@@ -8537,6 +8537,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
    }

    @Override
    public boolean isEphemeralUser(ComponentName who) {
        Preconditions.checkNotNull(who, "ComponentName is null");
        synchronized (this) {
            getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
        }

        final int callingUserId = mInjector.userHandleGetCallingUserId();
        final long id = mInjector.binderClearCallingIdentity();
        try {
            return mInjector.getUserManager().isUserEphemeral(callingUserId);
        } finally {
            mInjector.binderRestoreCallingIdentity(id);
        }
    }

    @Override
    public Bundle getApplicationRestrictions(ComponentName who, String callerPackage,
            String packageName) {