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

Commit 599dd7ce authored by Amith Yamasani's avatar Amith Yamasani
Browse files

DevicePolicyManager per user

Bug: 7136483

Store device policy information for each user and apply them when user switches.

Global proxy can only be controlled by owner.
Camera restriction applies to all users, if any one has an admin that disables it.
Storage encryption can only be controlled by owner, although other users can query the state.
Wipe data will only remove the user if non-zero, wipe the device, if zero.

Change-Id: I359be46c1bc3828fd13d4be3228f11495081c8f2
parent 24ed2769
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -413,6 +413,13 @@ public final class PendingIntent implements Parcelable {
     */
    public static PendingIntent getBroadcast(Context context, int requestCode,
            Intent intent, int flags) {
        return getBroadcastAsUser(context, requestCode, intent, flags,
                new UserHandle(UserHandle.myUserId()));
    }

    /** @hide */
    public static PendingIntent getBroadcastAsUser(Context context, int requestCode,
            Intent intent, int flags, UserHandle userHandle) {
        String packageName = context.getPackageName();
        String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
                context.getContentResolver()) : null;
@@ -423,7 +430,7 @@ public final class PendingIntent implements Parcelable {
                    ActivityManager.INTENT_SENDER_BROADCAST, packageName,
                    null, null, requestCode, new Intent[] { intent },
                    resolvedType != null ? new String[] { resolvedType } : null,
                    flags, null, UserHandle.myUserId());
                    flags, null, userHandle.getIdentifier());
            return target != null ? new PendingIntent(target) : null;
        } catch (RemoteException e) {
        }
+124 −52

File changed.

Preview size limit exceeded, changes collapsed.

+48 −48

File changed.

Preview size limit exceeded, changes collapsed.

+75 −36

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.Log;
@@ -344,7 +345,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        final boolean usingPattern = mode == KeyguardSecurityModel.SecurityMode.Pattern;

        final int failedAttemptsBeforeWipe = mLockPatternUtils.getDevicePolicyManager()
                .getMaximumFailedPasswordsForWipe(null);
                .getMaximumFailedPasswordsForWipe(null, mLockPatternUtils.getCurrentUser());

        final int failedAttemptWarning = LockPatternUtils.FAILED_ATTEMPTS_BEFORE_RESET
                - LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT;
@@ -678,7 +679,7 @@ public class KeyguardHostView extends KeyguardViewBase {
    private void maybePopulateWidgets() {
        DevicePolicyManager dpm =
                (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
        if (dpm != null && dpm.getKeyguardWidgetsDisabled(null)
        if (dpm != null && dpm.getKeyguardWidgetsDisabled(null, mLockPatternUtils.getCurrentUser())
                != DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_NONE) {
            Log.v(TAG, "Keyguard widgets disabled because of device policy admin");
            return;
Loading