summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Mertz <scott@cyngn.com>2015-02-09 12:55:55 -0800
committerAdnan Begovic <adnan@cyngn.com>2015-10-29 17:36:31 -0700
commitba4c43f77699721dff7c2536ee61c0f8c18ea446 (patch)
treedbdb89b6dbf9d21f58574956256f7a3048c18460
parent306c2881c045ccf0e1afc4494fe9e50781f88818 (diff)
downloadpackages_apps_Settings-ba4c43f77699721dff7c2536ee61c0f8c18ea446.zip
packages_apps_Settings-ba4c43f77699721dff7c2536ee61c0f8c18ea446.tar.gz
packages_apps_Settings-ba4c43f77699721dff7c2536ee61c0f8c18ea446.tar.bz2
Settings: Change to CmHardwareService
Change-Id: Iab392aefa9476a2e956a697210f3f7e6426ff815
-rw-r--r--Android.mk1
-rw-r--r--AndroidManifest.xml41
-rw-r--r--src/com/android/settings/ButtonSettings.java36
-rw-r--r--src/com/android/settings/DisplaySettings.java46
-rw-r--r--src/com/android/settings/cyanogenmod/BootReceiver.java2
-rw-r--r--src/com/android/settings/hardware/VibratorIntensity.java68
-rw-r--r--src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java71
-rw-r--r--src/com/android/settings/livedisplay/DisplayGamma.java122
-rw-r--r--src/com/android/settings/livedisplay/LiveDisplay.java74
9 files changed, 223 insertions, 238 deletions
diff --git a/Android.mk b/Android.mk
index 10ce94f..365e797 100644
--- a/Android.mk
+++ b/Android.mk
@@ -35,7 +35,6 @@ include frameworks/opt/setupwizard/library/common.mk
include frameworks/base/packages/SettingsLib/common.mk
LOCAL_JAVA_LIBRARIES += org.cyanogenmod.hardware
-
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fe1ffb0..dd86301 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -83,6 +83,7 @@
<uses-permission android:name="android.permission.PEERS_MAC_ADDRESS"/>
<uses-permission android:name="cyanogenmod.permission.FINISH_SETUP" />
<uses-permission android:name="cyanogenmod.permission.MODIFY_PROFILES" />
+ <uses-permission android:name="android.permission.HARDWARE_ABSTRACTION_ACCESS" />
<application android:label="@string/settings_label"
android:icon="@mipmap/ic_launcher_settings"
@@ -104,10 +105,6 @@
android:screenOrientation="nosensor">
</activity>
- <!-- Settings -->
- <uses-library android:name="org.cyanogenmod.hardware"
- android:required="false" />
-
<activity android:name="Settings"
android:taskAffinity="com.android.settings"
android:label="@string/settings_label_launcher"
@@ -2215,40 +2212,6 @@
</intent-filter>
</activity>
-<<<<<<< HEAD
- <!-- CyanogenMod activities End -->
-=======
- <activity android:name=".cyanogenmod.ContributorsCloud" />
-
- <activity android:name=".cyanogenmod.SpamList" />
-
- <!-- "Blacklist settings" UI, used only on voice-capable phone devices. -->
- <activity android:name="Settings$BlacklistSettingsActivity"
- android:uiOptions="splitActionBarWhenNarrow"
- android:label="@string/blacklist_title"
- android:excludeFromRecents="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.blacklist.BlacklistSettings" />
- <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
- android:resource="@id/security_settings" />
- </activity>
-
- <activity-alias android:name=".blacklist.BlacklistSettings"
- android:taskAffinity="com.android.settings"
- android:label="@string/blacklist_title"
- android:targetActivity="Settings$BlacklistSettingsActivity"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:exported="true">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.blacklist.BlacklistSettings" />
- <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
- android:resource="@id/security_settings" />
- </activity-alias>
-
<!-- LiveDisplay settings -->
<activity android:name="Settings$LiveDisplayActivity"
android:label="@string/live_display_title"
@@ -2278,7 +2241,7 @@
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/display_and_lights_settings" />
</activity-alias>
->>>>>>> eda58c5... livedisplay: Add LiveDisplay settings
+ <!-- CyanogenMod activities End -->
<!-- Pseudo-activity used to provide an intent-filter entry point to encryption settings -->
<activity android:name="Settings$CryptKeeperSettingsActivity"
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java
index 85d1541..f9d29e2 100644
--- a/src/com/android/settings/ButtonSettings.java
+++ b/src/com/android/settings/ButtonSettings.java
@@ -25,6 +25,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
+import android.hardware.CmHardwareManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.Handler;
@@ -49,6 +50,10 @@ import com.android.settings.Utils;
import com.android.settings.cyanogenmod.ButtonBacklightBrightness;
import org.cyanogenmod.hardware.KeyDisabler;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+
+import java.util.List;
public class ButtonSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
@@ -195,10 +200,13 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
mNavigationRecentsLongPressAction =
initRecentsLongPressAction(KEY_NAVIGATION_RECENTS_LONG_PRESS);
+ final CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+
// Only visible on devices that does not have a navigation bar already,
// and don't even try unless the existing keys can be disabled
boolean needsNavigationBar = false;
- if (isKeyDisablerSupported()) {
+ if (cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE)) {
try {
IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
needsNavigationBar = wm.needsNavigationBar();
@@ -361,9 +369,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
mNavigationPreferencesCat.removePreference(mNavigationBarLeftPref);
}
- if ((!hasNavBar && (needsNavigationBar || !isKeyDisablerSupported())) ||
- (mNavigationPreferencesCat.getPreferenceCount() == 0)
- ) {
+ if (!hasNavBar && (needsNavigationBar ||
+ !cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE))) {
// Hide navigation bar category
prefScreen.removePreference(mNavigationPreferencesCat);
}
@@ -563,9 +570,11 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
final int defaultBrightness = context.getResources().getInteger(
com.android.internal.R.integer.config_buttonBrightnessSettingDefault);
- Settings.System.putInt(context.getContentResolver(),
- Settings.System.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
- KeyDisabler.setActive(enabled);
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ cmHardwareManager.set(CmHardwareManager.FEATURE_KEY_DISABLE, enabled);
/* Save/restore button timeouts to disable them in softkey mode */
Editor editor = prefs.edit();
@@ -639,7 +648,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
}
public static void restoreKeyDisabler(Context context) {
- if (!isKeyDisablerSupported()) {
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE)) {
return;
}
@@ -680,15 +691,6 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
- private static boolean isKeyDisablerSupported() {
- try {
- return KeyDisabler.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
private void handleTogglePowerButtonEndsCallPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, (mPowerEndCall.isChecked()
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 6340c4e..d601c20 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -24,8 +24,8 @@ import com.android.internal.view.RotationPolicy;
import com.android.settings.DropDownPreference.Callback;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
-
import static android.provider.Settings.Secure.DOUBLE_TAP_TO_WAKE;
+import static android.hardware.CmHardwareManager.FEATURE_TAP_TO_WAKE;
import static android.provider.Settings.Secure.DOZE_ENABLED;
import static android.provider.Settings.Secure.WAKE_GESTURE_ENABLED;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
@@ -45,6 +45,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.SharedPreferences;
+import android.hardware.CmHardwareManager;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
@@ -71,8 +72,6 @@ import java.util.List;
import com.android.settings.Utils;
import com.android.settings.cyanogenmod.DisplayRotation;
-import org.cyanogenmod.hardware.TapToWake;
-
public class DisplaySettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, OnPreferenceClickListener, Indexable {
private static final String TAG = "DisplaySettings";
@@ -113,6 +112,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private SwitchPreference mTapToWake;
private SwitchPreference mWakeWhenPluggedOrUnplugged;
+ private CmHardwareManager mCmHardwareManager;
+
private ContentObserver mAccelerometerRotationObserver =
new ContentObserver(new Handler()) {
@Override
@@ -140,6 +141,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
final Activity activity = getActivity();
final ContentResolver resolver = activity.getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
+ mCmHardwareManager = (CmHardwareManager) activity.getSystemService(Context.CMHW_SERVICE);
mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION);
@@ -207,7 +209,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
mTapToWake = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
- if (!isTapToWakeSupported()) {
+
+ if (!mCmHardwareManager.isSupported(FEATURE_TAP_TO_WAKE)) {
advancedPrefs.removePreference(mTapToWake);
mTapToWake = null;
}
@@ -362,7 +365,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
updateDisplayRotationPreferenceDescription();
if (mTapToWake != null) {
- mTapToWake.setChecked(TapToWake.isEnabled());
+ mTapToWake.setChecked(mCmHardwareManager.get(FEATURE_TAP_TO_WAKE));
}
RotationPolicy.registerRotationPolicyListener(getActivity(),
@@ -448,15 +451,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
}
- private static boolean isTapToWakeSupported() {
- try {
- return TapToWake.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
/**
* Reads the current font size and sets the value in the summary text
*/
@@ -485,7 +479,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference == mTapToWake) {
- return TapToWake.setEnabled(mTapToWake.isChecked());
+ return mCmHardwareManager.set(FEATURE_TAP_TO_WAKE, mTapToWake.isChecked());
} else if (preference == mWakeWhenPluggedOrUnplugged) {
Settings.Global.putInt(getContentResolver(),
Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
@@ -561,15 +555,18 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
/**
* Restore the properties associated with this preference on boot
- @param ctx A valid context
+ *
+ * @param ctx A valid context
*/
public static void restore(Context ctx) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
- if (isTapToWakeSupported()) {
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) ctx.getSystemService(Context.CMHW_SERVICE);
+ if (cmHardwareManager.isSupported(FEATURE_TAP_TO_WAKE)) {
final boolean enabled = prefs.getBoolean(KEY_TAP_TO_WAKE,
- TapToWake.isEnabled());
+ cmHardwareManager.get(FEATURE_TAP_TO_WAKE));
- if (!TapToWake.setEnabled(enabled)) {
+ if (!cmHardwareManager.set(FEATURE_TAP_TO_WAKE, enabled)) {
Log.e(TAG, "Failed to restore tap-to-wake settings.");
} else {
Log.d(TAG, "Tap-to-wake settings restored.");
@@ -579,12 +576,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
- private boolean mHasTapToWake;
-
- @Override
- public void prepare() {
- mHasTapToWake = isTapToWakeSupported();
- }
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
@@ -601,6 +592,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
@Override
public List<String> getNonIndexableKeys(Context context) {
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
ArrayList<String> result = new ArrayList<String>();
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_dreamsSupported)) {
@@ -610,10 +603,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
com.android.internal.R.bool.config_proximityCheckOnWake)) {
result.add(KEY_PROXIMITY_WAKE);
}
- if (!mHasTapToWake) {
+ if (!cmHardwareManager.isSupported(FEATURE_TAP_TO_WAKE)) {
result.add(KEY_TAP_TO_WAKE);
}
-
if (!isAutomaticBrightnessAvailable(context.getResources())) {
result.add(KEY_AUTO_BRIGHTNESS);
}
diff --git a/src/com/android/settings/cyanogenmod/BootReceiver.java b/src/com/android/settings/cyanogenmod/BootReceiver.java
index 7454a3e..4d56e60 100644
--- a/src/com/android/settings/cyanogenmod/BootReceiver.java
+++ b/src/com/android/settings/cyanogenmod/BootReceiver.java
@@ -24,6 +24,7 @@ import com.android.settings.DisplaySettings;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.hardware.VibratorIntensity;
+import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
import com.android.settings.livedisplay.DisplayGamma;
public class BootReceiver extends BroadcastReceiver {
@@ -38,5 +39,6 @@ public class BootReceiver extends BroadcastReceiver {
DisplayGamma.restore(ctx);
VibratorIntensity.restore(ctx);
DisplaySettings.restore(ctx);
+ InputMethodAndLanguageSettings.restore(ctx);
}
}
diff --git a/src/com/android/settings/hardware/VibratorIntensity.java b/src/com/android/settings/hardware/VibratorIntensity.java
index 88f1298..6c00cde 100644
--- a/src/com/android/settings/hardware/VibratorIntensity.java
+++ b/src/com/android/settings/hardware/VibratorIntensity.java
@@ -25,6 +25,7 @@ import android.graphics.Color;
import android.graphics.LightingColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
+import android.hardware.CmHardwareManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.preference.DialogPreference;
@@ -37,7 +38,6 @@ import android.widget.TextView;
import android.widget.Button;
import com.android.settings.R;
-import org.cyanogenmod.hardware.VibratorHW;
public class VibratorIntensity extends DialogPreference implements
SeekBar.OnSeekBarChangeListener {
@@ -46,6 +46,11 @@ public class VibratorIntensity extends DialogPreference implements
private TextView mValue;
private TextView mWarning;
private int mOriginalValue;
+ private int mMinValue;
+ private int mMaxValue;
+ private int mDefaultValue;
+ private int mWarningValue;
+ private CmHardwareManager mCmHardwareManager;
private Drawable mProgressDrawable;
private Drawable mProgressThumb;
@@ -54,7 +59,9 @@ public class VibratorIntensity extends DialogPreference implements
public VibratorIntensity(Context context, AttributeSet attrs) {
super(context, attrs);
- if (!isSupported()) {
+ mCmHardwareManager = (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+
+ if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_VIBRATOR)) {
return;
}
@@ -79,10 +86,16 @@ public class VibratorIntensity extends DialogPreference implements
mValue = (TextView) view.findViewById(R.id.value);
mWarning = (TextView) view.findViewById(R.id.warning_text);
- int warningThreshold = VibratorHW.getWarningThreshold();
- if (warningThreshold > 0) {
+ // Read the current value in case user wants to dismiss his changes
+ mOriginalValue = mCmHardwareManager.getVibratorIntensity();
+ mWarningValue = mCmHardwareManager.getVibratorWarningIntensity();
+ mMinValue = mCmHardwareManager.getVibratorMinIntensity();
+ mMaxValue = mCmHardwareManager.getVibratorMaxIntensity();
+ mDefaultValue = mCmHardwareManager.getVibratorDefaultIntensity();
+ if (mWarningValue > 0) {
String message = getContext().getResources().getString(
- R.string.vibrator_warning, intensityToPercent(warningThreshold));
+ R.string.vibrator_warning, intensityToPercent(mMinValue, mMaxValue,
+ mWarningValue));
mWarning.setText(message);
} else if (mWarning != null) {
mWarning.setVisibility(View.GONE);
@@ -97,12 +110,9 @@ public class VibratorIntensity extends DialogPreference implements
mRedFilter = new LightingColorFilter(Color.BLACK,
getContext().getResources().getColor(android.R.color.holo_red_light));
- // Read the current value in case user wants to dismiss his changes
- mOriginalValue = VibratorHW.getCurIntensity();
-
// Restore percent value from SharedPreferences object
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
- int defaultValue = intensityToPercent(VibratorHW.getDefaultIntensity());
+ int defaultValue = intensityToPercent(mMinValue, mMaxValue, mDefaultValue);
int percent = prefs.getInt(PREF_NAME, defaultValue);
mSeekBar.setOnSeekBarChangeListener(this);
@@ -120,7 +130,7 @@ public class VibratorIntensity extends DialogPreference implements
defaultsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- mSeekBar.setProgress(intensityToPercent(VibratorHW.getDefaultIntensity()));
+ mSeekBar.setProgress(intensityToPercent(mMinValue, mMaxValue, mDefaultValue));
}
});
}
@@ -134,35 +144,32 @@ public class VibratorIntensity extends DialogPreference implements
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putInt(PREF_NAME, mSeekBar.getProgress()).commit();
} else {
- VibratorHW.setIntensity(mOriginalValue);
- }
- }
-
- public static boolean isSupported() {
- try {
- return VibratorHW.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework isn't installed
- return false;
+ mCmHardwareManager.setVibratorIntensity(mCmHardwareManager.getVibratorIntensity());
}
}
public static void restore(Context context) {
- if (!isSupported()) {
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_VIBRATOR)) {
return;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- int defaultValue = intensityToPercent(VibratorHW.getDefaultIntensity());
+ int vibrator = cmHardwareManager.getVibratorIntensity();
+ int min = cmHardwareManager.getVibratorMinIntensity();
+ int max = cmHardwareManager.getVibratorMaxIntensity();
+ int defaultValue = intensityToPercent(min, max,
+ cmHardwareManager.getVibratorDefaultIntensity());
int percent = prefs.getInt(PREF_NAME, defaultValue);
- VibratorHW.setIntensity(percentToIntensity(percent));
+ cmHardwareManager.setVibratorIntensity(percentToIntensity(min, max, percent));
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- int warningThreshold = VibratorHW.getWarningThreshold();
boolean shouldWarn =
- warningThreshold > 0 && progress >= intensityToPercent(warningThreshold);
+ mWarningValue > 0 && progress >= intensityToPercent(mMinValue, mMaxValue,
+ mWarningValue);
if (mProgressDrawable != null) {
mProgressDrawable.setColorFilter(shouldWarn ? mRedFilter : null);
@@ -171,7 +178,8 @@ public class VibratorIntensity extends DialogPreference implements
mProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null);
}
- VibratorHW.setIntensity(percentToIntensity(progress));
+ mCmHardwareManager.setVibratorIntensity(percentToIntensity(mMinValue, mMaxValue,
+ progress));
mValue.setText(String.format("%d%%", progress));
}
@@ -186,9 +194,7 @@ public class VibratorIntensity extends DialogPreference implements
vib.vibrate(200);
}
- private static int intensityToPercent(int value) {
- double maxValue = VibratorHW.getMaxIntensity();
- double minValue = VibratorHW.getMinIntensity();
+ private static int intensityToPercent(double minValue, double maxValue, int value) {
double percent = (value - minValue) * (100 / (maxValue - minValue));
if (percent > 100) {
@@ -200,9 +206,7 @@ public class VibratorIntensity extends DialogPreference implements
return (int) percent;
}
- private static int percentToIntensity(int percent) {
- int maxValue = VibratorHW.getMaxIntensity();
- int minValue = VibratorHW.getMinIntensity();
+ private static int percentToIntensity(int minValue, int maxValue, int percent) {
int value = Math.round((((maxValue - minValue) * percent) / 100) + minValue);
if (value > maxValue) {
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index f796ed8..03e8cb5 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -27,6 +27,7 @@ import android.content.SharedPreferences;
import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
+import android.hardware.CmHardwareManager;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
@@ -43,6 +44,7 @@ import android.provider.Settings;
import android.provider.Settings.System;
import android.speech.tts.TtsEngines;
import android.text.TextUtils;
+import android.util.Log;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -74,13 +76,13 @@ import java.util.List;
import java.util.Locale;
import java.util.TreeSet;
-import org.cyanogenmod.hardware.HighTouchSensitivity;
-import org.cyanogenmod.hardware.TouchscreenHovering;
-
public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
implements Preference.OnPreferenceChangeListener, InputManager.InputDeviceListener,
KeyboardLayoutDialogFragment.OnSetupKeyboardLayoutsListener, Indexable,
InputMethodPreference.OnSavePreferenceListener {
+
+ private static final String TAG = "InputMethodAndLanguageSettings";
+
private static final String KEY_SPELL_CHECKERS = "spellcheckers_settings";
private static final String KEY_PHONE_LANGUAGE = "phone_language";
private static final String KEY_CURRENT_INPUT_METHOD = "current_input_method";
@@ -117,6 +119,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
private Intent mIntentWaitingForResult;
private InputMethodSettingValuesWrapper mInputMethodSettingValues;
private DevicePolicyManager mDpm;
+ private CmHardwareManager mCmHardwareManager;
@Override
protected int getMetricsCategory() {
@@ -133,6 +136,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity);
+ mCmHardwareManager = (CmHardwareManager) getSystemService(Context.CMHW_SERVICE);
+
try {
mDefaultInputMethodSelectorVisibility = Integer.valueOf(
getString(R.string.input_method_selector_visibility_default_value));
@@ -195,18 +200,21 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
pointerSettingsCategory.removePreference(mStylusIconEnabled);
}
- if (!isHighTouchSensitivitySupported()) {
+ if (!mCmHardwareManager.isSupported(
+ CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
pointerSettingsCategory.removePreference(mHighTouchSensitivity);
mHighTouchSensitivity = null;
} else {
- mHighTouchSensitivity.setChecked(HighTouchSensitivity.isEnabled());
+ mHighTouchSensitivity.setChecked(
+ mCmHardwareManager.get(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY));
}
- if (!isTouchscreenHoveringSupported()) {
+ if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_TOUCH_HOVERING)) {
pointerSettingsCategory.removePreference(mTouchscreenHovering);
mTouchscreenHovering = null;
} else {
- mTouchscreenHovering.setChecked(TouchscreenHovering.isEnabled());
+ mTouchscreenHovering.setChecked(
+ mCmHardwareManager.get(CmHardwareManager.FEATURE_TOUCH_HOVERING));
}
Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(),
@@ -404,9 +412,11 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
return true;
}
} else if (preference == mHighTouchSensitivity) {
- return HighTouchSensitivity.setEnabled(mHighTouchSensitivity.isChecked());
+ return mCmHardwareManager.set(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
+ mHighTouchSensitivity.isChecked());
} else if (preference == mTouchscreenHovering) {
- return TouchscreenHovering.setEnabled(mTouchscreenHovering.isChecked());
+ return mCmHardwareManager.set(CmHardwareManager.FEATURE_TOUCH_HOVERING,
+ mTouchscreenHovering.isChecked());
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@@ -684,24 +694,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
}
}
- private static boolean isHighTouchSensitivitySupported() {
- try {
- return HighTouchSensitivity.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
- private static boolean isTouchscreenHoveringSupported() {
- try {
- return TouchscreenHovering.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
private static boolean haveInputDeviceWithVibrator() {
final int[] devices = InputDevice.getDeviceIds();
for (int i = 0; i < devices.length; i++) {
@@ -738,6 +730,31 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
}
}
+ public static void restore(Context context) {
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ final CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ if (cmHardwareManager.isSupported(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
+ final boolean enabled = prefs.getBoolean(KEY_HIGH_TOUCH_SENSITIVITY,
+ cmHardwareManager.get(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY));
+ if (!cmHardwareManager.set(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
+ enabled)) {
+ Log.e(TAG, "Failed to restore high touch sensitivity settings.");
+ } else {
+ Log.d(TAG, "High touch sensitivity settings restored.");
+ }
+ }
+ if (cmHardwareManager.isSupported(CmHardwareManager.FEATURE_TOUCH_HOVERING)) {
+ final boolean enabled = prefs.getBoolean(KEY_TOUCHSCREEN_HOVERING,
+ cmHardwareManager.get(CmHardwareManager.FEATURE_TOUCH_HOVERING));
+ if (!cmHardwareManager.set(CmHardwareManager.FEATURE_TOUCH_HOVERING, enabled)) {
+ Log.e(TAG, "Failed to restore touch hovering settings.");
+ } else {
+ Log.d(TAG, "Touch hovering settings restored.");
+ }
+ }
+ }
+
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/livedisplay/DisplayGamma.java b/src/com/android/settings/livedisplay/DisplayGamma.java
index 38a187b..c9e5697 100644
--- a/src/com/android/settings/livedisplay/DisplayGamma.java
+++ b/src/com/android/settings/livedisplay/DisplayGamma.java
@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
+import android.hardware.CmHardwareManager;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -37,7 +38,8 @@ import android.widget.SeekBar;
import android.widget.TextView;
import com.android.settings.R;
-import org.cyanogenmod.hardware.DisplayGammaCalibration;
+
+import java.util.Arrays;
/**
* Special preference type that allows configuration of Gamma settings
@@ -53,22 +55,24 @@ public class DisplayGamma extends DialogPreference {
private GammaSeekBar[][] mSeekBars;
- private String[][] mCurrentColors;
- private String[] mOriginalColors;
+ private int[][] mCurrentColors;
+ private int[][] mOriginalColors;
private int mNumberOfControls;
+ private CmHardwareManager mCmHardwareManager;
public DisplayGamma(Context context, AttributeSet attrs) {
super(context, attrs);
- if (!isSupported()) {
+ mCmHardwareManager = (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
return;
}
- mNumberOfControls = DisplayGammaCalibration.getNumberOfControls();
+ mNumberOfControls = mCmHardwareManager.getNumGammaControls();
mSeekBars = new GammaSeekBar[mNumberOfControls][BAR_COLORS.length];
- mOriginalColors = new String[mNumberOfControls];
- mCurrentColors = new String[mNumberOfControls][];
+ mOriginalColors = new int[mNumberOfControls][];
+ mCurrentColors = new int[mNumberOfControls][];
setDialogLayoutResource(R.layout.display_gamma_calibration);
}
@@ -96,12 +100,15 @@ public class DisplayGamma extends DialogPreference {
// Create multiple sets of seekbars, depending on the
// number of controls the device has
for (int index = 0; index < mNumberOfControls; index++) {
- mOriginalColors[index] = DisplayGammaCalibration.getCurGamma(index);
- mCurrentColors[index] = mOriginalColors[index].split(" ");
+ mOriginalColors[index] = mCmHardwareManager.getDisplayGammaCalibration(index);
+ mCurrentColors[index] = Arrays.copyOf(mOriginalColors[index],
+ mOriginalColors[index].length);
final String defaultKey = "display_gamma_default_" + index;
if (!prefs.contains(defaultKey)) {
- prefs.edit().putString(defaultKey, mOriginalColors[index]).commit();
+ prefs.edit()
+ .putString(defaultKey, buildPreferenceValue(mOriginalColors[index]))
+ .apply();
}
if (mNumberOfControls != 1) {
@@ -117,12 +124,14 @@ public class DisplayGamma extends DialogPreference {
container.addView(header);
}
+ int min = mCmHardwareManager.getDisplayGammaCalibrationMin();
+ int max = mCmHardwareManager.getDisplayGammaCalibrationMax();
for (int color = 0; color < BAR_COLORS.length; color++) {
ViewGroup item = (ViewGroup) inflater.inflate(
R.layout.display_gamma_calibration_item, container, false);
- mSeekBars[index][color] = new GammaSeekBar(index, color, item);
- mSeekBars[index][color].setGamma(Integer.valueOf(mCurrentColors[index][color]));
+ mSeekBars[index][color] = new GammaSeekBar(index, color, item, min, max);
+ mSeekBars[index][color].setGamma(mCurrentColors[index][color]);
// make sure to add the seekbar group to the container _after_
// creating GammaSeekBar, so that GammaSeekBar has a chance to
// get the correct subviews without getting confused by duplicate IDs
@@ -147,14 +156,15 @@ public class DisplayGamma extends DialogPreference {
final String defaultKey = "display_gamma_default_" + index;
// this key is guaranteed to be present, as we have
// created it in onBindDialogView()
- final String[] defaultColors = prefs.getString(defaultKey, null).split(" ");
+ final String value = prefs.getString(defaultKey, null);
+ final String[] defaultColors = value.split(" ");
for (int color = 0; color < BAR_COLORS.length; color++) {
- mSeekBars[index][color].setGamma(Integer.valueOf(defaultColors[color]));
- mCurrentColors[index][color] = defaultColors[color];
+ int val = Integer.valueOf(defaultColors[color]);
+ mSeekBars[index][color].setGamma(val);
+ mCurrentColors[index][color] = val;
}
- DisplayGammaCalibration.setGamma(index,
- TextUtils.join(" ", mCurrentColors[index]));
+ mCmHardwareManager.setDisplayGammaCalibration(index, mCurrentColors[index]);
}
}
});
@@ -167,12 +177,13 @@ public class DisplayGamma extends DialogPreference {
if (positiveResult) {
Editor editor = getEditor();
for (int i = 0; i < mNumberOfControls; i++) {
- editor.putString("display_gamma_" + i, DisplayGammaCalibration.getCurGamma(i));
+ editor.putString("display_gamma_" + i,
+ buildPreferenceValue(mCmHardwareManager.getDisplayGammaCalibration(i)));
}
- editor.commit();
+ editor.apply();
} else if (mOriginalColors != null) {
for (int i = 0; i < mNumberOfControls; i++) {
- DisplayGammaCalibration.setGamma(i, mOriginalColors[i]);
+ mCmHardwareManager.setDisplayGammaCalibration(i, mOriginalColors[i]);
}
}
}
@@ -192,7 +203,7 @@ public class DisplayGamma extends DialogPreference {
// Restore the old state when the activity or dialog is being paused
for (int i = 0; i < mNumberOfControls; i++) {
- DisplayGammaCalibration.setGamma(i, mOriginalColors[i]);
+ mCmHardwareManager.setDisplayGammaCalibration(i, mOriginalColors[i]);
}
mOriginalColors = null;
@@ -215,39 +226,48 @@ public class DisplayGamma extends DialogPreference {
for (int index = 0; index < mNumberOfControls; index++) {
for (int color = 0; color < BAR_COLORS.length; color++) {
- mSeekBars[index][color].setGamma(Integer.valueOf(mCurrentColors[index][color]));
+ mSeekBars[index][color].setGamma(mCurrentColors[index][color]);
}
- DisplayGammaCalibration.setGamma(index, TextUtils.join(" ", mCurrentColors[index]));
+ mCmHardwareManager.setDisplayGammaCalibration(index, mCurrentColors[index]);
}
}
- public static boolean isSupported() {
- try {
- return DisplayGammaCalibration.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework isn't installed
- return false;
+ private String buildPreferenceValue(int[] colorValues) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < colorValues.length; i++) {
+ if (i != 0) {
+ builder.append(" ");
+ }
+ builder.append(colorValues[i]);
}
+ return builder.toString();
}
public static void restore(Context context) {
- if (!isSupported()) {
+ final CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+ if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
return;
}
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- for (int i = 0; i < DisplayGammaCalibration.getNumberOfControls(); i++) {
- final String values = prefs.getString("display_gamma_" + i, null);
- if (values != null) {
- DisplayGammaCalibration.setGamma(i, values);
+ int[] rgb = new int[3];
+ for (int i = 0; i < cmHardwareManager.getNumGammaControls(); i++) {
+ final String value = prefs.getString("display_gamma_" + i, null);
+ if (value != null) {
+ final String[] values = value.split(" ");
+ rgb[0] = Integer.valueOf(values[0]);
+ rgb[1] = Integer.valueOf(values[1]);
+ rgb[2] = Integer.valueOf(values[2]);
+ cmHardwareManager.setDisplayGammaCalibration(i, rgb);
}
}
}
private static class SavedState extends BaseSavedState {
int controlCount;
- String[] originalColors;
- String[][] currentColors;
+ int[][] originalColors;
+ int[][] currentColors;
public SavedState(Parcelable superState) {
super(superState);
@@ -256,10 +276,13 @@ public class DisplayGamma extends DialogPreference {
public SavedState(Parcel source) {
super(source);
controlCount = source.readInt();
- originalColors = source.createStringArray();
- currentColors = new String[controlCount][];
+ originalColors = new int[controlCount][];
+ currentColors = new int[controlCount][];
+ for (int i = 0; i < controlCount; i++) {
+ originalColors[i] = source.createIntArray();
+ }
for (int i = 0; i < controlCount; i++) {
- currentColors[i] = source.createStringArray();
+ currentColors[i] = source.createIntArray();
}
}
@@ -267,9 +290,11 @@ public class DisplayGamma extends DialogPreference {
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(controlCount);
- dest.writeStringArray(originalColors);
for (int i = 0; i < controlCount; i++) {
- dest.writeStringArray(currentColors[i]);
+ dest.writeIntArray(originalColors[i]);
+ }
+ for (int i = 0; i < controlCount; i++) {
+ dest.writeIntArray(currentColors[i]);
}
}
@@ -291,14 +316,17 @@ public class DisplayGamma extends DialogPreference {
private int mColorIndex;
private int mOriginal;
private int mMin;
+ private int mMax;
private SeekBar mSeekBar;
private TextView mValue;
- public GammaSeekBar(int controlIndex, int colorIndex, ViewGroup container) {
+ public GammaSeekBar(int controlIndex, int colorIndex, ViewGroup container,
+ int min, int max) {
mControlIndex = controlIndex;
mColorIndex = colorIndex;
- mMin = DisplayGammaCalibration.getMinValue(controlIndex);
+ mMin = min;
+ mMax = max;
mValue = (TextView) container.findViewById(R.id.color_value);
mSeekBar = (SeekBar) container.findViewById(R.id.color_seekbar);
@@ -306,7 +334,7 @@ public class DisplayGamma extends DialogPreference {
TextView label = (TextView) container.findViewById(R.id.color_text);
label.setText(container.getContext().getString(BAR_COLORS[colorIndex]));
- mSeekBar.setMax(DisplayGammaCalibration.getMaxValue(controlIndex) - mMin);
+ mSeekBar.setMax(mMax - mMin);
mSeekBar.setProgress(0);
mValue.setText(String.valueOf(mSeekBar.getProgress() + mMin));
@@ -321,9 +349,9 @@ public class DisplayGamma extends DialogPreference {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
- mCurrentColors[mControlIndex][mColorIndex] = String.valueOf(progress + mMin);
- DisplayGammaCalibration.setGamma(mControlIndex,
- TextUtils.join(" ", mCurrentColors[mControlIndex]));
+ mCurrentColors[mControlIndex][mColorIndex] = progress + mMin;
+ mCmHardwareManager.setDisplayGammaCalibration(mControlIndex,
+ mCurrentColors[mControlIndex]);
}
mValue.setText(String.valueOf(progress + mMin));
}
diff --git a/src/com/android/settings/livedisplay/LiveDisplay.java b/src/com/android/settings/livedisplay/LiveDisplay.java
index 07283a6..8a9e9a0 100644
--- a/src/com/android/settings/livedisplay/LiveDisplay.java
+++ b/src/com/android/settings/livedisplay/LiveDisplay.java
@@ -16,10 +16,12 @@
package com.android.settings.livedisplay;
import android.app.Activity;
+import android.database.ContentObserver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.database.ContentObserver;
+import android.hardware.CmHardwareManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -33,6 +35,11 @@ import android.preference.SwitchPreference;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
+import static android.hardware.CmHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT;
+import static android.hardware.CmHardwareManager.FEATURE_COLOR_ENHANCEMENT;
+import static android.hardware.CmHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION;
+import static android.hardware.CmHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT;
+
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
@@ -40,10 +47,6 @@ import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
-import org.cyanogenmod.hardware.AdaptiveBacklight;
-import org.cyanogenmod.hardware.ColorEnhancement;
-import org.cyanogenmod.hardware.SunlightEnhancement;
-
import java.util.ArrayList;
import java.util.List;
@@ -90,6 +93,8 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
private int mDefaultDayTemperature;
private int mDefaultNightTemperature;
+ private CmHardwareManager mCmHardwareManager;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -102,6 +107,8 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
mDefaultNightTemperature = res.getInteger(
com.android.internal.R.integer.config_nightColorTemperature);
+ mCmHardwareManager = (CmHardwareManager) activity.getSystemService(Context.CMHW_SERVICE);
+
addPreferencesFromResource(R.xml.livedisplay);
PreferenceCategory liveDisplayPrefs = (PreferenceCategory)
@@ -123,7 +130,7 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
com.android.internal.R.array.live_display_summaries);
// Remove outdoor mode from lists if there is no support
- if (!SunlightEnhancement.isSupported()) {
+ if (!mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
int idx = ArrayUtils.indexOf(mModeValues, String.valueOf(MODE_OUTDOOR));
String[] entriesTemp = new String[mModeEntries.length - 1];
String[] valuesTemp = new String[mModeValues.length - 1];
@@ -151,26 +158,27 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
mLowPower = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_LOW_POWER);
if (liveDisplayPrefs != null && mLowPower != null
- && !isAdaptiveBacklightSupported()) {
+ && !mCmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) {
liveDisplayPrefs.removePreference(mLowPower);
mLowPower = null;
}
mOutdoorMode = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE);
if (liveDisplayPrefs != null && mOutdoorMode != null
- && !isSunlightEnhancementSupported()) {
+ && !mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
liveDisplayPrefs.removePreference(mOutdoorMode);
mOutdoorMode = null;
}
mColorEnhancement = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
if (liveDisplayPrefs != null && mColorEnhancement != null
- && !isColorEnhancementSupported()) {
+ && !mCmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) {
liveDisplayPrefs.removePreference(mColorEnhancement);
mColorEnhancement = null;
}
- if (calibrationPrefs != null && !DisplayGamma.isSupported()) {
+ if (calibrationPrefs != null
+ && !mCmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
Preference gammaPref = findPreference(KEY_DISPLAY_GAMMA);
if (gammaPref != null) {
calibrationPrefs.removePreference(gammaPref);
@@ -238,33 +246,6 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
return true;
}
- private static boolean isAdaptiveBacklightSupported() {
- try {
- return AdaptiveBacklight.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
- private static boolean isSunlightEnhancementSupported() {
- try {
- return SunlightEnhancement.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
- private static boolean isColorEnhancementSupported() {
- try {
- return ColorEnhancement.isSupported();
- } catch (NoClassDefFoundError e) {
- // Hardware abstraction framework not installed
- return false;
- }
- }
-
private static boolean isPostProcessingSupported(Context context) {
return Utils.isPackageInstalled(context, "com.qualcomm.display");
}
@@ -306,14 +287,6 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
private boolean mHasDisplayGamma;
@Override
- public void prepare() {
- mHasSunlightEnhancement = isSunlightEnhancementSupported();
- mHasColorEnhancement = isColorEnhancementSupported();
- mHasLowPower = isAdaptiveBacklightSupported();
- mHasDisplayGamma = DisplayGamma.isSupported();
- }
-
- @Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
ArrayList<SearchIndexableResource> result =
@@ -328,20 +301,25 @@ public class LiveDisplay extends SettingsPreferenceFragment implements
@Override
public List<String> getNonIndexableKeys(Context context) {
+ CmHardwareManager cmHardwareManager =
+ (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
+
ArrayList<String> result = new ArrayList<String>();
- if (!mHasSunlightEnhancement) {
+ if (!cmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) {
result.add(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE);
}
- if (!mHasColorEnhancement) {
+ if (!cmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) {
result.add(KEY_LIVE_DISPLAY_COLOR_ENHANCE);
}
- if (!mHasLowPower) {
+ if (!cmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) {
result.add(KEY_LIVE_DISPLAY_LOW_POWER);
}
if (!isPostProcessingSupported(context)) {
result.add(KEY_SCREEN_COLOR_SETTINGS);
+ } else {
+ result.add(KEY_DISPLAY_COLOR);
}
- if (!mHasDisplayGamma) {
+ if (!cmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) {
result.add(KEY_DISPLAY_GAMMA);
}
return result;