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

Commit 48f84243 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Fixes some DPM APIs to use the context user."

parents 9254c106 601d3e82
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -3704,10 +3704,11 @@ public class DevicePolicyManager {
    @RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.INTERACT_ACROSS_USERS})
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @UserHandleAware
    public void acknowledgeNewUserDisclaimer() {
        if (mService != null) {
            try {
                mService.acknowledgeNewUserDisclaimer();
                mService.acknowledgeNewUserDisclaimer(mContext.getUserId());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -3715,17 +3716,18 @@ public class DevicePolicyManager {
    }
    /**
     * Checks whether the new managed user disclaimer was viewed by the current user.
     * Checks whether the new managed user disclaimer was viewed by the user.
     *
     * @hide
     */
    @RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.INTERACT_ACROSS_USERS})
    @TestApi
    @UserHandleAware
    public boolean isNewUserDisclaimerAcknowledged() {
        if (mService != null) {
            try {
                return mService.isNewUserDisclaimerAcknowledged();
                return mService.isNewUserDisclaimerAcknowledged(mContext.getUserId());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
+2 −2
Original line number Diff line number Diff line
@@ -271,8 +271,8 @@ interface IDevicePolicyManager {
    int logoutUserInternal(); // AIDL doesn't allow overloading name (logoutUser())
    int getLogoutUserId();
    List<UserHandle> getSecondaryUsers(in ComponentName who);
    void acknowledgeNewUserDisclaimer();
    boolean isNewUserDisclaimerAcknowledged();
    void acknowledgeNewUserDisclaimer(int userId);
    boolean isNewUserDisclaimerAcknowledged(int userId);

    void enableSystemApp(in ComponentName admin, in String callerPackage, in String packageName);
    int enableSystemAppWithIntent(in ComponentName admin, in String callerPackage, in Intent intent);
+3 −5
Original line number Diff line number Diff line
@@ -10982,13 +10982,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    @Override
    public void acknowledgeNewUserDisclaimer() {
    public void acknowledgeNewUserDisclaimer(@UserIdInt int userId) {
        CallerIdentity callerIdentity = getCallerIdentity();
        Preconditions.checkCallAuthorization(canManageUsers(callerIdentity)
                || hasCallingOrSelfPermission(permission.INTERACT_ACROSS_USERS));
        setShowNewUserDisclaimer(callerIdentity.getUserId(),
                DevicePolicyData.NEW_USER_DISCLAIMER_ACKNOWLEDGED);
        setShowNewUserDisclaimer(userId, DevicePolicyData.NEW_USER_DISCLAIMER_ACKNOWLEDGED);
    }
    private void setShowNewUserDisclaimer(@UserIdInt int userId, String value) {
@@ -11021,11 +11020,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    }
    @Override
    public boolean isNewUserDisclaimerAcknowledged() {
    public boolean isNewUserDisclaimerAcknowledged(@UserIdInt int userId) {
        CallerIdentity callerIdentity = getCallerIdentity();
        Preconditions.checkCallAuthorization(canManageUsers(callerIdentity)
                || hasCallingOrSelfPermission(permission.INTERACT_ACROSS_USERS));
        int userId = callerIdentity.getUserId();
        synchronized (getLockObject()) {
            DevicePolicyData policyData = getUserData(userId);
            return policyData.isNewUserDisclaimerAcknowledged();