The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.os; |
| 18 | |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Harpreet \"Eli\" Sangha | 45d53ee | 2019-09-25 17:43:24 +0900 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 21 | import android.annotation.RequiresPermission; |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 22 | import android.annotation.SystemService; |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 23 | import android.app.ActivityThread; |
Artur Satayev | afdb23a | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 24 | import android.compat.annotation.UnsupportedAppUsage; |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 25 | import android.content.Context; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 26 | import android.media.AudioAttributes; |
Michael Wright | 6a40713e | 2017-04-05 14:13:19 +0100 | [diff] [blame] | 27 | import android.util.Log; |
Brad Fitzpatrick | e331644 | 2010-10-14 19:40:56 -0700 | [diff] [blame] | 28 | |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 29 | import java.lang.annotation.Retention; |
| 30 | import java.lang.annotation.RetentionPolicy; |
| 31 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | /** |
| 33 | * Class that operates the vibrator on the device. |
| 34 | * <p> |
John Spurlock | 0f49c28 | 2014-03-10 11:29:35 -0400 | [diff] [blame] | 35 | * If your process exits, any vibration you started will stop. |
Jeff Brown | d10bfe1 | 2010-12-14 13:23:10 -0800 | [diff] [blame] | 36 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | */ |
Jeff Sharkey | d86b8fe | 2017-06-02 17:36:26 -0600 | [diff] [blame] | 38 | @SystemService(Context.VIBRATOR_SERVICE) |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 39 | public abstract class Vibrator { |
Michael Wright | 6a40713e | 2017-04-05 14:13:19 +0100 | [diff] [blame] | 40 | private static final String TAG = "Vibrator"; |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 41 | |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 42 | /** |
| 43 | * Vibration intensity: no vibrations. |
| 44 | * @hide |
| 45 | */ |
| 46 | public static final int VIBRATION_INTENSITY_OFF = 0; |
| 47 | |
| 48 | /** |
| 49 | * Vibration intensity: low. |
| 50 | * @hide |
| 51 | */ |
| 52 | public static final int VIBRATION_INTENSITY_LOW = 1; |
| 53 | |
| 54 | /** |
| 55 | * Vibration intensity: medium. |
| 56 | * @hide |
| 57 | */ |
| 58 | public static final int VIBRATION_INTENSITY_MEDIUM = 2; |
| 59 | |
| 60 | /** |
| 61 | * Vibration intensity: high. |
| 62 | * @hide |
| 63 | */ |
| 64 | public static final int VIBRATION_INTENSITY_HIGH = 3; |
| 65 | |
| 66 | /** @hide */ |
| 67 | @Retention(RetentionPolicy.SOURCE) |
| 68 | @IntDef(prefix = { "VIBRATION_INTENSITY_" }, value = { |
| 69 | VIBRATION_INTENSITY_OFF, |
| 70 | VIBRATION_INTENSITY_LOW, |
| 71 | VIBRATION_INTENSITY_MEDIUM, |
| 72 | VIBRATION_INTENSITY_HIGH |
| 73 | }) |
| 74 | public @interface VibrationIntensity{} |
| 75 | |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 76 | private final String mPackageName; |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 77 | // The default vibration intensity level for haptic feedback. |
| 78 | @VibrationIntensity |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 79 | private int mDefaultHapticFeedbackIntensity; |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 80 | // The default vibration intensity level for notifications. |
| 81 | @VibrationIntensity |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 82 | private int mDefaultNotificationVibrationIntensity; |
| 83 | // The default vibration intensity level for ringtones. |
| 84 | @VibrationIntensity |
| 85 | private int mDefaultRingVibrationIntensity; |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 86 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 87 | /** |
| 88 | * @hide to prevent subclassing from outside of the framework |
| 89 | */ |
Andrei Onea | 24ec321 | 2019-03-15 17:35:05 +0000 | [diff] [blame] | 90 | @UnsupportedAppUsage |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 91 | public Vibrator() { |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 92 | mPackageName = ActivityThread.currentPackageName(); |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 93 | final Context ctx = ActivityThread.currentActivityThread().getSystemContext(); |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 94 | loadVibrationIntensities(ctx); |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @hide to prevent subclassing from outside of the framework |
| 99 | */ |
| 100 | protected Vibrator(Context context) { |
| 101 | mPackageName = context.getOpPackageName(); |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 102 | loadVibrationIntensities(context); |
| 103 | } |
| 104 | |
| 105 | private void loadVibrationIntensities(Context context) { |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 106 | mDefaultHapticFeedbackIntensity = loadDefaultIntensity(context, |
| 107 | com.android.internal.R.integer.config_defaultHapticFeedbackIntensity); |
| 108 | mDefaultNotificationVibrationIntensity = loadDefaultIntensity(context, |
| 109 | com.android.internal.R.integer.config_defaultNotificationVibrationIntensity); |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 110 | mDefaultRingVibrationIntensity = loadDefaultIntensity(context, |
| 111 | com.android.internal.R.integer.config_defaultRingVibrationIntensity); |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | private int loadDefaultIntensity(Context ctx, int resId) { |
| 115 | return ctx != null ? ctx.getResources().getInteger(resId) : VIBRATION_INTENSITY_MEDIUM; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | /** |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 119 | * Get the default vibration intensity for haptic feedback. |
| 120 | * @hide |
| 121 | */ |
| 122 | public int getDefaultHapticFeedbackIntensity() { |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 123 | return mDefaultHapticFeedbackIntensity; |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /** |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 127 | * Get the default vibration intensity for notifications. |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 128 | * @hide |
| 129 | */ |
| 130 | public int getDefaultNotificationVibrationIntensity() { |
Michael Wright | 0dbb516 | 2018-05-25 15:13:36 +0100 | [diff] [blame] | 131 | return mDefaultNotificationVibrationIntensity; |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Alexey Kuzmin | ccdaebb | 2018-12-10 12:02:51 +0000 | [diff] [blame] | 134 | /** Get the default vibration intensity for ringtones. |
| 135 | * @hide |
| 136 | */ |
| 137 | public int getDefaultRingVibrationIntensity() { |
| 138 | return mDefaultRingVibrationIntensity; |
| 139 | } |
| 140 | |
Michael Wright | 35a0c67 | 2018-01-24 00:32:53 +0000 | [diff] [blame] | 141 | /** |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 142 | * Check whether the hardware has a vibrator. |
| 143 | * |
| 144 | * @return True if the hardware has a vibrator, else false. |
Dianne Hackborn | ea9020e | 2010-11-04 11:39:12 -0700 | [diff] [blame] | 145 | */ |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 146 | public abstract boolean hasVibrator(); |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 147 | |
Dianne Hackborn | ea9020e | 2010-11-04 11:39:12 -0700 | [diff] [blame] | 148 | /** |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 149 | * Check whether the vibrator has amplitude control. |
| 150 | * |
| 151 | * @return True if the hardware can control the amplitude of the vibrations, otherwise false. |
| 152 | */ |
| 153 | public abstract boolean hasAmplitudeControl(); |
| 154 | |
| 155 | /** |
Harpreet \"Eli\" Sangha | 45d53ee | 2019-09-25 17:43:24 +0900 | [diff] [blame] | 156 | * Configure an always-on haptics effect. |
| 157 | * |
| 158 | * @param id The board-specific always-on ID to configure. |
| 159 | * @param effect Vibration effect to assign to always-on id. Passing null will disable it. |
| 160 | * @param attributes {@link AudioAttributes} corresponding to the vibration. For example, |
| 161 | * specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or |
| 162 | * {@link AudioAttributes#USAGE_NOTIFICATION_RINGTONE} for |
| 163 | * vibrations associated with incoming calls. May only be null when effect is null. |
| 164 | * @hide |
| 165 | */ |
| 166 | @RequiresPermission(android.Manifest.permission.VIBRATE_ALWAYS_ON) |
| 167 | public boolean setAlwaysOnEffect(int id, @Nullable VibrationEffect effect, |
| 168 | @Nullable AudioAttributes attributes) { |
| 169 | Log.w(TAG, "Always-on effects aren't supported"); |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | /** |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 174 | * Vibrate constantly for the specified period of time. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | * |
Jeff Brown | d10bfe1 | 2010-12-14 13:23:10 -0800 | [diff] [blame] | 176 | * @param milliseconds The number of milliseconds to vibrate. |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 177 | * |
| 178 | * @deprecated Use {@link #vibrate(VibrationEffect)} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | */ |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 180 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 181 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 182 | public void vibrate(long milliseconds) { |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 183 | vibrate(milliseconds, null); |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Vibrate constantly for the specified period of time. |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 188 | * |
| 189 | * @param milliseconds The number of milliseconds to vibrate. |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 190 | * @param attributes {@link AudioAttributes} corresponding to the vibration. For example, |
| 191 | * specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or |
Jean-Michel Trivi | 89c3b29 | 2014-07-20 11:41:02 -0700 | [diff] [blame] | 192 | * {@link AudioAttributes#USAGE_NOTIFICATION_RINGTONE} for |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 193 | * vibrations associated with incoming calls. |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 194 | * |
| 195 | * @deprecated Use {@link #vibrate(VibrationEffect, AudioAttributes)} instead. |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 196 | */ |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 197 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 198 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 199 | public void vibrate(long milliseconds, AudioAttributes attributes) { |
Michael Wright | 6a40713e | 2017-04-05 14:13:19 +0100 | [diff] [blame] | 200 | try { |
| 201 | // This ignores all exceptions to stay compatible with pre-O implementations. |
| 202 | VibrationEffect effect = |
| 203 | VibrationEffect.createOneShot(milliseconds, VibrationEffect.DEFAULT_AMPLITUDE); |
| 204 | vibrate(effect, attributes); |
| 205 | } catch (IllegalArgumentException iae) { |
| 206 | Log.e(TAG, "Failed to create VibrationEffect", iae); |
| 207 | } |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 208 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | |
| 210 | /** |
| 211 | * Vibrate with a given pattern. |
| 212 | * |
| 213 | * <p> |
Jeff Brown | d10bfe1 | 2010-12-14 13:23:10 -0800 | [diff] [blame] | 214 | * Pass in an array of ints that are the durations for which to turn on or off |
| 215 | * the vibrator in milliseconds. The first value indicates the number of milliseconds |
| 216 | * to wait before turning the vibrator on. The next value indicates the number of milliseconds |
| 217 | * for which to keep the vibrator on before turning it off. Subsequent values alternate |
| 218 | * between durations in milliseconds to turn the vibrator off or to turn the vibrator on. |
| 219 | * </p><p> |
| 220 | * To cause the pattern to repeat, pass the index into the pattern array at which |
| 221 | * to start the repeat, or -1 to disable repeating. |
| 222 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | * |
Jeff Brown | d10bfe1 | 2010-12-14 13:23:10 -0800 | [diff] [blame] | 224 | * @param pattern an array of longs of times for which to turn the vibrator on or off. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | * @param repeat the index into pattern at which to repeat, or -1 if |
| 226 | * you don't want to repeat. |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 227 | * |
| 228 | * @deprecated Use {@link #vibrate(VibrationEffect)} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | */ |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 230 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 231 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 232 | public void vibrate(long[] pattern, int repeat) { |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 233 | vibrate(pattern, repeat, null); |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Vibrate with a given pattern. |
| 238 | * |
| 239 | * <p> |
| 240 | * Pass in an array of ints that are the durations for which to turn on or off |
| 241 | * the vibrator in milliseconds. The first value indicates the number of milliseconds |
| 242 | * to wait before turning the vibrator on. The next value indicates the number of milliseconds |
| 243 | * for which to keep the vibrator on before turning it off. Subsequent values alternate |
| 244 | * between durations in milliseconds to turn the vibrator off or to turn the vibrator on. |
| 245 | * </p><p> |
| 246 | * To cause the pattern to repeat, pass the index into the pattern array at which |
| 247 | * to start the repeat, or -1 to disable repeating. |
| 248 | * </p> |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 249 | * |
| 250 | * @param pattern an array of longs of times for which to turn the vibrator on or off. |
| 251 | * @param repeat the index into pattern at which to repeat, or -1 if |
| 252 | * you don't want to repeat. |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 253 | * @param attributes {@link AudioAttributes} corresponding to the vibration. For example, |
| 254 | * specify {@link AudioAttributes#USAGE_ALARM} for alarm vibrations or |
Jean-Michel Trivi | 89c3b29 | 2014-07-20 11:41:02 -0700 | [diff] [blame] | 255 | * {@link AudioAttributes#USAGE_NOTIFICATION_RINGTONE} for |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 256 | * vibrations associated with incoming calls. |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 257 | * |
| 258 | * @deprecated Use {@link #vibrate(VibrationEffect, AudioAttributes)} instead. |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 259 | */ |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 260 | @Deprecated |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 261 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 262 | public void vibrate(long[] pattern, int repeat, AudioAttributes attributes) { |
Michael Wright | 6a40713e | 2017-04-05 14:13:19 +0100 | [diff] [blame] | 263 | // This call needs to continue throwing ArrayIndexOutOfBoundsException but ignore all other |
| 264 | // exceptions for compatibility purposes |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 265 | if (repeat < -1 || repeat >= pattern.length) { |
Michael Wright | 0ef6edd | 2017-04-05 20:57:39 +0100 | [diff] [blame] | 266 | Log.e(TAG, "vibrate called with repeat index out of bounds" + |
| 267 | " (pattern.length=" + pattern.length + ", index=" + repeat + ")"); |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 268 | throw new ArrayIndexOutOfBoundsException(); |
| 269 | } |
Michael Wright | 6a40713e | 2017-04-05 14:13:19 +0100 | [diff] [blame] | 270 | |
| 271 | try { |
| 272 | vibrate(VibrationEffect.createWaveform(pattern, repeat), attributes); |
| 273 | } catch (IllegalArgumentException iae) { |
| 274 | Log.e(TAG, "Failed to create VibrationEffect", iae); |
| 275 | } |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 278 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 279 | public void vibrate(VibrationEffect vibe) { |
| 280 | vibrate(vibe, null); |
| 281 | } |
| 282 | |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 283 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
Michael Wright | 7121697 | 2017-01-31 18:33:54 +0000 | [diff] [blame] | 284 | public void vibrate(VibrationEffect vibe, AudioAttributes attributes) { |
Alexey Kuzmin | e1f06b8 | 2018-06-20 17:48:43 +0100 | [diff] [blame] | 285 | vibrate(Process.myUid(), mPackageName, vibe, null, attributes); |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 286 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | |
| 288 | /** |
Alexey Kuzmin | e1f06b8 | 2018-06-20 17:48:43 +0100 | [diff] [blame] | 289 | * Like {@link #vibrate(int, String, VibrationEffect, AudioAttributes)}, but allows the |
| 290 | * caller to specify the vibration is owned by someone else and set reason for vibration. |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 291 | * @hide |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 292 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 293 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
Alexey Kuzmin | e1f06b8 | 2018-06-20 17:48:43 +0100 | [diff] [blame] | 294 | public abstract void vibrate(int uid, String opPkg, VibrationEffect vibe, |
| 295 | String reason, AudioAttributes attributes); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 296 | |
| 297 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | * Turn the vibrator off. |
| 299 | */ |
Jeff Sharkey | 30e06bb | 2017-04-24 11:18:03 -0600 | [diff] [blame] | 300 | @RequiresPermission(android.Manifest.permission.VIBRATE) |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 301 | public abstract void cancel(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | } |