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
|
@ -1,9 +1,10 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
ifeq ($(BOARD_VENDOR_PLATFORM),xiaomi-sdm660)
|
||||
ifeq ($(BOARD_VENDOR_PLATFORM), xiaomi-sdm660)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
androidx.core_core \
|
||||
androidx.preference_preference
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
android:width="24.0dp"
|
||||
android:height="24.0dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M17,1L7,1C5.9,1,5,1.9,5,3v2h2v4H5v12c0,1.1,0.9,2,2,2h10c1.1,0,2-0.9,2-2V3C19,1.9,18.1,1,17,1z M11,21H7v-2h4V21z M17,21 h-4v-2h4V21z" />
|
||||
|
|
|
@ -18,5 +18,5 @@
|
|||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceTheme" parent="@style/PreferenceThemeOverlay.SettingsBase" />
|
||||
<style name="PreferenceTheme" parent="@android:style/Theme.DeviceDefault.Settings" />
|
||||
</resources>
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
android:title="@string/thermal_profile_title">
|
||||
|
||||
<org.lineageos.settings.device.preferences.SecureSettingListPreference
|
||||
android:persistent="true"
|
||||
android:defaultValue="0"
|
||||
android:dialogTitle="@string/thermal_dialogTitle"
|
||||
android:entries="@array/thermal_profiles"
|
||||
|
|
|
@ -33,6 +33,7 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
|||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
// KCAL
|
||||
if (Settings.Secure.getInt(context.getContentResolver(), PREF_ENABLED, 0) == 1) {
|
||||
FileUtils.setValue(KCAL_ENABLE, Settings.Secure.getInt(context.getContentResolver(),
|
||||
PREF_ENABLED, 0));
|
||||
|
@ -59,20 +60,28 @@ public class BootReceiver extends BroadcastReceiver implements Utils {
|
|||
PREF_HUE, HUE_DEFAULT));
|
||||
}
|
||||
|
||||
// Audio Gain
|
||||
int gain = Settings.Secure.getInt(context.getContentResolver(),
|
||||
DeviceSettings.PREF_HEADPHONE_GAIN, 0);
|
||||
FileUtils.setValue(HEADPHONE_GAIN_PATH, gain + " " + gain);
|
||||
FileUtils.setValue(MIC_GAIN_PATH, Settings.Secure.getInt(context.getContentResolver(),
|
||||
DeviceSettings.PREF_MIC_GAIN, 0));
|
||||
|
||||
// Notification LED
|
||||
FileUtils.setValue(DeviceSettings.NOTIF_LED_PATH,(1 + Math.pow(1.05694, Settings.Secure.getInt(
|
||||
context.getContentResolver(), DeviceSettings.PREF_NOTIF_LED, 100))));
|
||||
|
||||
// Vibration Strength
|
||||
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(
|
||||
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) {
|
||||
context.startService(new Intent(context, FPSInfoService.class));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue