1/* 2 * Copyright (C) 2016 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 17package android.hardware.vibrator@1.0; 18 19interface IVibrator { 20 /** 21 * Turn on vibrator 22 * 23 * This function must only be called after the previous timeout has expired or 24 * was canceled (through off()). 25 * @param timeout_ms number of milliseconds to vibrate. 26 * @return vibratorOnRet whether vibrator command was successful or not. 27 */ 28 on(uint32_t timeoutMs) generates (Status vibratorOnRet); 29 30 /** 31 * Turn off vibrator 32 * 33 * Cancel a previously-started vibration, if any. 34 * @return vibratorOffRet whether vibrator command was successful or not. 35 */ 36 off() generates (Status vibratorOffRet); 37 38 /** 39 * Returns whether the vibrator supports changes to its vibrational amplitude. 40 */ 41 supportsAmplitudeControl() generates (bool supports); 42 43 /** 44 * Sets the motor's vibrational amplitude. 45 * 46 * Changes the force being produced by the underlying motor. 47 * 48 * @param amplitude The unitless force setting. Note that this number must 49 * be between 1 and 255, inclusive. If the motor does not 50 * have exactly 255 steps, it must do it's best to map it 51 * onto the number of steps it does have. 52 * @return status Whether the command was successful or not. Must return 53 * Status::UNSUPPORTED_OPERATION if setting the amplitude is 54 * not supported by the device. 55 */ 56 setAmplitude(uint8_t amplitude) generates (Status status); 57 58 /** 59 * Fire off a predefined haptic event. 60 * 61 * @param event The type of haptic event to trigger. 62 * @return status Whether the effect was successfully performed or not. Must 63 * return Status::UNSUPPORTED_OPERATION is the effect is not 64 * supported. 65 * @return lengthMs The length of time the event is expected to take in 66 * milliseconds. This doesn't need to be perfectly accurate, 67 * but should be a reasonable approximation. Should be a 68 * positive, non-zero value if the returned status is 69 * Status::OK, and set to 0 otherwise. 70 */ 71 perform(Effect effect, EffectStrength strength) generates (Status status, uint32_t lengthMs); 72}; 73