Split ring and notification vibration settings
Synchronize settings between sound and accessibility menus Bug: 116172311 Test: See accessibility vibration settings - ring and notification settings sould be separate. Try changing vibration settings in sound and accessibility menus - the settings should stay in sync. Change-Id: Ia0276dfdd0efafe211c14cda140831b57f8c42b1
This commit is contained in:
@@ -74,10 +74,13 @@ public abstract class Vibrator {
|
||||
private final String mPackageName;
|
||||
// The default vibration intensity level for haptic feedback.
|
||||
@VibrationIntensity
|
||||
private final int mDefaultHapticFeedbackIntensity;
|
||||
private int mDefaultHapticFeedbackIntensity;
|
||||
// The default vibration intensity level for notifications.
|
||||
@VibrationIntensity
|
||||
private final int mDefaultNotificationVibrationIntensity;
|
||||
private int mDefaultNotificationVibrationIntensity;
|
||||
// The default vibration intensity level for ringtones.
|
||||
@VibrationIntensity
|
||||
private int mDefaultRingVibrationIntensity;
|
||||
|
||||
/**
|
||||
* @hide to prevent subclassing from outside of the framework
|
||||
@@ -85,10 +88,7 @@ public abstract class Vibrator {
|
||||
public Vibrator() {
|
||||
mPackageName = ActivityThread.currentPackageName();
|
||||
final Context ctx = ActivityThread.currentActivityThread().getSystemContext();
|
||||
mDefaultHapticFeedbackIntensity = loadDefaultIntensity(ctx,
|
||||
com.android.internal.R.integer.config_defaultHapticFeedbackIntensity);
|
||||
mDefaultNotificationVibrationIntensity = loadDefaultIntensity(ctx,
|
||||
com.android.internal.R.integer.config_defaultNotificationVibrationIntensity);
|
||||
loadVibrationIntensities(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,10 +96,16 @@ public abstract class Vibrator {
|
||||
*/
|
||||
protected Vibrator(Context context) {
|
||||
mPackageName = context.getOpPackageName();
|
||||
loadVibrationIntensities(context);
|
||||
}
|
||||
|
||||
private void loadVibrationIntensities(Context context) {
|
||||
mDefaultHapticFeedbackIntensity = loadDefaultIntensity(context,
|
||||
com.android.internal.R.integer.config_defaultHapticFeedbackIntensity);
|
||||
mDefaultNotificationVibrationIntensity = loadDefaultIntensity(context,
|
||||
com.android.internal.R.integer.config_defaultNotificationVibrationIntensity);
|
||||
mDefaultRingVibrationIntensity = loadDefaultIntensity(context,
|
||||
com.android.internal.R.integer.config_defaultRingVibrationIntensity);
|
||||
}
|
||||
|
||||
private int loadDefaultIntensity(Context ctx, int resId) {
|
||||
@@ -115,13 +121,20 @@ public abstract class Vibrator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default vibration intensity for notifications and ringtones.
|
||||
* Get the default vibration intensity for notifications.
|
||||
* @hide
|
||||
*/
|
||||
public int getDefaultNotificationVibrationIntensity() {
|
||||
return mDefaultNotificationVibrationIntensity;
|
||||
}
|
||||
|
||||
/** Get the default vibration intensity for ringtones.
|
||||
* @hide
|
||||
*/
|
||||
public int getDefaultRingVibrationIntensity() {
|
||||
return mDefaultRingVibrationIntensity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the hardware has a vibrator.
|
||||
*
|
||||
|
||||
@@ -3377,6 +3377,22 @@ public final class Settings {
|
||||
*/
|
||||
public static final String NOTIFICATION_VIBRATION_INTENSITY =
|
||||
"notification_vibration_intensity";
|
||||
/**
|
||||
* The intensity of ringtone vibrations, if configurable.
|
||||
*
|
||||
* Not all devices are capable of changing their vibration intensity; on these devices
|
||||
* there will likely be no difference between the various vibration intensities except for
|
||||
* intensity 0 (off) and the rest.
|
||||
*
|
||||
* <b>Values:</b><br/>
|
||||
* 0 - Vibration is disabled<br/>
|
||||
* 1 - Weak vibrations<br/>
|
||||
* 2 - Medium vibrations<br/>
|
||||
* 3 - Strong vibrations
|
||||
* @hide
|
||||
*/
|
||||
public static final String RING_VIBRATION_INTENSITY =
|
||||
"ring_vibration_intensity";
|
||||
|
||||
/**
|
||||
* The intensity of haptic feedback vibrations, if configurable.
|
||||
@@ -4246,6 +4262,7 @@ public final class Settings {
|
||||
ACCELEROMETER_ROTATION,
|
||||
SHOW_BATTERY_PERCENT,
|
||||
NOTIFICATION_VIBRATION_INTENSITY,
|
||||
RING_VIBRATION_INTENSITY,
|
||||
HAPTIC_FEEDBACK_INTENSITY,
|
||||
DISPLAY_COLOR_MODE,
|
||||
ALARM_ALERT,
|
||||
@@ -4397,6 +4414,7 @@ public final class Settings {
|
||||
VALIDATORS.put(MUTE_STREAMS_AFFECTED, MUTE_STREAMS_AFFECTED_VALIDATOR);
|
||||
VALIDATORS.put(VIBRATE_ON, VIBRATE_ON_VALIDATOR);
|
||||
VALIDATORS.put(NOTIFICATION_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
|
||||
VALIDATORS.put(RING_VIBRATION_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
|
||||
VALIDATORS.put(HAPTIC_FEEDBACK_INTENSITY, VIBRATION_INTENSITY_VALIDATOR);
|
||||
VALIDATORS.put(RINGTONE, RINGTONE_VALIDATOR);
|
||||
VALIDATORS.put(NOTIFICATION_SOUND, NOTIFICATION_SOUND_VALIDATOR);
|
||||
|
||||
@@ -1152,6 +1152,10 @@
|
||||
Settings.System.NOTIFICATION_VIBRATION_INTENSITY more details on the constant values and
|
||||
meanings. -->
|
||||
<integer name="config_defaultNotificationVibrationIntensity">2</integer>
|
||||
<!-- The default intensity level for ring vibrations. See
|
||||
Settings.System.RING_VIBRATION_INTENSITY more details on the constant values and
|
||||
meanings. -->
|
||||
<integer name="config_defaultRingVibrationIntensity">2</integer>
|
||||
|
||||
<bool name="config_use_strict_phone_number_comparation">false</bool>
|
||||
|
||||
|
||||
@@ -3489,6 +3489,7 @@
|
||||
|
||||
<java-symbol type="integer" name="config_defaultHapticFeedbackIntensity" />
|
||||
<java-symbol type="integer" name="config_defaultNotificationVibrationIntensity" />
|
||||
<java-symbol type="integer" name="config_defaultRingVibrationIntensity" />
|
||||
|
||||
<java-symbol type="bool" name="config_maskMainBuiltInDisplayCutout" />
|
||||
|
||||
|
||||
@@ -5325,7 +5325,7 @@ message MetricsEvent {
|
||||
// OS: P
|
||||
ACCESSIBILITY_VIBRATION = 1292;
|
||||
|
||||
// OPEN: Settings > Accessibility > Vibration > Ring & notification vibration
|
||||
// OPEN: Settings > Accessibility > Vibration > Notification vibration
|
||||
// CATEGORY: SETTINGS
|
||||
// OS: P
|
||||
ACCESSIBILITY_VIBRATION_NOTIFICATION = 1293;
|
||||
@@ -6763,6 +6763,11 @@ message MetricsEvent {
|
||||
// OS: Q
|
||||
ACTION_TEXT_CLASSIFIER_ACTIONS_GENERATED = 1619;
|
||||
|
||||
// OPEN: Settings > Accessibility > Vibration > Ring vibration
|
||||
// CATEGORY: SETTINGS
|
||||
// OS: Q
|
||||
ACCESSIBILITY_VIBRATION_RING = 1620;
|
||||
|
||||
// ---- End Q Constants, all Q constants go above this line ----
|
||||
|
||||
// Add new aosp constants above this line.
|
||||
|
||||
@@ -141,6 +141,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
private boolean mLowPowerMode;
|
||||
private int mHapticFeedbackIntensity;
|
||||
private int mNotificationIntensity;
|
||||
private int mRingIntensity;
|
||||
|
||||
native static boolean vibratorExists();
|
||||
native static void vibratorInit();
|
||||
@@ -428,6 +429,10 @@ public class VibratorService extends IVibratorService.Stub
|
||||
Settings.System.getUriFor(Settings.System.NOTIFICATION_VIBRATION_INTENSITY),
|
||||
true, mSettingObserver, UserHandle.USER_ALL);
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.System.getUriFor(Settings.System.RING_VIBRATION_INTENSITY),
|
||||
true, mSettingObserver, UserHandle.USER_ALL);
|
||||
|
||||
mContext.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -747,7 +752,9 @@ public class VibratorService extends IVibratorService.Stub
|
||||
}
|
||||
|
||||
private int getCurrentIntensityLocked(Vibration vib) {
|
||||
if (vib.isNotification() || vib.isRingtone()){
|
||||
if (vib.isRingtone()) {
|
||||
return mRingIntensity;
|
||||
} else if (vib.isNotification()) {
|
||||
return mNotificationIntensity;
|
||||
} else if (vib.isHapticFeedback()) {
|
||||
return mHapticFeedbackIntensity;
|
||||
@@ -769,7 +776,9 @@ public class VibratorService extends IVibratorService.Stub
|
||||
}
|
||||
|
||||
final int defaultIntensity;
|
||||
if (vib.isNotification() || vib.isRingtone()) {
|
||||
if (vib.isRingtone()) {
|
||||
defaultIntensity = mVibrator.getDefaultRingVibrationIntensity();
|
||||
} else if (vib.isNotification()) {
|
||||
defaultIntensity = mVibrator.getDefaultNotificationVibrationIntensity();
|
||||
} else if (vib.isHapticFeedback()) {
|
||||
defaultIntensity = mVibrator.getDefaultHapticFeedbackIntensity();
|
||||
@@ -932,6 +941,9 @@ public class VibratorService extends IVibratorService.Stub
|
||||
mNotificationIntensity = Settings.System.getIntForUser(mContext.getContentResolver(),
|
||||
Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
|
||||
mVibrator.getDefaultNotificationVibrationIntensity(), UserHandle.USER_CURRENT);
|
||||
mRingIntensity = Settings.System.getIntForUser(mContext.getContentResolver(),
|
||||
Settings.System.RING_VIBRATION_INTENSITY,
|
||||
mVibrator.getDefaultRingVibrationIntensity(), UserHandle.USER_CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1280,6 +1292,7 @@ public class VibratorService extends IVibratorService.Stub
|
||||
pw.println(" mLowPowerMode=" + mLowPowerMode);
|
||||
pw.println(" mHapticFeedbackIntensity=" + mHapticFeedbackIntensity);
|
||||
pw.println(" mNotificationIntensity=" + mNotificationIntensity);
|
||||
pw.println(" mRingIntensity=" + mRingIntensity);
|
||||
pw.println("");
|
||||
pw.println(" Previous vibrations:");
|
||||
for (VibrationInfo info : mPreviousVibrations) {
|
||||
|
||||
Reference in New Issue
Block a user