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

Commit a22a7c2f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add DevicePolicyManager.isEphemeralUser"

parents 112d859e 8d6e18c8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6395,6 +6395,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
@@ -6360,6 +6360,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
@@ -358,6 +358,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
@@ -8540,6 +8540,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) {