sdm660-common: XiaomiParts: add notification LED brightness slider
Signed-off-by: Dušan Uverić <dusan.uveric9@gmail.com> Change-Id: I86851420cca27d34e36f8e385859c5be63545bba
This commit is contained in:
parent
b0fa4e9f51
commit
3476f16be6
7 changed files with 64 additions and 0 deletions
|
@ -22,6 +22,10 @@
|
||||||
<!-- KCal -->
|
<!-- KCal -->
|
||||||
<string name="device_kcal_title">Display Color Calibration</string>
|
<string name="device_kcal_title">Display Color Calibration</string>
|
||||||
|
|
||||||
|
<!-- Notification LED brightness -->
|
||||||
|
<string name="notification_title">Notification LED</string>
|
||||||
|
<string name="notification_led_title">LED brightness</string>
|
||||||
|
|
||||||
<!-- Ambient Display -->
|
<!-- Ambient Display -->
|
||||||
<string name="ambient_display_xiaomi">Xiaomi Doze</string>
|
<string name="ambient_display_xiaomi">Xiaomi Doze</string>
|
||||||
<string name="advanced_doze_summary">Ambient Display</string>
|
<string name="advanced_doze_summary">Ambient Display</string>
|
||||||
|
|
|
@ -28,6 +28,17 @@
|
||||||
app:units="%" />
|
app:units="%" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="notification_led"
|
||||||
|
android:title="@string/notification_title">
|
||||||
|
<org.lineageos.settings.device.preferences.NotificationLedSeekBarPreference
|
||||||
|
android:key="notification_led_brightness"
|
||||||
|
android:title="@string/notification_led_title"
|
||||||
|
android:max="64"
|
||||||
|
app:min="1"
|
||||||
|
android:defaultValue="64" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="display"
|
android:key="display"
|
||||||
android:title="@string/display_title">
|
android:title="@string/display_title">
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
||||||
PREF_HUE, HUE_DEFAULT));
|
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(
|
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);
|
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(
|
FileUtils.setValue(DeviceSettings.THERMAL_PATH, Settings.Secure.getString(
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.lineageos.settings.device.kcal.KCalSettingsActivity;
|
||||||
import org.lineageos.settings.device.preferences.SecureSettingListPreference;
|
import org.lineageos.settings.device.preferences.SecureSettingListPreference;
|
||||||
import org.lineageos.settings.device.preferences.SecureSettingSwitchPreference;
|
import org.lineageos.settings.device.preferences.SecureSettingSwitchPreference;
|
||||||
import org.lineageos.settings.device.preferences.VibrationSeekBarPreference;
|
import org.lineageos.settings.device.preferences.VibrationSeekBarPreference;
|
||||||
|
import org.lineageos.settings.device.preferences.NotificationLedSeekBarPreference;
|
||||||
|
|
||||||
public class DeviceSettings extends PreferenceFragment implements
|
public class DeviceSettings extends PreferenceFragment implements
|
||||||
Preference.OnPreferenceChangeListener {
|
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 PREF_VIBRATION_STRENGTH = "vibration_strength";
|
||||||
public static final String VIBRATION_STRENGTH_PATH = "/sys/devices/virtual/timed_output/vibrator/vtg_level";
|
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
|
// value of vtg_min and vtg_max
|
||||||
public static final int MIN_VIBRATION = 116;
|
public static final int MIN_VIBRATION = 116;
|
||||||
public static final int MAX_VIBRATION = 3596;
|
public static final int MAX_VIBRATION = 3596;
|
||||||
|
@ -62,6 +67,12 @@ public class DeviceSettings extends PreferenceFragment implements
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.preferences_xiaomi_parts, 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);
|
VibrationSeekBarPreference vibrationStrength = (VibrationSeekBarPreference) findPreference(PREF_VIBRATION_STRENGTH);
|
||||||
vibrationStrength.setEnabled(FileUtils.fileWritable(VIBRATION_STRENGTH_PATH));
|
vibrationStrength.setEnabled(FileUtils.fileWritable(VIBRATION_STRENGTH_PATH));
|
||||||
vibrationStrength.setOnPreferenceChangeListener(this);
|
vibrationStrength.setOnPreferenceChangeListener(this);
|
||||||
|
@ -121,6 +132,10 @@ public class DeviceSettings extends PreferenceFragment implements
|
||||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
final String key = preference.getKey();
|
final String key = preference.getKey();
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case PREF_NOTIF_LED:
|
||||||
|
FileUtils.setValue(NOTIF_LED_PATH, (int) value);
|
||||||
|
break;
|
||||||
|
|
||||||
case PREF_VIBRATION_STRENGTH:
|
case PREF_VIBRATION_STRENGTH:
|
||||||
double vibrationValue = (int) value / 100.0 * (MAX_VIBRATION - MIN_VIBRATION) + MIN_VIBRATION;
|
double vibrationValue = (int) value / 100.0 * (MAX_VIBRATION - MIN_VIBRATION) + MIN_VIBRATION;
|
||||||
FileUtils.setValue(VIBRATION_STRENGTH_PATH, vibrationValue);
|
FileUtils.setValue(VIBRATION_STRENGTH_PATH, vibrationValue);
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
4
sepolicy/vendor/file_contexts
vendored
4
sepolicy/vendor/file_contexts
vendored
|
@ -44,6 +44,10 @@
|
||||||
/sys/devices/platform/kcal_ctrl.0(/.*)? u:object_r:kcal_dev:s0
|
/sys/devices/platform/kcal_ctrl.0(/.*)? u:object_r:kcal_dev:s0
|
||||||
/sys/bus/platform/drivers/kcal_ctrl(/.*)? 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
|
# Light HAL
|
||||||
/(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service\.xiaomi_sdm660 u:object_r:hal_light_default_exec:s0
|
/(vendor|system/vendor)/bin/hw/android\.hardware\.light@2\.0-service\.xiaomi_sdm660 u:object_r:hal_light_default_exec:s0
|
||||||
|
|
||||||
|
|
2
sepolicy/vendor/system_app.te
vendored
2
sepolicy/vendor/system_app.te
vendored
|
@ -9,6 +9,8 @@ allow system_app sysfs_thermal:file rw_file_perms;
|
||||||
allow system_app sysfs_thermal:dir search;
|
allow system_app sysfs_thermal:dir search;
|
||||||
allow system_app sysfs_vibrator:file rw_file_perms;
|
allow system_app sysfs_vibrator:file rw_file_perms;
|
||||||
allow system_app sysfs_vibrator:dir search;
|
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;
|
allow system_app sysfs_leds:dir search;
|
||||||
|
|
||||||
set_prop(system_app, system_prop);
|
set_prop(system_app, system_prop);
|
||||||
|
|
Loading…
Reference in a new issue