Loading packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +6 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading packages/SystemUI/src/com/android/systemui/qs/QSTile.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 { Loading packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +1 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +6 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading
packages/SettingsLib/src/com/android/settingslib/RestrictedPreferenceHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
packages/SystemUI/src/com/android/systemui/qs/QSTile.java +3 −2 Original line number Diff line number Diff line Loading @@ -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 { Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +1 −2 Original line number Diff line number Diff line Loading @@ -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