1 /** 2 * Copyright (c) 2018, 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 19 import android.os.ExternalVibration; 20 import android.os.ExternalVibrationScale; 21 22 /** 23 * The communication channel by which an external system that wants to control the system 24 * vibrator can notify the vibrator subsystem. 25 * 26 * Some vibrators can be driven via multiple paths (e.g. as an audio channel) in addition to 27 * the usual interface, but we typically only want one vibration at a time playing because they 28 * don't mix well. In order to synchronize the two places where vibration might be controlled, 29 * we provide this interface so the vibrator subsystem has a chance to: 30 * 31 * 1) Decide whether the current vibration should play based on the current system policy. 32 * 2) Stop any currently on-going vibrations. 33 * {@hide} 34 */ 35 interface IExternalVibratorService { 36 /** 37 * A method called by the external system to start a vibration. 38 * 39 * This returns an {@link ExternalVibrationScale} which includes the vibration scale level and 40 * the adaptive haptics scale. 41 * 42 * If the returned scale level is {@link ExternalVibrationScale.ScaleLevel#SCALE_MUTE}, then 43 * the vibration should <em>not</em> play. If it returns any other scale level, then 44 * any currently playing vibration controlled by the requesting system must be muted and this 45 * vibration can begin playback. 46 * 47 * Note that the IExternalVibratorService implementation will not call mute on any currently 48 * playing external vibrations in order to avoid re-entrancy with the system on the other side. 49 * 50 * @param vib The external vibration starting. 51 * @return {@link ExternalVibrationScale} including scale level and adaptive haptics scale. 52 */ onExternalVibrationStart(in ExternalVibration vib)53 ExternalVibrationScale onExternalVibrationStart(in ExternalVibration vib); 54 55 /** 56 * A method called by the external system when a vibration no longer wants to play. 57 */ onExternalVibrationStop(in ExternalVibration vib)58 void onExternalVibrationStop(in ExternalVibration vib); 59 } 60