1 /*
2  * Copyright 2023 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 androidx.core.haptics.signal
18 
19 import androidx.core.haptics.device.HapticDeviceProfile
20 
21 /**
22  * A function that provides a [HapticSignal] to be played by a device vibrator.
23  *
24  * Resolvable haptic signals allow for extension of [HapticSignal] by providing an opaque
25  * representation that can be resolved for a specific device vibrator base on its capabilities
26  * described by the [HapticDeviceProfile].
27  *
28  * This can be used to implement custom fallback behavior for lower SDK versions and/or less capable
29  * vibrator hardware.
30  */
31 public fun interface ResolvableSignal {
32 
33     /**
34      * Returns a concrete [HapticSignal] to be played in the device with given profile.
35      *
36      * This method can return a different signal based on the capabilities of the given device
37      * vibrator, including null if no haptic should be played by this device.
38      *
39      * @param deviceProfile The device profile to be used for haptic capability checks.
40      * @return The [HapticSignal] to be played on given device, not null if no signal should be
41      *   played in this device.
42      */
resolvenull43     public fun resolve(deviceProfile: HapticDeviceProfile): HapticSignal?
44 }
45