Disable dreams home controls button when disabled on lockscreen.

When home controls are disable on lockscreen, we should also disable
them on dreams.

Bug: 282680621
Test: flashed device, disabled/enabled home controls on lockscreen and
verified that dreams home controls button was hidden/shown correctly
Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.dream.DreamHomeControlsPreferenceControllerTest"

Change-Id: I535b079cabc2838e77f3afc74bb8f8730b850653
This commit is contained in:
Lucas Silva
2023-05-18 14:38:54 -04:00
parent ef7a75c394
commit 9872f4322b
2 changed files with 41 additions and 2 deletions

View File

@@ -17,6 +17,9 @@
package com.android.settings.dream;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
@@ -46,12 +49,21 @@ public class DreamHomeControlsPreferenceController extends TogglePreferenceContr
final boolean supported =
mBackend.getSupportedComplications()
.contains(DreamBackend.COMPLICATION_TYPE_HOME_CONTROLS);
return supported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
return controlsEnabledOnLockscreen() ? (supported ? AVAILABLE : CONDITIONALLY_UNAVAILABLE)
: DISABLED_DEPENDENT_SETTING;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
preference.setEnabled(getAvailabilityStatus() == AVAILABLE);
refreshSummary(preference);
}
@Override
public boolean isChecked() {
return mBackend.getEnabledComplications().contains(
return controlsEnabledOnLockscreen() && mBackend.getEnabledComplications().contains(
DreamBackend.COMPLICATION_TYPE_HOME_CONTROLS);
}
@@ -61,6 +73,12 @@ public class DreamHomeControlsPreferenceController extends TogglePreferenceContr
return true;
}
private boolean controlsEnabledOnLockscreen() {
return Settings.Secure.getInt(
mContext.getContentResolver(),
Settings.Secure.LOCKSCREEN_SHOW_CONTROLS, 0) != 0;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_display;