diff options
author | Brian Attwell <brianattwell@google.com> | 2014-12-18 19:08:34 -0800 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2015-01-05 12:11:08 -0800 |
commit | fb45b007d84a02b4889b614a1660c97bd5b4ee63 (patch) | |
tree | f97d2bba69025ce690378eca9f553e4617f978f0 /src | |
parent | 9f214f1b88036e307391f98df7927b7d181c25a1 (diff) |
Unbundle PhoneCommon 2/2
Move getVibrateWhenRingingSetting() to the only place it is
used, inside Dialer. This way we don't need to unhide the
Settings.VIBRATE_WHEN_RINGING.
Bug: 18777272
Change-Id: I18d1d6e19b0efa1f56985e63d917c398c957f5ab
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/settings/GeneralSettingsFragment.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/com/android/dialer/settings/GeneralSettingsFragment.java b/src/com/android/dialer/settings/GeneralSettingsFragment.java index 578ff3389..cad55e90a 100644 --- a/src/com/android/dialer/settings/GeneralSettingsFragment.java +++ b/src/com/android/dialer/settings/GeneralSettingsFragment.java @@ -150,10 +150,25 @@ public class GeneralSettingsFragment extends PreferenceFragment super.onResume(); if (mVibrateWhenRinging != null) { - mVibrateWhenRinging.setChecked(SettingsUtil.getVibrateWhenRingingSetting(mContext)); + mVibrateWhenRinging.setChecked(getVibrateWhenRingingSetting(mContext)); } // Lookup the ringtone name asynchronously. new Thread(mRingtoneLookupRunnable).start(); } + + /** + * Obtain the setting for "vibrate when ringing" setting. + * + * Watch out: if the setting is missing in the device, this will try obtaining the old + * "vibrate on ring" setting from AudioManager, and save the previous setting to the new one. + */ + public static boolean getVibrateWhenRingingSetting(Context context) { + Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + if (vibrator == null || !vibrator.hasVibrator()) { + return false; + } + return Settings.System.getInt(context.getContentResolver(), + Settings.System.VIBRATE_WHEN_RINGING, 0) != 0; + } } |