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

Commit 9e912ba0 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Clear calling identity before setting restrictions

Previously Settings.Secure.putIntForUser was failing with AppOps package
mismatch exception when createRestrictedProfile method was called from
a shell process.

Bug: 24212155
Change-Id: I47ecfa572b110d627e5b049aa98ed4d10b2e1374
parent e12aece4
Loading
Loading
Loading
Loading
+12 −7
Original line number Original line Diff line number Diff line
@@ -1930,6 +1930,8 @@ public class UserManagerService extends IUserManager.Stub {
        if (user == null) {
        if (user == null) {
            return null;
            return null;
        }
        }
        long identity = Binder.clearCallingIdentity();
        try {
            setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user.id);
            setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user.id);
            // Change the setting before applying the DISALLOW_SHARE_LOCATION restriction, otherwise
            // Change the setting before applying the DISALLOW_SHARE_LOCATION restriction, otherwise
            // the putIntForUser() will fail.
            // the putIntForUser() will fail.
@@ -1937,6 +1939,9 @@ public class UserManagerService extends IUserManager.Stub {
                    android.provider.Settings.Secure.LOCATION_MODE,
                    android.provider.Settings.Secure.LOCATION_MODE,
                    android.provider.Settings.Secure.LOCATION_MODE_OFF, user.id);
                    android.provider.Settings.Secure.LOCATION_MODE_OFF, user.id);
            setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user.id);
            setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user.id);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
        return user;
        return user;
    }
    }