Merge "Only call super.updateState when work profile exists" into main

This commit is contained in:
Treehugger Robot
2025-03-19 16:31:38 -07:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 4 deletions

View File

@@ -102,12 +102,12 @@ public class PoliteNotifWorkProfileToggleController extends TogglePreferenceCont
return CONDITIONALLY_UNAVAILABLE;
}
return (mManagedProfileId != UserHandle.USER_NULL) ? AVAILABLE : DISABLED_FOR_USER;
return hasManagedProfileUser() ? AVAILABLE : DISABLED_FOR_USER;
}
@Override
public boolean isChecked() {
if (!isCoolDownEnabledForPrimary()) {
if (!isCoolDownEnabledForPrimary() || !hasManagedProfileUser()) {
return false;
}
return Settings.System.getIntForUser(mContext.getContentResolver(),
@@ -131,7 +131,13 @@ public class PoliteNotifWorkProfileToggleController extends TogglePreferenceCont
public void updateState(@Nullable Preference preference) {
if (preference == null) return;
preference.setVisible(isAvailable());
super.updateState(preference);
if (isAvailable()) {
super.updateState(preference);
}
}
private boolean hasManagedProfileUser() {
return mManagedProfileId != UserHandle.USER_NULL;
}
private boolean isCoolDownEnabledForPrimary() {