diff options
Diffstat (limited to 'src/com/android')
9 files changed, 125 insertions, 127 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index 0c09601..45973e2 100644 --- a/src/com/android/settings/ButtonSettings.java +++ b/src/com/android/settings/ButtonSettings.java @@ -25,7 +25,6 @@ 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; @@ -53,6 +52,8 @@ import org.cyanogenmod.hardware.KeyDisabler; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; +import cyanogenmod.hardware.CMHardwareManager; + import java.util.List; public class ButtonSettings extends SettingsPreferenceFragment implements @@ -207,13 +208,12 @@ public class ButtonSettings extends SettingsPreferenceFragment implements mNavigationRecentsLongPressAction = initRecentsLongPressAction(KEY_NAVIGATION_RECENTS_LONG_PRESS); - final CmHardwareManager cmHardwareManager = - (CmHardwareManager) getActivity().getSystemService(Context.CMHW_SERVICE); + final CMHardwareManager hardware = CMHardwareManager.getInstance(getActivity()); // 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 (cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE)) { + if (hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE)) { try { IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); needsNavigationBar = wm.needsNavigationBar(); @@ -389,9 +389,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements } if (!hasNavBar && (needsNavigationBar || - !cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE))) { - // Hide navigation bar category - prefScreen.removePreference(mNavigationPreferencesCat); + !hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE))) { + // Hide navigation bar category + prefScreen.removePreference(mNavigationPreferencesCat); } } catch (RemoteException e) { Log.e(TAG, "Error getting navigation bar status"); @@ -610,9 +610,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements 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); + CMHardwareManager hardware = CMHardwareManager.getInstance(context); + hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled); /* Save/restore button timeouts to disable them in softkey mode */ if (enabled) { @@ -676,9 +675,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements } public static void restoreKeyDisabler(Context context) { - CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); - if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE)) { + CMHardwareManager hardware = CMHardwareManager.getInstance(context); + if (!hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE)) { return; } diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index d601c20..68bf1c2 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -25,13 +25,13 @@ 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; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_TAP_TO_WAKE; import android.app.Activity; import android.app.ActivityManagerNative; @@ -45,7 +45,6 @@ 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; @@ -72,6 +71,8 @@ import java.util.List; import com.android.settings.Utils; import com.android.settings.cyanogenmod.DisplayRotation; +import cyanogenmod.hardware.CMHardwareManager; + public class DisplaySettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener, OnPreferenceClickListener, Indexable { private static final String TAG = "DisplaySettings"; @@ -112,7 +113,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private SwitchPreference mTapToWake; private SwitchPreference mWakeWhenPluggedOrUnplugged; - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; private ContentObserver mAccelerometerRotationObserver = new ContentObserver(new Handler()) { @@ -141,7 +142,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); + mHardware = CMHardwareManager.getInstance(activity); mDisplayRotationPreference = (PreferenceScreen) findPreference(KEY_DISPLAY_ROTATION); @@ -209,8 +210,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } mTapToWake = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE); - - if (!mCmHardwareManager.isSupported(FEATURE_TAP_TO_WAKE)) { + if (mTapToWake != null + && !mHardware.isSupported(FEATURE_TAP_TO_WAKE)) { advancedPrefs.removePreference(mTapToWake); mTapToWake = null; } @@ -365,7 +366,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements updateDisplayRotationPreferenceDescription(); if (mTapToWake != null) { - mTapToWake.setChecked(mCmHardwareManager.get(FEATURE_TAP_TO_WAKE)); + mTapToWake.setChecked(mHardware.get(FEATURE_TAP_TO_WAKE)); } RotationPolicy.registerRotationPolicyListener(getActivity(), @@ -479,7 +480,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mTapToWake) { - return mCmHardwareManager.set(FEATURE_TAP_TO_WAKE, mTapToWake.isChecked()); + return mHardware.set(FEATURE_TAP_TO_WAKE, mTapToWake.isChecked()); } else if (preference == mWakeWhenPluggedOrUnplugged) { Settings.Global.putInt(getContentResolver(), Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED, @@ -560,8 +561,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements */ public static void restore(Context ctx) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); - CmHardwareManager cmHardwareManager = - (CmHardwareManager) ctx.getSystemService(Context.CMHW_SERVICE); + CMHardwareManager cmHardwareManager = CMHardwareManager.getInstance(ctx); if (cmHardwareManager.isSupported(FEATURE_TAP_TO_WAKE)) { final boolean enabled = prefs.getBoolean(KEY_TAP_TO_WAKE, cmHardwareManager.get(FEATURE_TAP_TO_WAKE)); @@ -592,8 +592,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements @Override public List<String> getNonIndexableKeys(Context context) { - CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); + CMHardwareManager cmHardwareManager = CMHardwareManager.getInstance(context); ArrayList<String> result = new ArrayList<String>(); if (!context.getResources().getBoolean( com.android.internal.R.bool.config_dreamsSupported)) { diff --git a/src/com/android/settings/cyanogenmod/LtoService.java b/src/com/android/settings/cyanogenmod/LtoService.java index 8bbf8c8..c0b211b 100644 --- a/src/com/android/settings/cyanogenmod/LtoService.java +++ b/src/com/android/settings/cyanogenmod/LtoService.java @@ -16,7 +16,7 @@ package com.android.settings.cyanogenmod; -import static android.hardware.CmHardwareManager.FEATURE_LONG_TERM_ORBITS; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_LONG_TERM_ORBITS; import android.app.AlarmManager; import android.app.PendingIntent; @@ -24,7 +24,6 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.hardware.CmHardwareManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; @@ -37,6 +36,8 @@ import android.util.Log; import com.android.settings.location.LocationSettings; +import cyanogenmod.hardware.CMHardwareManager; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; @@ -58,13 +59,13 @@ public class LtoService extends Service { private static final int DOWNLOAD_TIMEOUT = 45000; /* 45 seconds */ - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; private LtoDownloadTask mTask; @Override public int onStartCommand(Intent intent, int flags, int startId) { - if (mCmHardwareManager == null || - !mCmHardwareManager.isSupported(FEATURE_LONG_TERM_ORBITS)) { + if (mHardware == null || + !mHardware.isSupported(FEATURE_LONG_TERM_ORBITS)) { if (ALOGV) Log.v(TAG, "LTO is not supported by this device"); return START_NOT_STICKY; } @@ -84,8 +85,8 @@ public class LtoService extends Service { return START_NOT_STICKY; } - mTask = new LtoDownloadTask(mCmHardwareManager.getLtoSource(), - new File(mCmHardwareManager.getLtoDestination())); + mTask = new LtoDownloadTask(mHardware.getLtoSource(), + new File(mHardware.getLtoDestination())); mTask.execute(); return START_REDELIVER_INTENT; @@ -99,7 +100,7 @@ public class LtoService extends Service { @Override public void onCreate() { super.onCreate(); - mCmHardwareManager = (CmHardwareManager) getSystemService(Context.CMHW_SERVICE); + mHardware = CMHardwareManager.getInstance(this); } @Override @@ -131,7 +132,7 @@ public class LtoService extends Service { long now = System.currentTimeMillis(); long lastDownload = getLastDownload(); - long due = lastDownload + mCmHardwareManager.getLtoDownloadInterval(); + long due = lastDownload + mHardware.getLtoDownloadInterval(); if (ALOGV) { Log.v(TAG, "Now " + now + " due " + due + "(" + new Date(due) + ")"); @@ -325,7 +326,7 @@ public class LtoService extends Service { PendingIntent pi = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); - long nextLtoDownload = lastDownload + mCmHardwareManager.getLtoDownloadInterval(); + long nextLtoDownload = lastDownload + mHardware.getLtoDownloadInterval(); am.set(AlarmManager.RTC, nextLtoDownload, pi); return pi; } diff --git a/src/com/android/settings/hardware/VibratorIntensity.java b/src/com/android/settings/hardware/VibratorIntensity.java index 6c00cde..009f35f 100644 --- a/src/com/android/settings/hardware/VibratorIntensity.java +++ b/src/com/android/settings/hardware/VibratorIntensity.java @@ -25,7 +25,6 @@ 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,6 +36,8 @@ import android.widget.SeekBar; import android.widget.TextView; import android.widget.Button; +import cyanogenmod.hardware.CMHardwareManager; + import com.android.settings.R; public class VibratorIntensity extends DialogPreference implements @@ -50,7 +51,7 @@ public class VibratorIntensity extends DialogPreference implements private int mMaxValue; private int mDefaultValue; private int mWarningValue; - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; private Drawable mProgressDrawable; private Drawable mProgressThumb; @@ -59,9 +60,9 @@ public class VibratorIntensity extends DialogPreference implements public VibratorIntensity(Context context, AttributeSet attrs) { super(context, attrs); - mCmHardwareManager = (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); + mHardware = CMHardwareManager.getInstance(context); - if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_VIBRATOR)) { + if (!mHardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) { return; } @@ -87,11 +88,11 @@ public class VibratorIntensity extends DialogPreference implements mWarning = (TextView) view.findViewById(R.id.warning_text); // 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(); + mOriginalValue = mHardware.getVibratorIntensity(); + mWarningValue = mHardware.getVibratorWarningIntensity(); + mMinValue = mHardware.getVibratorMinIntensity(); + mMaxValue = mHardware.getVibratorMaxIntensity(); + mDefaultValue = mHardware.getVibratorDefaultIntensity(); if (mWarningValue > 0) { String message = getContext().getResources().getString( R.string.vibrator_warning, intensityToPercent(mMinValue, mMaxValue, @@ -144,25 +145,24 @@ public class VibratorIntensity extends DialogPreference implements SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.edit().putInt(PREF_NAME, mSeekBar.getProgress()).commit(); } else { - mCmHardwareManager.setVibratorIntensity(mCmHardwareManager.getVibratorIntensity()); + mHardware.setVibratorIntensity(mHardware.getVibratorIntensity()); } } public static void restore(Context context) { - CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); - if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_VIBRATOR)) { + CMHardwareManager hardware = CMHardwareManager.getInstance(context); + if (!hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) { return; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - int vibrator = cmHardwareManager.getVibratorIntensity(); - int min = cmHardwareManager.getVibratorMinIntensity(); - int max = cmHardwareManager.getVibratorMaxIntensity(); + int vibrator = hardware.getVibratorIntensity(); + int min = hardware.getVibratorMinIntensity(); + int max = hardware.getVibratorMaxIntensity(); int defaultValue = intensityToPercent(min, max, - cmHardwareManager.getVibratorDefaultIntensity()); + hardware.getVibratorDefaultIntensity()); int percent = prefs.getInt(PREF_NAME, defaultValue); - cmHardwareManager.setVibratorIntensity(percentToIntensity(min, max, percent)); + hardware.setVibratorIntensity(percentToIntensity(min, max, percent)); } @Override @@ -178,7 +178,7 @@ public class VibratorIntensity extends DialogPreference implements mProgressThumb.setColorFilter(shouldWarn ? mRedFilter : null); } - mCmHardwareManager.setVibratorIntensity(percentToIntensity(mMinValue, mMaxValue, + mHardware.setVibratorIntensity(percentToIntensity(mMinValue, mMaxValue, progress)); mValue.setText(String.format("%d%%", progress)); } diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java index e1aed8c..7d9547a 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java @@ -27,7 +27,6 @@ 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; @@ -66,6 +65,8 @@ import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableRaw; +import cyanogenmod.hardware.CMHardwareManager; + import java.text.Collator; import java.util.ArrayList; import java.util.Collections; @@ -127,7 +128,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private Intent mIntentWaitingForResult; private InputMethodSettingValuesWrapper mInputMethodSettingValues; private DevicePolicyManager mDpm; - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; @Override protected int getMetricsCategory() { @@ -144,7 +145,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity); - mCmHardwareManager = (CmHardwareManager) getSystemService(Context.CMHW_SERVICE); + mHardware = CMHardwareManager.getInstance(activity); try { mDefaultInputMethodSelectorVisibility = Integer.valueOf( @@ -208,21 +209,21 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment pointerSettingsCategory.removePreference(mStylusIconEnabled); } - if (!mCmHardwareManager.isSupported( - CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) { + if (!mHardware.isSupported( + CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) { pointerSettingsCategory.removePreference(mHighTouchSensitivity); mHighTouchSensitivity = null; } else { mHighTouchSensitivity.setChecked( - mCmHardwareManager.get(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)); + mHardware.get(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)); } - if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_TOUCH_HOVERING)) { + if (!mHardware.isSupported(CMHardwareManager.FEATURE_TOUCH_HOVERING)) { pointerSettingsCategory.removePreference(mTouchscreenHovering); mTouchscreenHovering = null; } else { mTouchscreenHovering.setChecked( - mCmHardwareManager.get(CmHardwareManager.FEATURE_TOUCH_HOVERING)); + mHardware.get(CMHardwareManager.FEATURE_TOUCH_HOVERING)); } Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(), @@ -414,6 +415,12 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment if (preference == mStylusIconEnabled) { Settings.System.putInt(getActivity().getContentResolver(), Settings.System.STYLUS_ICON_ENABLED, mStylusIconEnabled.isChecked() ? 1 : 0); + } else if (preference == mHighTouchSensitivity) { + return mHardware.set(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY, + mHighTouchSensitivity.isChecked()); + } else if (preference == mTouchscreenHovering) { + return mHardware.set(CMHardwareManager.FEATURE_TOUCH_HOVERING, + mTouchscreenHovering.isChecked()); } else if (preference instanceof PreferenceScreen) { if (preference.getFragment() != null) { // Fragment will be handled correctly by the super class. @@ -438,12 +445,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } } - } else if (preference == mHighTouchSensitivity) { - return mCmHardwareManager.set(CmHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY, - mHighTouchSensitivity.isChecked()); - } else if (preference == mTouchscreenHovering) { - return mCmHardwareManager.set(CmHardwareManager.FEATURE_TOUCH_HOVERING, - mTouchscreenHovering.isChecked()); } return super.onPreferenceTreeClick(preferenceScreen, preference); } @@ -759,22 +760,21 @@ 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 CMHardwareManager hardware = CMHardwareManager.getInstance(context); + if (hardware.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, + hardware.get(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)); + if (!hardware.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)) { + if (hardware.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)) { + hardware.get(CMHardwareManager.FEATURE_TOUCH_HOVERING)); + if (!hardware.set(CMHardwareManager.FEATURE_TOUCH_HOVERING, enabled)) { Log.e(TAG, "Failed to restore touch hovering settings."); } else { Log.d(TAG, "Touch hovering settings restored."); diff --git a/src/com/android/settings/livedisplay/DisplayColor.java b/src/com/android/settings/livedisplay/DisplayColor.java index d6b7b37..eb46abc 100644 --- a/src/com/android/settings/livedisplay/DisplayColor.java +++ b/src/com/android/settings/livedisplay/DisplayColor.java @@ -16,10 +16,11 @@ package com.android.settings.livedisplay; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION; + import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.hardware.CmHardwareManager; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -35,7 +36,7 @@ import android.widget.TextView; import com.android.settings.IntervalSeekBar; import com.android.settings.R; -import static android.hardware.CmHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION; +import cyanogenmod.hardware.CMHardwareManager; /** * Special preference type that allows configuration of Color settings @@ -73,13 +74,12 @@ public class DisplayColor extends DialogPreference { mContext = context; - final CmHardwareManager mCmHardwareManager = - (CmHardwareManager) mContext.getSystemService(Context.CMHW_SERVICE); - useCMHW = mCmHardwareManager.isSupported(FEATURE_DISPLAY_COLOR_CALIBRATION); + final CMHardwareManager mHardware = CMHardwareManager.getInstance(context); + useCMHW = mHardware.isSupported(FEATURE_DISPLAY_COLOR_CALIBRATION); if (useCMHW) { - minRGB = mCmHardwareManager.getDisplayColorCalibrationMin(); - maxRGB = mCmHardwareManager.getDisplayColorCalibrationMax(); - defaultRGB = (float) mCmHardwareManager.getDisplayColorCalibrationDefault() / maxRGB; + minRGB = mHardware.getDisplayColorCalibrationMin(); + maxRGB = mHardware.getDisplayColorCalibrationMax(); + defaultRGB = (float) mHardware.getDisplayColorCalibrationDefault() / maxRGB; } else { // Initialize these just to avoid compiler errors. minRGB = 20; diff --git a/src/com/android/settings/livedisplay/DisplayGamma.java b/src/com/android/settings/livedisplay/DisplayGamma.java index c9e5697..e75e3a4 100644 --- a/src/com/android/settings/livedisplay/DisplayGamma.java +++ b/src/com/android/settings/livedisplay/DisplayGamma.java @@ -22,7 +22,6 @@ 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; @@ -39,6 +38,8 @@ import android.widget.TextView; import com.android.settings.R; +import cyanogenmod.hardware.CMHardwareManager; + import java.util.Arrays; /** @@ -58,17 +59,17 @@ public class DisplayGamma extends DialogPreference { private int[][] mCurrentColors; private int[][] mOriginalColors; private int mNumberOfControls; - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; public DisplayGamma(Context context, AttributeSet attrs) { super(context, attrs); - mCmHardwareManager = (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); - if (!mCmHardwareManager.isSupported(CmHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) { + mHardware = CMHardwareManager.getInstance(context); + if (!mHardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) { return; } - mNumberOfControls = mCmHardwareManager.getNumGammaControls(); + mNumberOfControls = mHardware.getNumGammaControls(); mSeekBars = new GammaSeekBar[mNumberOfControls][BAR_COLORS.length]; mOriginalColors = new int[mNumberOfControls][]; @@ -100,7 +101,7 @@ 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] = mCmHardwareManager.getDisplayGammaCalibration(index); + mOriginalColors[index] = mHardware.getDisplayGammaCalibration(index); mCurrentColors[index] = Arrays.copyOf(mOriginalColors[index], mOriginalColors[index].length); @@ -124,8 +125,8 @@ public class DisplayGamma extends DialogPreference { container.addView(header); } - int min = mCmHardwareManager.getDisplayGammaCalibrationMin(); - int max = mCmHardwareManager.getDisplayGammaCalibrationMax(); + int min = mHardware.getDisplayGammaCalibrationMin(); + int max = mHardware.getDisplayGammaCalibrationMax(); for (int color = 0; color < BAR_COLORS.length; color++) { ViewGroup item = (ViewGroup) inflater.inflate( R.layout.display_gamma_calibration_item, container, false); @@ -164,7 +165,7 @@ public class DisplayGamma extends DialogPreference { mSeekBars[index][color].setGamma(val); mCurrentColors[index][color] = val; } - mCmHardwareManager.setDisplayGammaCalibration(index, mCurrentColors[index]); + mHardware.setDisplayGammaCalibration(index, mCurrentColors[index]); } } }); @@ -178,12 +179,12 @@ public class DisplayGamma extends DialogPreference { Editor editor = getEditor(); for (int i = 0; i < mNumberOfControls; i++) { editor.putString("display_gamma_" + i, - buildPreferenceValue(mCmHardwareManager.getDisplayGammaCalibration(i))); + buildPreferenceValue(mHardware.getDisplayGammaCalibration(i))); } editor.apply(); } else if (mOriginalColors != null) { for (int i = 0; i < mNumberOfControls; i++) { - mCmHardwareManager.setDisplayGammaCalibration(i, mOriginalColors[i]); + mHardware.setDisplayGammaCalibration(i, mOriginalColors[i]); } } } @@ -203,7 +204,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++) { - mCmHardwareManager.setDisplayGammaCalibration(i, mOriginalColors[i]); + mHardware.setDisplayGammaCalibration(i, mOriginalColors[i]); } mOriginalColors = null; @@ -228,7 +229,7 @@ public class DisplayGamma extends DialogPreference { for (int color = 0; color < BAR_COLORS.length; color++) { mSeekBars[index][color].setGamma(mCurrentColors[index][color]); } - mCmHardwareManager.setDisplayGammaCalibration(index, mCurrentColors[index]); + mHardware.setDisplayGammaCalibration(index, mCurrentColors[index]); } } @@ -244,22 +245,21 @@ public class DisplayGamma extends DialogPreference { } public static void restore(Context context) { - final CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); - if (!cmHardwareManager.isSupported(CmHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) { + final CMHardwareManager hardware = CMHardwareManager.getInstance(context); + if (!hardware.isSupported(CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION)) { return; } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int[] rgb = new int[3]; - for (int i = 0; i < cmHardwareManager.getNumGammaControls(); i++) { + for (int i = 0; i < hardware.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); + hardware.setDisplayGammaCalibration(i, rgb); } } } @@ -350,7 +350,7 @@ public class DisplayGamma extends DialogPreference { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { mCurrentColors[mControlIndex][mColorIndex] = progress + mMin; - mCmHardwareManager.setDisplayGammaCalibration(mControlIndex, + mHardware.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 8a9e9a0..dd20f0e 100644 --- a/src/com/android/settings/livedisplay/LiveDisplay.java +++ b/src/com/android/settings/livedisplay/LiveDisplay.java @@ -15,13 +15,17 @@ */ package com.android.settings.livedisplay; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_COLOR_ENHANCEMENT; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT; + 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; @@ -35,11 +39,6 @@ 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; @@ -47,6 +46,8 @@ import com.android.settings.Utils; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; +import cyanogenmod.hardware.CMHardwareManager; + import java.util.ArrayList; import java.util.List; @@ -93,7 +94,7 @@ public class LiveDisplay extends SettingsPreferenceFragment implements private int mDefaultDayTemperature; private int mDefaultNightTemperature; - private CmHardwareManager mCmHardwareManager; + private CMHardwareManager mHardware; @Override public void onCreate(Bundle savedInstanceState) { @@ -107,7 +108,7 @@ public class LiveDisplay extends SettingsPreferenceFragment implements mDefaultNightTemperature = res.getInteger( com.android.internal.R.integer.config_nightColorTemperature); - mCmHardwareManager = (CmHardwareManager) activity.getSystemService(Context.CMHW_SERVICE); + mHardware = CMHardwareManager.getInstance(activity); addPreferencesFromResource(R.xml.livedisplay); @@ -130,7 +131,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 (!mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) { + if (!mHardware.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]; @@ -158,27 +159,27 @@ public class LiveDisplay extends SettingsPreferenceFragment implements mLowPower = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_LOW_POWER); if (liveDisplayPrefs != null && mLowPower != null - && !mCmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) { + && !mHardware.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) { liveDisplayPrefs.removePreference(mLowPower); mLowPower = null; } mOutdoorMode = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE); if (liveDisplayPrefs != null && mOutdoorMode != null - && !mCmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) { + && !mHardware.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) { liveDisplayPrefs.removePreference(mOutdoorMode); mOutdoorMode = null; } mColorEnhancement = (SwitchPreference) findPreference(KEY_LIVE_DISPLAY_COLOR_ENHANCE); if (liveDisplayPrefs != null && mColorEnhancement != null - && !mCmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) { + && !mHardware.isSupported(FEATURE_COLOR_ENHANCEMENT)) { liveDisplayPrefs.removePreference(mColorEnhancement); mColorEnhancement = null; } if (calibrationPrefs != null - && !mCmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) { + && !mHardware.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) { Preference gammaPref = findPreference(KEY_DISPLAY_GAMMA); if (gammaPref != null) { calibrationPrefs.removePreference(gammaPref); @@ -301,17 +302,16 @@ public class LiveDisplay extends SettingsPreferenceFragment implements @Override public List<String> getNonIndexableKeys(Context context) { - CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); + CMHardwareManager hardware = CMHardwareManager.getInstance(context); ArrayList<String> result = new ArrayList<String>(); - if (!cmHardwareManager.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) { + if (!hardware.isSupported(FEATURE_SUNLIGHT_ENHANCEMENT)) { result.add(KEY_LIVE_DISPLAY_AUTO_OUTDOOR_MODE); } - if (!cmHardwareManager.isSupported(FEATURE_COLOR_ENHANCEMENT)) { + if (!hardware.isSupported(FEATURE_COLOR_ENHANCEMENT)) { result.add(KEY_LIVE_DISPLAY_COLOR_ENHANCE); } - if (!cmHardwareManager.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) { + if (!hardware.isSupported(FEATURE_ADAPTIVE_BACKLIGHT)) { result.add(KEY_LIVE_DISPLAY_LOW_POWER); } if (!isPostProcessingSupported(context)) { @@ -319,7 +319,7 @@ public class LiveDisplay extends SettingsPreferenceFragment implements } else { result.add(KEY_DISPLAY_COLOR); } - if (!cmHardwareManager.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) { + if (!hardware.isSupported(FEATURE_DISPLAY_GAMMA_CALIBRATION)) { result.add(KEY_DISPLAY_GAMMA); } return result; diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java index d3f0ac8..f4a1c9b 100644 --- a/src/com/android/settings/location/LocationSettings.java +++ b/src/com/android/settings/location/LocationSettings.java @@ -17,7 +17,7 @@ package com.android.settings.location; -import static android.hardware.CmHardwareManager.FEATURE_LONG_TERM_ORBITS; +import static cyanogenmod.hardware.CMHardwareManager.FEATURE_LONG_TERM_ORBITS; import android.app.AlarmManager; import android.app.PendingIntent; @@ -27,7 +27,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; -import android.hardware.CmHardwareManager; import android.location.SettingInjectorService; import android.os.Bundle; import android.os.UserHandle; @@ -51,6 +50,8 @@ import com.android.settings.Utils; import com.android.settings.cyanogenmod.LtoService; import com.android.settings.widget.SwitchBar; +import cyanogenmod.hardware.CMHardwareManager; + import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -467,8 +468,7 @@ public class LocationSettings extends LocationSettingsBase } private static boolean isLtoSupported(Context context) { - final CmHardwareManager hwManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); - return hwManager != null && hwManager.isSupported(FEATURE_LONG_TERM_ORBITS); + final CMHardwareManager hardware = CMHardwareManager.getInstance(context); + return hardware != null && hardware.isSupported(FEATURE_LONG_TERM_ORBITS); } } |