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

Commit f50cc6a8 authored by Lais Andrade's avatar Lais Andrade
Browse files

Remove support for CombinedVibration.SequentialCombination

This API for combining a sequence of synchronized vibration effects was
never released and is not well supported.

Removing the unused framework code to support this unreleased fearure.

Bug: 421857859
Flag: android.os.vibrator.remove_sequential_combination
Test: FrameworksVibratorServicesTests
Change-Id: I71882414032d52532fe9fd835932cec133d4adfb
parent b9fd32e5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import java.util.function.Function;
public abstract class CombinedVibration implements Parcelable {
    private static final int PARCEL_TOKEN_MONO = 1;
    private static final int PARCEL_TOKEN_STEREO = 2;
    // TODO(b/421857859): remove this once flag remove_sequential_combination is removed
    private static final int PARCEL_TOKEN_SEQUENTIAL = 3;

    /** Prevent subclassing from outside of the framework. */
@@ -88,6 +89,7 @@ public abstract class CombinedVibration implements Parcelable {
     * @hide
     * @see CombinedVibration.SequentialCombination
     */
    // TODO(b/421857859): remove this once flag remove_sequential_combination is removed
    @TestApi
    @NonNull
    public static SequentialCombination startSequential() {
@@ -252,6 +254,7 @@ public abstract class CombinedVibration implements Parcelable {
     * @hide
     * @see CombinedVibration#startSequential()
     */
    // TODO(b/421857859): remove this class once flag remove_sequential_combination is removed
    @TestApi
    public static final class SequentialCombination {

@@ -766,6 +769,7 @@ public abstract class CombinedVibration implements Parcelable {
     *
     * @hide
     */
    // TODO(b/421857859): remove this class once flag remove_sequential_combination is removed
    @TestApi
    public static final class Sequential extends CombinedVibration {
        // If a vibration is playing more than 3 effects, it's probably not haptic feedback
+10 −0
Original line number Diff line number Diff line
@@ -149,3 +149,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "haptics"
    name: "remove_sequential_combination"
    description: "Remove CombinedVibration.SequentialCombination and related types"
    bug: "421857859"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+66 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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 com.android.server.vibrator;

import android.annotation.NonNull;
import android.os.Trace;

import java.util.List;

/**
 * Finish a synced vibration started by a {@link StartCombinedVibrationStep}.
 *
 * <p>This only plays after all active vibrators steps have finished.
 */
final class FinishCombinedVibrationStep extends Step {

    FinishCombinedVibrationStep(VibrationStepConductor conductor) {
        // No predefined startTime, just wait for all steps in the queue.
        super(conductor, Long.MAX_VALUE);
    }

    @Override
    public boolean isCleanUp() {
        // This step only notes that all the vibrators has been turned off.
        return true;
    }

    @NonNull
    @Override
    public List<Step> play() {
        Trace.traceBegin(Trace.TRACE_TAG_VIBRATOR, "FinishCombinedVibrationStep");
        try {
            conductor.vibratorManagerHooks.noteVibratorOff(
                    conductor.getVibration().callerInfo.uid);
            return VibrationStepConductor.EMPTY_STEP_LIST;
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_VIBRATOR);
        }
    }

    @NonNull
    @Override
    public List<Step> cancel() {
        cancelImmediately();
        return VibrationStepConductor.EMPTY_STEP_LIST;
    }

    @Override
    public void cancelImmediately() {
        conductor.vibratorManagerHooks.noteVibratorOff(conductor.getVibration().callerInfo.uid);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import java.util.List;
 * <p>This only plays after all active vibrators steps have finished, and adds a {@link
 * StartSequentialEffectStep} to the queue if the sequential effect isn't finished yet.
 */
// TODO(b/421857859): remove this class once flag remove_sequential_combination is removed
final class FinishSequentialEffectStep extends Step {
    public final StartSequentialEffectStep startedStep;

+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ final class HalVibration extends Vibration {
            for (int i = 0; i < effects.size(); i++) {
                fillFallbacksForEffect(effects.valueAt(i), fallbackProvider);
            }
        // TODO(b/421857859): remove this once flag remove_sequential_combination is removed
        } else if (effect instanceof CombinedVibration.Sequential) {
            List<CombinedVibration> effects =
                    ((CombinedVibration.Sequential) effect).getEffects();
Loading