Merge "Guard against duplicate calls to setQuietModeEnabled" into main

This commit is contained in:
Oli Thompson
2023-11-21 13:37:03 +00:00
committed by Android (Google) Code Review
4 changed files with 64 additions and 21 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.accounts;
import android.app.admin.flags.Flags;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -58,7 +59,14 @@ final class ManagedProfileQuietModeEnabler implements DefaultLifecycleObserver {
}
public void setQuietModeEnabled(boolean enabled) {
if (mManagedProfile != null) {
if (mManagedProfile == null) {
return;
}
if (Flags.quietModeCredentialBugFix()) {
if (isQuietModeEnabled() != enabled) {
mUserManager.requestQuietModeEnabled(enabled, mManagedProfile);
}
} else {
mUserManager.requestQuietModeEnabled(enabled, mManagedProfile);
}
}

View File

@@ -70,6 +70,9 @@ public class WorkModePreferenceController extends BasePreferenceController
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mQuietModeEnabler.setQuietModeEnabled(!isChecked);
if (android.app.admin.flags.Flags.quietModeCredentialBugFix()) {
updateState(mPreference);
}
}
@Override