sm6150-common: parts: Hide doze brightness if it is not supported

Change-Id: Ib88dd2db8c872ebb2d4daf3f3b0c996d766dfd9e
This commit is contained in:
Arian 2021-07-03 21:29:24 +02:00
parent 10f101e143
commit 7764bbddc7
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9
2 changed files with 8 additions and 3 deletions

View File

@ -42,6 +42,7 @@ import androidx.preference.PreferenceFragment;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
import org.lineageos.settings.R; import org.lineageos.settings.R;
import org.lineageos.settings.utils.FileUtils;
public class DozeSettingsFragment extends PreferenceFragment public class DozeSettingsFragment extends PreferenceFragment
implements OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener { implements OnPreferenceChangeListener, CompoundButton.OnCheckedChangeListener {
@ -109,15 +110,19 @@ public class DozeSettingsFragment extends PreferenceFragment
getPreferenceScreen().removePreference(proximitySensorCategory); getPreferenceScreen().removePreference(proximitySensorCategory);
} }
// Hide AOD if not supported and set all its dependents otherwise // Hide AOD and doze brightness if not supported and set all its dependents otherwise
if (!DozeUtils.alwaysOnDisplayAvailable(getActivity())) { if (!DozeUtils.alwaysOnDisplayAvailable(getActivity())) {
getPreferenceScreen().removePreference(mAlwaysOnDisplayPreference); getPreferenceScreen().removePreference(mAlwaysOnDisplayPreference);
getPreferenceScreen().removePreference(mDozeBrightnessPreference); getPreferenceScreen().removePreference(mDozeBrightnessPreference);
} else { } else {
if (!FileUtils.isFileWritable(DozeUtils.DOZE_MODE_PATH)) {
getPreferenceScreen().removePreference(mDozeBrightnessPreference);
} else {
DozeUtils.updateDozeBrightnessIcon(getContext(), mDozeBrightnessPreference);
}
mWakeOnGesturePreference.setDependency(DozeUtils.ALWAYS_ON_DISPLAY); mWakeOnGesturePreference.setDependency(DozeUtils.ALWAYS_ON_DISPLAY);
pickupSensorCategory.setDependency(DozeUtils.ALWAYS_ON_DISPLAY); pickupSensorCategory.setDependency(DozeUtils.ALWAYS_ON_DISPLAY);
proximitySensorCategory.setDependency(DozeUtils.ALWAYS_ON_DISPLAY); proximitySensorCategory.setDependency(DozeUtils.ALWAYS_ON_DISPLAY);
DozeUtils.updateDozeBrightnessIcon(getContext(), mDozeBrightnessPreference);
} }
} }

View File

@ -53,7 +53,7 @@ public final class DozeUtils {
protected static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave"; protected static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave";
protected static final String GESTURE_POCKET_KEY = "gesture_pocket"; protected static final String GESTURE_POCKET_KEY = "gesture_pocket";
private static final String DOZE_MODE_PATH = protected static final String DOZE_MODE_PATH =
"/sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode"; "/sys/devices/platform/soc/soc:qcom,dsi-display/doze_mode";
protected static final String DOZE_MODE_HBM = "1"; protected static final String DOZE_MODE_HBM = "1";
protected static final String DOZE_MODE_LBM = "0"; protected static final String DOZE_MODE_LBM = "0";