3
0

galaxys2: advanced settings: add content adaptive backlight control

Change-Id: I325d9663d7d1b82a7ebfb112e983a485689b063b
This commit is contained in:
Daniel Hillenbrand 2013-06-09 11:07:54 +02:00
parent 036beb482d
commit 01917c8934
6 changed files with 132 additions and 50 deletions

View File

@ -4,8 +4,15 @@
<string name="defaults_button">Reset to default</string>
<!-- Screen Preference -->
<string name="category_screen_title">Screen</string>
<string name="screen_colors_title">Colors</string>
<!-- Content adaptive backlight control -->
<string name="cabc_title_head">CABC</string>
<string name="cabc_summary_head">Enable content adaptive backlight control</string>
<!-- mDNIe -->
<string name="mdnie_scenario_title_head">Scenario</string>
<string name="mdnie_scenario_summary_head">Set the mDNIe Scenario</string>
<string name="mdnie_mode_title_head">Mode</string>
@ -17,16 +24,19 @@
<string name="panel_gamma_title_head">Screen Gamma</string>
<string name="panel_gamma_summary_head">Set screen gamma value</string>
<!-- Touchscreen tuning -->
<string name="touchscreen_subcat_title">Touchscreen</string>
<string name="touchscreen_sensitivity_title_head">Touch sensitivity</string>
<string name="touchscreen_sensitivity_summary_head">Set touch panel sensitivity</string>
<!-- Touchkey tuning -->
<string name="touchkey_subcat_title">Touchkeys</string>
<string name="touchkey_light_title_head">Enable keys backlight</string>
<string name="touchkey_light_summary_head">Light up touchkeys when screen is on</string>
<string name="touchkey_timeout_title_head">Backlight timeout</string>
<string name="touchkey_timeout_summary_head">Delay after a keypress before backlight turns off</string>
<!-- Sensors Preference -->
<string name="category_sensors_title">Sensors</string>
<string name="accelerometer_subcat_title">Accelerometer</string>
<string name="use_accelerometer_calibration_title_head">Use calibration data</string>
@ -45,10 +55,12 @@
<string name="vibrator_tuning_summary_head">Adjust the strength of the vibration feedback</string>
<string name="vibrator_warning">Values higher than %1$d are not recommended</string>
<!-- Radio Preference -->
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
<!-- Dock Preference -->
<string name="category_dock_title">Dock</string>
<string name="dockaudio_subcat_title">Audio</string>
<string name="use_dock_audio_title_head">Use Dock USB Audio</string>

View File

@ -4,6 +4,12 @@
<PreferenceCategory
android:title="@string/screen_colors_title">
<!-- CABC -->
<com.cyanogenmod.settings.device.CABC
android:key="cabc"
android:title="@string/cabc_title_head"
android:summary="@string/cabc_summary_head"
android:defaultValue="true" />
<!-- mDNIe Scenario modes -->
<com.cyanogenmod.settings.device.mDNIeScenario
@ -49,8 +55,9 @@
android:entries="@array/panel_gamma_entries"
android:entryValues="@array/panel_gamma_entries_values"
android:defaultValue="0" />
</PreferenceCategory>
<!-- Touchscreen -->
<PreferenceCategory
android:title="@string/touchscreen_subcat_title">
<com.cyanogenmod.settings.device.TouchscreenSensitivity
@ -62,22 +69,21 @@
android:defaultValue="50" />
</PreferenceCategory>
<!-- Touchkeys -->
<PreferenceCategory
android:title="@string/touchkey_subcat_title">
<!-- Touchkey backlight -->
<CheckBoxPreference
android:key="touchkey_light"
android:title="@string/touchkey_light_title_head"
android:summary="@string/touchkey_light_summary_head"
android:defaultValue="true"
/>
android:defaultValue="true" />
<com.cyanogenmod.settings.device.TouchkeyTimeout
android:key="touchkey_timeout"
android:title="@string/touchkey_timeout_title_head"
android:summary="@string/touchkey_timeout_summary_head"
android:entries="@array/touchkey_timeout_entries"
android:entryValues="@array/touchkey_timeout_entries_values"
android:defaultValue="3"
/>
android:defaultValue="3" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cyanogenmod.settings.device;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
public class CABC extends CheckBoxPreference implements OnPreferenceChangeListener {
public CABC(Context context, AttributeSet attrs) {
super(context, attrs);
this.setOnPreferenceChangeListener(this);
}
private static final String FILE = "/sys/class/lcd/panel/power_reduce";
public static boolean isSupported() {
return Utils.fileExists(FILE);
}
/**
* Restore cabc setting from SharedPreferences. (Write to kernel.)
* @param context The context to read the SharedPreferences from
*/
public static void restore(Context context) {
if (!isSupported()) {
return;
}
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Utils.writeValue(FILE, sharedPrefs.getBoolean(DeviceSettings.KEY_CABC, true) ? "1" : "0");
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
Utils.writeValue(FILE, (Boolean)newValue ? "1" : "0");
return true;
}
}

View File

@ -35,6 +35,7 @@ public class DeviceSettings extends FragmentActivity {
public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device";
public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE";
public static final String KEY_CABC = "cabc";
public static final String KEY_MDNIE_SCENARIO = "mdnie_scenario";
public static final String KEY_MDNIE_MODE = "mdnie_mode";
public static final String KEY_MDNIE_NEGATIVE = "mdnie_negative";

View File

@ -37,6 +37,7 @@ public class ScreenFragmentActivity extends PreferenceFragment {
private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable";
private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness";
private CABC mCABC;
private mDNIeScenario mmDNIeScenario;
private mDNIeMode mmDNIeMode;
private mDNIeNegative mmDNIeNegative;
@ -51,6 +52,9 @@ public class ScreenFragmentActivity extends PreferenceFragment {
addPreferencesFromResource(R.xml.screen_preferences);
PreferenceScreen prefSet = getPreferenceScreen();
mCABC = (CABC) findPreference(DeviceSettings.KEY_CABC);
mCABC.setEnabled(CABC.isSupported());
mmDNIeScenario = (mDNIeScenario) findPreference(DeviceSettings.KEY_MDNIE_SCENARIO);
mmDNIeScenario.setEnabled(mDNIeScenario.isSupported());

View File

@ -24,6 +24,7 @@ public class Startup extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent bootintent) {
CABC.restore(context);
DockFragmentActivity.restore(context);
HapticFragmentActivity.restore(context);
mDNIeScenario.restore(context);