Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f586f221 authored by Lais Andrade's avatar Lais Andrade Committed by Android (Google) Code Review
Browse files

Merge "Introduce vibration session HAL support" into main

parents c0a92f55 f1120b13
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.vibrator;
@VintfStability
interface IVibrationSession {
  void close();
  void abort();
}
+3 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ interface IVibratorManager {
  void prepareSynced(in int[] vibratorIds);
  void triggerSynced(in android.hardware.vibrator.IVibratorCallback callback);
  void cancelSynced();
  android.hardware.vibrator.IVibrationSession startSession(in int[] vibratorIds, in android.hardware.vibrator.VibrationSessionConfig config, in android.hardware.vibrator.IVibratorCallback callback);
  void clearSessions();
  const int CAP_SYNC = (1 << 0) /* 1 */;
  const int CAP_PREPARE_ON = (1 << 1) /* 2 */;
  const int CAP_PREPARE_PERFORM = (1 << 2) /* 4 */;
@@ -48,4 +50,5 @@ interface IVibratorManager {
  const int CAP_MIXED_TRIGGER_PERFORM = (1 << 5) /* 32 */;
  const int CAP_MIXED_TRIGGER_COMPOSE = (1 << 6) /* 64 */;
  const int CAP_TRIGGER_CALLBACK = (1 << 7) /* 128 */;
  const int CAP_START_SESSIONS = (1 << 8) /* 256 */;
}
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.vibrator;
@VintfStability
parcelable VibrationSessionConfig {
  ParcelableHolder vendorExtension;
}
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.vibrator;

@VintfStability
interface IVibrationSession {
    /**
     * Request the end of this session.
     *
     * This will cause this session to end once the ongoing vibration commands are completed in each
     * individual vibrator. The immediate end of this session can stll be trigged via abort().
     *
     * This should not block on the end of this session. The callback provided during the creation
     * of this session should be used to indicate the vibrations are done and the session has
     * ended. The session object can be safely destroyed after this is called, and the session
     * should end as expected.
     */
    void close();

    /**
     * Immediately end this session.
     *
     * This will cause this session to end immediately and stop any ongoing vibration. The vibrator
     * manager and each individual vibrator in this session will be reset and available when this
     * returns.
     */
    void abort();
}
+49 −4
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package android.hardware.vibrator;

import android.hardware.vibrator.IVibrationSession;
import android.hardware.vibrator.IVibrator;
import android.hardware.vibrator.IVibratorCallback;
import android.hardware.vibrator.VibrationSessionConfig;

@VintfStability
interface IVibratorManager {
@@ -42,17 +44,23 @@ interface IVibratorManager {
     */
    const int CAP_MIXED_TRIGGER_ON = 1 << 4;
    /**
     * Whether IVibrator 'perform' can be triggered with other functions in sync with 'triggerSynced'.
     * Whether IVibrator 'perform' can be triggered with other functions in sync with
     * 'triggerSynced'.
     */
    const int CAP_MIXED_TRIGGER_PERFORM = 1 << 5;
    /**
     * Whether IVibrator 'compose' can be triggered with other functions in sync with 'triggerSynced'.
     * Whether IVibrator 'compose' can be triggered with other functions in sync with
     * 'triggerSynced'.
     */
    const int CAP_MIXED_TRIGGER_COMPOSE = 1 << 6;
    /**
     * Whether on w/ IVibratorCallback can be used w/ 'trigerSynced' function.
     */
    const int CAP_TRIGGER_CALLBACK = 1 << 7;
    /**
     * Whether vibration sessions are supported.
     */
    const int CAP_START_SESSIONS = 1 << 8;

    /**
     * Determine capabilities of the vibrator manager HAL (CAP_* mask)
@@ -75,8 +83,8 @@ interface IVibratorManager {
     * This function must only be called after the previous synced vibration was triggered or
     * canceled (through cancelSynced()).
     *
     * Doing this operation while any of the specified vibrators is already on is undefined behavior.
     * Clients should explicitly call off in each vibrator.
     * Doing this operation while any of the specified vibrators is already on is undefined
     * behavior. Clients should explicitly call off in each vibrator.
     *
     * @param vibratorIds ids of the vibrators to play vibrations in sync.
     */
@@ -99,4 +107,41 @@ interface IVibratorManager {
     * Cancel a previously-started preparation for synced vibration, if any.
     */
    void cancelSynced();

    /**
     * Start a vibration session.
     *
     * A vibration session can be used to send commands without resetting the vibrator state. Once a
     * session starts, the individual vibrators can receive one or more commands like on(),
     * performEffect(), setAmplitude(), etc. The vibrations performed in a session must have the
     * same behavior they have outside them. Multiple commands can be synced in a session via
     * prepareSynced as usual.
     *
     * Starting a session on a vibrator already in another session or in a prepareSynced state is
     * not allowed and should throw illegal state. The end of a session should always notify the
     * callback provided, even if it ends prematurely due to an error.
     *
     * This may not be supported and this support is reflected in
     * getCapabilities (CAP_START_SESSIONS). IVibratorCallback.onComplete() support is required for
     * this API.
     *
     * @param vibratorIds ids of the vibrators in the session.
     * @param config The parameters for starting a vibration session.
     * @param callback A callback used to inform Frameworks of state change.
     * @throws :
     *         - EX_UNSUPPORTED_OPERATION if unsupported, as reflected by getCapabilities.
     *         - EX_ILLEGAL_ARGUMENT for invalid vibrator IDs.
     *         - EX_ILLEGAL_STATE for vibrator IDs already in a session or in a prepareSynced state.
     *         - EX_SERVICE_SPECIFIC for bad vendor data.
     */
    IVibrationSession startSession(
            in int[] vibratorIds, in VibrationSessionConfig config, in IVibratorCallback callback);

    /**
     * Abort and clear all ongoing vibration sessions.
     *
     * This can be used to reset the vibrator manager and some individual vibrators to an idle
     * state.
     */
    void clearSessions();
}
Loading