Merge "Add documentation to Vibrator on foreground/background app behavior" am: 8ceda33e96 am: 53720c4394 am: a3ff04d175

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1567201

Change-Id: I6f80fd6e9c20f6eeb61c8809cba8f185ceacf386
This commit is contained in:
Treehugger Robot
2021-05-26 19:59:54 +00:00
committed by Automerger Merge Worker

View File

@@ -327,6 +327,8 @@ public abstract class Vibrator {
/** /**
* Vibrate constantly for the specified period of time. * Vibrate constantly for the specified period of time.
* *
* <p>The app should be in foreground for the vibration to happen.</p>
*
* @param milliseconds The number of milliseconds to vibrate. * @param milliseconds The number of milliseconds to vibrate.
* @deprecated Use {@link #vibrate(VibrationEffect)} instead. * @deprecated Use {@link #vibrate(VibrationEffect)} instead.
*/ */
@@ -339,6 +341,9 @@ public abstract class Vibrator {
/** /**
* Vibrate constantly for the specified period of time. * Vibrate constantly for the specified period of time.
* *
* <p>The app should be in foreground for the vibration to happen. Background apps should
* specify a ringtone, notification or alarm usage in order to vibrate.</p>
*
* @param milliseconds The number of milliseconds to vibrate. * @param milliseconds The number of milliseconds to vibrate.
* @param attributes {@link AudioAttributes} corresponding to the vibration. For example, * @param attributes {@link AudioAttributes} corresponding to the vibration. For example,
* specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or * specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or
@@ -373,6 +378,8 @@ public abstract class Vibrator {
* to start the repeat, or -1 to disable repeating. * to start the repeat, or -1 to disable repeating.
* </p> * </p>
* *
* <p>The app should be in foreground for the vibration to happen.</p>
*
* @param pattern an array of longs of times for which to turn the vibrator on or off. * @param pattern an array of longs of times for which to turn the vibrator on or off.
* @param repeat the index into pattern at which to repeat, or -1 if * @param repeat the index into pattern at which to repeat, or -1 if
* you don't want to repeat. * you don't want to repeat.
@@ -398,6 +405,9 @@ public abstract class Vibrator {
* to start the repeat, or -1 to disable repeating. * to start the repeat, or -1 to disable repeating.
* </p> * </p>
* *
* <p>The app should be in foreground for the vibration to happen. Background apps should
* specify a ringtone, notification or alarm usage in order to vibrate.</p>
*
* @param pattern an array of longs of times for which to turn the vibrator on or off. * @param pattern an array of longs of times for which to turn the vibrator on or off.
* @param repeat the index into pattern at which to repeat, or -1 if * @param repeat the index into pattern at which to repeat, or -1 if
* you don't want to repeat. * you don't want to repeat.
@@ -425,11 +435,30 @@ public abstract class Vibrator {
} }
} }
/**
* Vibrate with a given effect.
*
* <p>The app should be in foreground for the vibration to happen.</p>
*
* @param vibe {@link VibrationEffect} describing the vibration to be performed.
*/
@RequiresPermission(android.Manifest.permission.VIBRATE) @RequiresPermission(android.Manifest.permission.VIBRATE)
public void vibrate(VibrationEffect vibe) { public void vibrate(VibrationEffect vibe) {
vibrate(vibe, null); vibrate(vibe, null);
} }
/**
* Vibrate with a given effect.
*
* <p>The app should be in foreground for the vibration to happen. Background apps should
* specify a ringtone, notification or alarm usage in order to vibrate.</p>
*
* @param vibe {@link VibrationEffect} describing the vibration to be performed.
* @param attributes {@link AudioAttributes} corresponding to the vibration. For example,
* specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or
* {@link AudioAttributes#USAGE_NOTIFICATION_RINGTONE} for
* vibrations associated with incoming calls.
*/
@RequiresPermission(android.Manifest.permission.VIBRATE) @RequiresPermission(android.Manifest.permission.VIBRATE)
public void vibrate(VibrationEffect vibe, AudioAttributes attributes) { public void vibrate(VibrationEffect vibe, AudioAttributes attributes) {
vibrate(Process.myUid(), mPackageName, vibe, null, attributes); vibrate(Process.myUid(), mPackageName, vibe, null, attributes);