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

Commit c908e136 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Support vibration-select parsing

The VibrationXmlParser supported parsing a full XML document for a
single vibration, or an open parser for a single vibration. Given that a
lot of the use cases for VibrationXmlParser involve using fall-back
vibrations in case the first vibration is not supported by the target
Vibrator, we are introducing APIs to support a "vibration-select" XML
tag in a vibration serialization.

"vibration-select" allows serializing multiple vibrations in a single
XML document, or as part of a bigger XML. We are adding APIs to allow
parsing this tag as an entire document, or as part of a larger XML.

API changes:
- The existing TestApi to parse public-API-based vibration serializations
  is kept with only a renaming: parse() -> parseVibrationEffect().
- New API added, parseDocument() -> this parses an entire XML with a
  root tag of "vibration" or "vibration-select". It's a TestApi.
- New API added, parseElement() -> this parses a single element from an
  open parser, for the "vibration" or "vibration-select" tag.

Bug: 295335663
Test: atest VibrationEffectXmlSerializationTest
Test: atest ParsedVibrationTest
Test: atest HapticFeedbackCustomizationTest
Test: atest ShutdownThreadTest

Change-Id: I28f67440b09e751ea8b34cad3eaa800909eb4bc7
parent eb0f2e31
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2704,8 +2704,14 @@ package android.os.vibrator {

package android.os.vibrator.persistence {

  public class ParsedVibration {
    method @NonNull public java.util.List<android.os.VibrationEffect> getVibrationEffectListForTesting();
    method @Nullable public android.os.VibrationEffect resolve(@NonNull android.os.Vibrator);
  }

  public final class VibrationXmlParser {
    method @Nullable public static android.os.VibrationEffect parse(@NonNull java.io.Reader) throws java.io.IOException;
    method @Nullable public static android.os.vibrator.persistence.ParsedVibration parseDocument(@NonNull java.io.Reader) throws java.io.IOException;
    method @Nullable public static android.os.VibrationEffect parseVibrationEffect(@NonNull java.io.Reader) throws java.io.IOException;
  }

  public final class VibrationXmlSerializer {
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ final class InputDeviceVibrator extends Vibrator {
    }

    @Override
    protected VibratorInfo getInfo() {
    public VibratorInfo getInfo() {
        return mVibratorInfo;
    }

+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class SystemVibrator extends Vibrator {
    }

    @Override
    protected VibratorInfo getInfo() {
    public VibratorInfo getInfo() {
        synchronized (mLock) {
            if (mVibratorInfo != null) {
                return mVibratorInfo;
+1 −1
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ public class SystemVibratorManager extends VibratorManager {
        }

        @Override
        protected VibratorInfo getInfo() {
        public VibratorInfo getInfo() {
            return mVibratorInfo;
        }

+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public abstract class Vibrator {
     *
     * @hide
     */
    protected VibratorInfo getInfo() {
    public VibratorInfo getInfo() {
        return VibratorInfo.EMPTY_VIBRATOR_INFO;
    }

Loading