diff --git a/XiaomiParts/res/values/strings.xml b/XiaomiParts/res/values/strings.xml
index d124f275..aca14513 100644
--- a/XiaomiParts/res/values/strings.xml
+++ b/XiaomiParts/res/values/strings.xml
@@ -22,6 +22,10 @@
Display Color Calibration
+
+ Notification LED
+ LED brightness
+
Xiaomi Doze
Ambient Display
diff --git a/XiaomiParts/res/xml/preferences_xiaomi_parts.xml b/XiaomiParts/res/xml/preferences_xiaomi_parts.xml
index f0e16a76..5744516e 100644
--- a/XiaomiParts/res/xml/preferences_xiaomi_parts.xml
+++ b/XiaomiParts/res/xml/preferences_xiaomi_parts.xml
@@ -28,6 +28,17 @@
app:units="%" />
+
+
+
+
diff --git a/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java b/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java
index 5092ab1a..2e31d14a 100644
--- a/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java
+++ b/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java
@@ -53,6 +53,8 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
PREF_HUE, HUE_DEFAULT));
}
+ FileUtils.setValue(DeviceSettings.NOTIF_LED_PATH, Settings.Secure.getInt(
+ context.getContentResolver(), DeviceSettings.PREF_NOTIF_LED, 64));
FileUtils.setValue(DeviceSettings.VIBRATION_STRENGTH_PATH, Settings.Secure.getInt(
context.getContentResolver(), DeviceSettings.PREF_VIBRATION_STRENGTH, 80) / 100.0 * (DeviceSettings.MAX_VIBRATION - DeviceSettings.MIN_VIBRATION) + DeviceSettings.MIN_VIBRATION);
FileUtils.setValue(DeviceSettings.THERMAL_PATH, Settings.Secure.getString(
diff --git a/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java b/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java
index 87d960da..70d4efae 100644
--- a/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java
+++ b/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java
@@ -27,6 +27,7 @@ import org.lineageos.settings.device.kcal.KCalSettingsActivity;
import org.lineageos.settings.device.preferences.SecureSettingListPreference;
import org.lineageos.settings.device.preferences.SecureSettingSwitchPreference;
import org.lineageos.settings.device.preferences.VibrationSeekBarPreference;
+import org.lineageos.settings.device.preferences.NotificationLedSeekBarPreference;
public class DeviceSettings extends PreferenceFragment implements
Preference.OnPreferenceChangeListener {
@@ -34,6 +35,10 @@ public class DeviceSettings extends PreferenceFragment implements
public static final String PREF_VIBRATION_STRENGTH = "vibration_strength";
public static final String VIBRATION_STRENGTH_PATH = "/sys/devices/virtual/timed_output/vibrator/vtg_level";
+ public static final String CATEGORY_NOTIF = "notification_led";
+ public static final String PREF_NOTIF_LED = "notification_led_brightness";
+ public static final String NOTIF_LED_PATH = "/sys/class/leds/white/max_brightness";
+
// value of vtg_min and vtg_max
public static final int MIN_VIBRATION = 116;
public static final int MAX_VIBRATION = 3596;
@@ -62,6 +67,12 @@ public class DeviceSettings extends PreferenceFragment implements
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences_xiaomi_parts, rootKey);
+ if (FileUtils.fileWritable(NOTIF_LED_PATH)) {
+ NotificationLedSeekBarPreference notifLedBrightness =
+ (NotificationLedSeekBarPreference) findPreference(PREF_NOTIF_LED);
+ notifLedBrightness.setOnPreferenceChangeListener(this);
+ } else { getPreferenceScreen().removePreference(findPreference(CATEGORY_NOTIF)); }
+
VibrationSeekBarPreference vibrationStrength = (VibrationSeekBarPreference) findPreference(PREF_VIBRATION_STRENGTH);
vibrationStrength.setEnabled(FileUtils.fileWritable(VIBRATION_STRENGTH_PATH));
vibrationStrength.setOnPreferenceChangeListener(this);
@@ -121,6 +132,10 @@ public class DeviceSettings extends PreferenceFragment implements
public boolean onPreferenceChange(Preference preference, Object value) {
final String key = preference.getKey();
switch (key) {
+ case PREF_NOTIF_LED:
+ FileUtils.setValue(NOTIF_LED_PATH, (int) value);
+ break;
+
case PREF_VIBRATION_STRENGTH:
double vibrationValue = (int) value / 100.0 * (MAX_VIBRATION - MIN_VIBRATION) + MIN_VIBRATION;
FileUtils.setValue(VIBRATION_STRENGTH_PATH, vibrationValue);
diff --git a/XiaomiParts/src/org/lineageos/settings/device/preferences/NotificationLedSeekBarPreference.java b/XiaomiParts/src/org/lineageos/settings/device/preferences/NotificationLedSeekBarPreference.java
new file mode 100644
index 00000000..f01a6465
--- /dev/null
+++ b/XiaomiParts/src/org/lineageos/settings/device/preferences/NotificationLedSeekBarPreference.java
@@ -0,0 +1,26 @@
+package org.lineageos.settings.device.preferences;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.SeekBar;
+import org.lineageos.settings.device.FileUtils;
+
+public class NotificationLedSeekBarPreference extends SecureSettingCustomSeekBarPreference {
+
+ public static final String NOTIF_LED_PATH = "/sys/class/leds/white/brightness";
+
+ public NotificationLedSeekBarPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ notifyChanged();
+ FileUtils.setValue(NOTIF_LED_PATH, 64);
+ }
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ notifyChanged();
+ FileUtils.setValue(NOTIF_LED_PATH, 0);
+ }
+}
\ No newline at end of file
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
index 652c0d0c..1d60d493 100644
--- a/sepolicy/vendor/file_contexts
+++ b/sepolicy/vendor/file_contexts
@@ -44,6 +44,10 @@
/sys/devices/platform/kcal_ctrl.0(/.*)? u:object_r:kcal_dev:s0
/sys/bus/platform/drivers/kcal_ctrl(/.*)? u:object_r:kcal_dev:s0
+# Notification LED
+/devices/soc/800f000.qcom,spmi/spmi-0/spmi0-03/800f000.qcom,spmi:qcom,pm660l@3:qcom,leds@d000/leds/white/max_brightness u:object_r:sysfs_graphics:s0
+/devices/soc/800f000.qcom,spmi/spmi-0/spmi0-03/800f000.qcom,spmi:qcom,pm660l@3:qcom,leds@d000/leds/white/brightness u:object_r:sysfs_graphics:s0
+
# Light HAL
/(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service\.xiaomi_sdm660 u:object_r:hal_light_default_exec:s0
diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te
index 25ae0677..600dadeb 100644
--- a/sepolicy/vendor/system_app.te
+++ b/sepolicy/vendor/system_app.te
@@ -9,6 +9,8 @@ allow system_app sysfs_thermal:file rw_file_perms;
allow system_app sysfs_thermal:dir search;
allow system_app sysfs_vibrator:file rw_file_perms;
allow system_app sysfs_vibrator:dir search;
+allow system_app sysfs_graphics:dir search;
+allow system_app sysfs_graphics:file rw_file_perms;
allow system_app sysfs_leds:dir search;
set_prop(system_app, system_prop);