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

Commit a8fbbb30 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Part1 - Don't add padlock if the restriction is not set by admin.

Bug: 26687435
Change-Id: I2fd740b1fa0d76eceedc4dde73e41d779820bbcf
parent b0e07aa0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -113,6 +113,12 @@ public class RestrictedLockUtils {
        return admin;
    }

    public static boolean hasBaseUserRestriction(Context context,
            String userRestriction, int userId) {
        UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
        return um.hasBaseUserRestriction(userRestriction, UserHandle.of(userId));
    }

    /**
     * Checks if keyguard features are disabled by policy.
     *
+6 −0
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ public class RestrictedPreferenceHelper {
                }
            }
            mAttrUserRestriction = data == null ? null : data.toString();
            // If the system has set the user restriction, then we shouldn't add the padlock.
            if (RestrictedLockUtils.hasBaseUserRestriction(mContext, mAttrUserRestriction,
                    UserHandle.myUserId())) {
                mAttrUserRestriction = null;
                return;
            }

            final TypedValue useAdminDisabledSummary =
                    attributes.peekValue(R.styleable.RestrictedPreference_useAdminDisabledSummary);
+3 −2
Original line number Diff line number Diff line
@@ -279,10 +279,11 @@ public abstract class QSTile<TState extends State> implements Listenable {
        mCallbacks.clear();
    }

    protected void checkIfRestrictionEnforced(State state, String userRestriction) {
    protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) {
        EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(mContext,
                userRestriction, ActivityManager.getCurrentUser());
        if (admin != null) {
        if (admin != null && !RestrictedLockUtils.hasBaseUserRestriction(mContext,
                userRestriction, ActivityManager.getCurrentUser())) {
            state.disabledByPolicy = true;
            state.enforcedAdmin = admin;
        } else {
+11 −2
Original line number Diff line number Diff line
@@ -29,11 +29,13 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
import android.widget.Toast;

import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SysUIToast;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.volume.ZenModePanel;
@@ -100,6 +102,14 @@ public class DndTile extends QSTile<QSTile.BooleanState> {

    @Override
    public void handleClick() {
        if (mController.isVolumeRestricted()) {
            // Collapse the panels, so the user can see the toast.
            mHost.collapsePanels();
            SysUIToast.makeText(mContext, mContext.getString(
                    com.android.internal.R.string.error_message_change_not_allowed),
                    Toast.LENGTH_LONG).show();
            return;
        }
        MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
        if (mState.value) {
            mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
@@ -116,8 +126,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
        final boolean newValue = zen != Global.ZEN_MODE_OFF;
        final boolean valueChanged = state.value != newValue;
        state.value = newValue;
        state.disabledByPolicy = mController.isVolumeRestricted();
        checkIfRestrictionEnforced(state, UserManager.DISALLOW_ADJUST_VOLUME);
        checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_ADJUST_VOLUME);
        switch (zen) {
            case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
                state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on);
+1 −2
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.label = mContext.getString(R.string.quick_settings_hotspot_label);

        state.disabledByPolicy = mController.isTetheringAllowed();
        checkIfRestrictionEnforced(state, UserManager.DISALLOW_CONFIG_TETHERING);
        checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING);
        if (arg instanceof Boolean) {
            state.value = (boolean) arg;
        } else {
Loading