Merge "Don't allow do not disturb when volume restricted" into mnc-dev
This commit is contained in:
@@ -28,6 +28,7 @@ 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.systemui.Prefs;
|
||||
@@ -98,6 +99,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();
|
||||
Toast.makeText(mContext, mContext.getString(
|
||||
com.android.internal.R.string.error_message_change_not_allowed),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
mDisable.setAllowAnimation(true);
|
||||
mDisableTotalSilence.setAllowAnimation(true);
|
||||
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
|
||||
|
||||
@@ -36,6 +36,7 @@ public interface ZenModeController {
|
||||
ComponentName getEffectsSuppressor();
|
||||
boolean isCountdownConditionSupported();
|
||||
int getCurrentUser();
|
||||
boolean isVolumeRestricted();
|
||||
|
||||
public static class Callback {
|
||||
public void onZenChanged(int zen) {}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings.Global;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.service.notification.Condition;
|
||||
@@ -57,6 +58,7 @@ public class ZenModeControllerImpl implements ZenModeController {
|
||||
private final LinkedHashMap<Uri, Condition> mConditions = new LinkedHashMap<Uri, Condition>();
|
||||
private final AlarmManager mAlarmManager;
|
||||
private final SetupObserver mSetupObserver;
|
||||
private final UserManager mUserManager;
|
||||
|
||||
private int mUserId;
|
||||
private boolean mRequesting;
|
||||
@@ -84,6 +86,13 @@ public class ZenModeControllerImpl implements ZenModeController {
|
||||
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
mSetupObserver = new SetupObserver(handler);
|
||||
mSetupObserver.register();
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolumeRestricted() {
|
||||
return mUserManager.hasUserRestriction(UserManager.DISALLOW_ADJUST_VOLUME,
|
||||
new UserHandle(mUserId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user