sdm660-common: DeviceSettings: Fix null object reference of thermal
* also optimize code with references
This commit is contained in:
parent
313ca103eb
commit
3a742e8c0b
5 changed files with 21 additions and 12 deletions
|
@ -4,6 +4,7 @@ include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||||
|
androidx.core_core \
|
||||||
androidx.preference_preference
|
androidx.preference_preference
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:width="24.0dp"
|
||||||
android:width="24dp"
|
android:height="24.0dp"
|
||||||
android:height="24dp"
|
android:viewportWidth="24.0"
|
||||||
android:viewportWidth="24"
|
android:viewportHeight="24.0"
|
||||||
android:viewportHeight="24"
|
|
||||||
android:tint="?android:attr/colorControlNormal">
|
android:tint="?android:attr/colorControlNormal">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#FFFFFFFF"
|
android:fillColor="#FFFFFFFF"
|
||||||
|
|
|
@ -18,5 +18,5 @@
|
||||||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase" />
|
<style name="PreferenceTheme" parent="@android:style/Theme.DeviceDefault.Settings" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
android:title="@string/thermal_profile_title">
|
android:title="@string/thermal_profile_title">
|
||||||
|
|
||||||
<org.lineageos.settings.device.preferences.SecureSettingListPreference
|
<org.lineageos.settings.device.preferences.SecureSettingListPreference
|
||||||
|
android:persistent="true"
|
||||||
android:defaultValue="0"
|
android:defaultValue="0"
|
||||||
android:dialogTitle="@string/thermal_dialogTitle"
|
android:dialogTitle="@string/thermal_dialogTitle"
|
||||||
android:entries="@array/thermal_profiles"
|
android:entries="@array/thermal_profiles"
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
||||||
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
|
// KCAL
|
||||||
if (Settings.Secure.getInt(context.getContentResolver(), PREF_ENABLED, 0) == 1) {
|
if (Settings.Secure.getInt(context.getContentResolver(), PREF_ENABLED, 0) == 1) {
|
||||||
FileUtils.setValue(KCAL_ENABLE, Settings.Secure.getInt(context.getContentResolver(),
|
FileUtils.setValue(KCAL_ENABLE, Settings.Secure.getInt(context.getContentResolver(),
|
||||||
PREF_ENABLED, 0));
|
PREF_ENABLED, 0));
|
||||||
|
@ -59,20 +60,28 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
||||||
PREF_HUE, HUE_DEFAULT));
|
PREF_HUE, HUE_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Audio Gain
|
||||||
int gain = Settings.Secure.getInt(context.getContentResolver(),
|
int gain = Settings.Secure.getInt(context.getContentResolver(),
|
||||||
DeviceSettings.PREF_HEADPHONE_GAIN, 0);
|
DeviceSettings.PREF_HEADPHONE_GAIN, 0);
|
||||||
FileUtils.setValue(HEADPHONE_GAIN_PATH, gain + " " + gain);
|
FileUtils.setValue(HEADPHONE_GAIN_PATH, gain + " " + gain);
|
||||||
FileUtils.setValue(MIC_GAIN_PATH, Settings.Secure.getInt(context.getContentResolver(),
|
FileUtils.setValue(MIC_GAIN_PATH, Settings.Secure.getInt(context.getContentResolver(),
|
||||||
DeviceSettings.PREF_MIC_GAIN, 0));
|
DeviceSettings.PREF_MIC_GAIN, 0));
|
||||||
|
|
||||||
|
// Notification LED
|
||||||
FileUtils.setValue(DeviceSettings.NOTIF_LED_PATH,(1 + Math.pow(1.05694, Settings.Secure.getInt(
|
FileUtils.setValue(DeviceSettings.NOTIF_LED_PATH,(1 + Math.pow(1.05694, Settings.Secure.getInt(
|
||||||
context.getContentResolver(), DeviceSettings.PREF_NOTIF_LED, 100))));
|
context.getContentResolver(), DeviceSettings.PREF_NOTIF_LED, 100))));
|
||||||
|
|
||||||
|
// Vibration Strength
|
||||||
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(
|
|
||||||
context.getContentResolver(), DeviceSettings.PREF_THERMAL));
|
|
||||||
|
|
||||||
boolean enabled = Settings.Secure.getInt(context.getContentResolver(), DeviceSettings.PREF_KEY_FPS_INFO, 0) == 1;
|
// Thermal
|
||||||
|
FileUtils.setValue(DeviceSettings.THERMAL_PATH, Settings.Secure.getInt(context.getContentResolver(),
|
||||||
|
DeviceSettings.PREF_THERMAL, 0));
|
||||||
|
|
||||||
|
// FPS Info
|
||||||
|
boolean enabled = Settings.Secure.getInt(context.getContentResolver(),
|
||||||
|
DeviceSettings.PREF_KEY_FPS_INFO, 0) == 1;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
context.startService(new Intent(context, FPSInfoService.class));
|
context.startService(new Intent(context, FPSInfoService.class));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue