Loading core/api/test-current.txt +2 −2 Original line number Diff line number Diff line Loading @@ -2603,7 +2603,7 @@ package android.os { public abstract class Vibrator { method public int getDefaultVibrationIntensity(int); method @Nullable public android.os.vibrator.VibratorFrequencyProfile getFrequencyProfile(); method @Nullable public android.os.vibrator.VibratorFrequencyProfileLegacy getFrequencyProfileLegacy(); method public boolean hasFrequencyControl(); field public static final int VIBRATION_INTENSITY_HIGH = 3; // 0x3 field public static final int VIBRATION_INTENSITY_LOW = 1; // 0x1 Loading Loading @@ -2793,7 +2793,7 @@ package android.os.vibrator { field @NonNull public static final android.os.Parcelable.Creator<android.os.vibrator.VibrationEffectSegment> CREATOR; } public final class VibratorFrequencyProfile { public final class VibratorFrequencyProfileLegacy { method public float getMaxAmplitudeMeasurementInterval(); method @FloatRange(from=0, to=1) @NonNull public float[] getMaxAmplitudeMeasurements(); method public float getMaxFrequency(); Loading core/java/android/os/VibrationEffect.java +3 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.vibrator.PrimitiveSegment; import android.os.vibrator.RampSegment; import android.os.vibrator.StepSegment; import android.os.vibrator.VibrationEffectSegment; import android.os.vibrator.VibratorFrequencyProfileLegacy; import android.util.MathUtils; import com.android.internal.util.Preconditions; Loading Loading @@ -1761,7 +1762,7 @@ public abstract class VibrationEffect implements Parcelable { * new value as fast as possible. * * <p>Vibration parameter values will be truncated to conform to the device capabilities * according to the {@link android.os.vibrator.VibratorFrequencyProfile}. * according to the {@link VibratorFrequencyProfileLegacy}. * * @param duration The length of time this transition should take. Value must be * non-negative and will be truncated to milliseconds. Loading Loading @@ -1792,7 +1793,7 @@ public abstract class VibrationEffect implements Parcelable { * new values as fast as possible. * * <p>Vibration parameters values will be truncated to conform to the device capabilities * according to the {@link android.os.vibrator.VibratorFrequencyProfile}. * according to the {@link VibratorFrequencyProfileLegacy}. * * @param duration The length of time this transition should take. Value must be * non-negative and will be truncated to milliseconds. Loading core/java/android/os/Vibrator.java +7 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.TestApi; Loading @@ -33,7 +34,7 @@ import android.hardware.vibrator.IVibrator; import android.media.AudioAttributes; import android.os.vibrator.Flags; import android.os.vibrator.VibrationConfig; import android.os.vibrator.VibratorFrequencyProfile; import android.os.vibrator.VibratorFrequencyProfileLegacy; import android.util.Log; import android.view.HapticFeedbackConstants; Loading Loading @@ -290,13 +291,15 @@ public abstract class Vibrator { * @hide */ @TestApi @SuppressLint("UnflaggedApi") @Nullable public VibratorFrequencyProfile getFrequencyProfile() { VibratorInfo.FrequencyProfile frequencyProfile = getInfo().getFrequencyProfile(); public VibratorFrequencyProfileLegacy getFrequencyProfileLegacy() { VibratorInfo.FrequencyProfileLegacy frequencyProfile = getInfo().getFrequencyProfileLegacy(); if (frequencyProfile.isEmpty()) { return null; } return new VibratorFrequencyProfile(frequencyProfile); return new VibratorFrequencyProfileLegacy(frequencyProfile); } /** Loading core/java/android/os/VibratorInfo.java +32 −32 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class VibratorInfo implements Parcelable { private final int mPwlePrimitiveDurationMax; private final int mPwleSizeMax; private final float mQFactor; private final FrequencyProfile mFrequencyProfile; private final FrequencyProfileLegacy mFrequencyProfileLegacy; private final int mMaxEnvelopeEffectSize; private final int mMinEnvelopeEffectControlPointDurationMillis; private final int mMaxEnvelopeEffectControlPointDurationMillis; Loading @@ -75,7 +75,7 @@ public class VibratorInfo implements Parcelable { mPwlePrimitiveDurationMax = in.readInt(); mPwleSizeMax = in.readInt(); mQFactor = in.readFloat(); mFrequencyProfile = FrequencyProfile.CREATOR.createFromParcel(in); mFrequencyProfileLegacy = FrequencyProfileLegacy.CREATOR.createFromParcel(in); mMaxEnvelopeEffectSize = in.readInt(); mMinEnvelopeEffectControlPointDurationMillis = in.readInt(); mMaxEnvelopeEffectControlPointDurationMillis = in.readInt(); Loading @@ -86,7 +86,7 @@ public class VibratorInfo implements Parcelable { baseVibratorInfo.mSupportedBraking, baseVibratorInfo.mSupportedPrimitives, baseVibratorInfo.mPrimitiveDelayMax, baseVibratorInfo.mCompositionSizeMax, baseVibratorInfo.mPwlePrimitiveDurationMax, baseVibratorInfo.mPwleSizeMax, baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfile, baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfileLegacy, baseVibratorInfo.mMaxEnvelopeEffectSize, baseVibratorInfo.mMinEnvelopeEffectControlPointDurationMillis, baseVibratorInfo.mMaxEnvelopeEffectControlPointDurationMillis); Loading @@ -112,7 +112,7 @@ public class VibratorInfo implements Parcelable { * @param pwleSizeMax The maximum number of primitives supported by a PWLE * composition. * @param qFactor The vibrator quality factor. * @param frequencyProfile The description of the vibrator supported frequencies and max * @param frequencyProfileLegacy The description of the vibrator supported frequencies and max * amplitude mappings. * @hide */ Loading @@ -120,11 +120,11 @@ public class VibratorInfo implements Parcelable { @Nullable SparseBooleanArray supportedBraking, @NonNull SparseIntArray supportedPrimitives, int primitiveDelayMax, int compositionSizeMax, int pwlePrimitiveDurationMax, int pwleSizeMax, float qFactor, @NonNull FrequencyProfile frequencyProfile, float qFactor, @NonNull FrequencyProfileLegacy frequencyProfileLegacy, int maxEnvelopeEffectSize, int minEnvelopeEffectControlPointDurationMillis, int maxEnvelopeEffectControlPointDurationMillis) { Preconditions.checkNotNull(supportedPrimitives); Preconditions.checkNotNull(frequencyProfile); Preconditions.checkNotNull(frequencyProfileLegacy); mId = id; mCapabilities = capabilities; mSupportedEffects = supportedEffects == null ? null : supportedEffects.clone(); Loading @@ -135,7 +135,7 @@ public class VibratorInfo implements Parcelable { mPwlePrimitiveDurationMax = pwlePrimitiveDurationMax; mPwleSizeMax = pwleSizeMax; mQFactor = qFactor; mFrequencyProfile = frequencyProfile; mFrequencyProfileLegacy = frequencyProfileLegacy; mMaxEnvelopeEffectSize = maxEnvelopeEffectSize; mMinEnvelopeEffectControlPointDurationMillis = minEnvelopeEffectControlPointDurationMillis; Loading @@ -155,7 +155,7 @@ public class VibratorInfo implements Parcelable { dest.writeInt(mPwlePrimitiveDurationMax); dest.writeInt(mPwleSizeMax); dest.writeFloat(mQFactor); mFrequencyProfile.writeToParcel(dest, flags); mFrequencyProfileLegacy.writeToParcel(dest, flags); dest.writeInt(mMaxEnvelopeEffectSize); dest.writeInt(mMinEnvelopeEffectControlPointDurationMillis); dest.writeInt(mMaxEnvelopeEffectControlPointDurationMillis); Loading Loading @@ -205,7 +205,7 @@ public class VibratorInfo implements Parcelable { && Objects.equals(mSupportedEffects, that.mSupportedEffects) && Objects.equals(mSupportedBraking, that.mSupportedBraking) && Objects.equals(mQFactor, that.mQFactor) && Objects.equals(mFrequencyProfile, that.mFrequencyProfile) && Objects.equals(mFrequencyProfileLegacy, that.mFrequencyProfileLegacy) && mMaxEnvelopeEffectSize == that.mMaxEnvelopeEffectSize && mMinEnvelopeEffectControlPointDurationMillis == that.mMinEnvelopeEffectControlPointDurationMillis Loading @@ -216,7 +216,7 @@ public class VibratorInfo implements Parcelable { @Override public int hashCode() { int hashCode = Objects.hash(mId, mCapabilities, mSupportedEffects, mSupportedBraking, mQFactor, mFrequencyProfile); mQFactor, mFrequencyProfileLegacy); for (int i = 0; i < mSupportedPrimitives.size(); i++) { hashCode = 31 * hashCode + mSupportedPrimitives.keyAt(i); hashCode = 31 * hashCode + mSupportedPrimitives.valueAt(i); Loading @@ -238,7 +238,7 @@ public class VibratorInfo implements Parcelable { + ", mPwlePrimitiveDurationMax=" + mPwlePrimitiveDurationMax + ", mPwleSizeMax=" + mPwleSizeMax + ", mQFactor=" + mQFactor + ", mFrequencyProfile=" + mFrequencyProfile + ", mFrequencyProfileLegacy=" + mFrequencyProfileLegacy + ", mMaxEnvelopeEffectSize=" + mMaxEnvelopeEffectSize + ", mMinEnvelopeEffectControlPointDurationMillis=" + mMinEnvelopeEffectControlPointDurationMillis Loading @@ -262,7 +262,7 @@ public class VibratorInfo implements Parcelable { pw.println("pwlePrimitiveDurationMax = " + mPwlePrimitiveDurationMax); pw.println("pwleSizeMax = " + mPwleSizeMax); pw.println("q-factor = " + mQFactor); pw.println("frequencyProfile = " + mFrequencyProfile); pw.println("frequencyProfileLegacy = " + mFrequencyProfileLegacy); pw.println("mMaxEnvelopeEffectSize = " + mMaxEnvelopeEffectSize); pw.println("mMinEnvelopeEffectControlPointDurationMillis = " + mMinEnvelopeEffectControlPointDurationMillis); Loading Loading @@ -517,7 +517,7 @@ public class VibratorInfo implements Parcelable { * this vibrator is a composite of multiple physical devices. */ public float getResonantFrequencyHz() { return mFrequencyProfile.mResonantFrequencyHz; return mFrequencyProfileLegacy.mResonantFrequencyHz; } /** Loading @@ -537,8 +537,8 @@ public class VibratorInfo implements Parcelable { * <p>If the devices does not have frequency control then the profile should be empty. */ @NonNull public FrequencyProfile getFrequencyProfile() { return mFrequencyProfile; public FrequencyProfileLegacy getFrequencyProfileLegacy() { return mFrequencyProfileLegacy; } /** Returns a single int representing all the capabilities of the vibrator. */ Loading Loading @@ -640,7 +640,7 @@ public class VibratorInfo implements Parcelable { * * @hide */ public static final class FrequencyProfile implements Parcelable { public static final class FrequencyProfileLegacy implements Parcelable { @Nullable private final Range<Float> mFrequencyRangeHz; private final float mMinFrequencyHz; Loading @@ -648,7 +648,7 @@ public class VibratorInfo implements Parcelable { private final float mFrequencyResolutionHz; private final float[] mMaxAmplitudes; FrequencyProfile(Parcel in) { FrequencyProfileLegacy(Parcel in) { this(in.readFloat(), in.readFloat(), in.readFloat(), in.createFloatArray()); } Loading @@ -664,7 +664,7 @@ public class VibratorInfo implements Parcelable { * resolution. * @hide */ public FrequencyProfile(float resonantFrequencyHz, float minFrequencyHz, public FrequencyProfileLegacy(float resonantFrequencyHz, float minFrequencyHz, float frequencyResolutionHz, float[] maxAmplitudes) { mMinFrequencyHz = minFrequencyHz; mResonantFrequencyHz = resonantFrequencyHz; Loading Loading @@ -776,10 +776,10 @@ public class VibratorInfo implements Parcelable { if (this == o) { return true; } if (!(o instanceof FrequencyProfile)) { if (!(o instanceof FrequencyProfileLegacy)) { return false; } FrequencyProfile that = (FrequencyProfile) o; FrequencyProfileLegacy that = (FrequencyProfileLegacy) o; return Float.compare(mMinFrequencyHz, that.mMinFrequencyHz) == 0 && Float.compare(mResonantFrequencyHz, that.mResonantFrequencyHz) == 0 && Float.compare(mFrequencyResolutionHz, that.mFrequencyResolutionHz) == 0 Loading @@ -796,7 +796,7 @@ public class VibratorInfo implements Parcelable { @Override public String toString() { return "FrequencyProfile{" return "FrequencyProfileLegacy{" + "mFrequencyRange=" + mFrequencyRangeHz + ", mMinFrequency=" + mMinFrequencyHz + ", mResonantFrequency=" + mResonantFrequencyHz Loading @@ -806,16 +806,16 @@ public class VibratorInfo implements Parcelable { } @NonNull public static final Creator<FrequencyProfile> CREATOR = new Creator<FrequencyProfile>() { public static final Creator<FrequencyProfileLegacy> CREATOR = new Creator<FrequencyProfileLegacy>() { @Override public FrequencyProfile createFromParcel(Parcel in) { return new FrequencyProfile(in); public FrequencyProfileLegacy createFromParcel(Parcel in) { return new FrequencyProfileLegacy(in); } @Override public FrequencyProfile[] newArray(int size) { return new FrequencyProfile[size]; public FrequencyProfileLegacy[] newArray(int size) { return new FrequencyProfileLegacy[size]; } }; } Loading @@ -832,8 +832,8 @@ public class VibratorInfo implements Parcelable { private int mPwlePrimitiveDurationMax; private int mPwleSizeMax; private float mQFactor = Float.NaN; private FrequencyProfile mFrequencyProfile = new FrequencyProfile(Float.NaN, Float.NaN, Float.NaN, null); private FrequencyProfileLegacy mFrequencyProfileLegacy = new FrequencyProfileLegacy(Float.NaN, Float.NaN, Float.NaN, null); private int mMaxEnvelopeEffectSize; private int mMinEnvelopeEffectControlPointDurationMillis; private int mMaxEnvelopeEffectControlPointDurationMillis; Loading Loading @@ -908,8 +908,8 @@ public class VibratorInfo implements Parcelable { /** Configure the vibrator frequency information like resonant frequency and bandwidth. */ @NonNull public Builder setFrequencyProfile(@NonNull FrequencyProfile frequencyProfile) { mFrequencyProfile = frequencyProfile; public Builder setFrequencyProfileLegacy(@NonNull FrequencyProfileLegacy frequencyProfile) { mFrequencyProfileLegacy = frequencyProfile; return this; } Loading Loading @@ -950,7 +950,7 @@ public class VibratorInfo implements Parcelable { public VibratorInfo build() { return new VibratorInfo(mId, mCapabilities, mSupportedEffects, mSupportedBraking, mSupportedPrimitives, mPrimitiveDelayMax, mCompositionSizeMax, mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfile, mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfileLegacy, mMaxEnvelopeEffectSize, mMinEnvelopeEffectControlPointDurationMillis, mMaxEnvelopeEffectControlPointDurationMillis); } Loading core/java/android/os/vibrator/MultiVibratorInfo.java +10 −10 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public final class MultiVibratorInfo extends VibratorInfo { } private MultiVibratorInfo( int id, VibratorInfo[] vibrators, VibratorInfo.FrequencyProfile mergedProfile) { int id, VibratorInfo[] vibrators, FrequencyProfileLegacy mergedProfile) { super(id, capabilitiesIntersection(vibrators, mergedProfile.isEmpty()), supportedEffectsIntersection(vibrators), Loading Loading @@ -209,15 +209,15 @@ public final class MultiVibratorInfo extends VibratorInfo { } @NonNull private static FrequencyProfile frequencyProfileIntersection(VibratorInfo[] infos) { private static FrequencyProfileLegacy frequencyProfileIntersection(VibratorInfo[] infos) { float freqResolution = floatPropertyIntersection(infos, info -> info.getFrequencyProfile().getFrequencyResolutionHz()); info -> info.getFrequencyProfileLegacy().getFrequencyResolutionHz()); float resonantFreq = floatPropertyIntersection(infos, VibratorInfo::getResonantFrequencyHz); Range<Float> freqRange = frequencyRangeIntersection(infos, freqResolution); if ((freqRange == null) || Float.isNaN(freqResolution)) { return new FrequencyProfile(resonantFreq, Float.NaN, freqResolution, null); return new FrequencyProfileLegacy(resonantFreq, Float.NaN, freqResolution, null); } int amplitudeCount = Loading @@ -230,8 +230,8 @@ public final class MultiVibratorInfo extends VibratorInfo { Arrays.fill(maxAmplitudes, Float.MAX_VALUE); for (VibratorInfo info : infos) { Range<Float> vibratorFreqRange = info.getFrequencyProfile().getFrequencyRangeHz(); float[] vibratorMaxAmplitudes = info.getFrequencyProfile().getMaxAmplitudes(); Range<Float> vibratorFreqRange = info.getFrequencyProfileLegacy().getFrequencyRangeHz(); float[] vibratorMaxAmplitudes = info.getFrequencyProfileLegacy().getMaxAmplitudes(); int vibratorStartIdx = Math.round( (freqRange.getLower() - vibratorFreqRange.getLower()) / freqResolution); int vibratorEndIdx = vibratorStartIdx + maxAmplitudes.length - 1; Loading @@ -240,7 +240,7 @@ public final class MultiVibratorInfo extends VibratorInfo { Slog.w(TAG, "Error calculating the intersection of vibrator frequency" + " profiles: attempted to fetch from vibrator " + info.getId() + " max amplitude with bad index " + vibratorStartIdx); return new FrequencyProfile(resonantFreq, Float.NaN, Float.NaN, null); return new FrequencyProfileLegacy(resonantFreq, Float.NaN, Float.NaN, null); } for (int i = 0; i < maxAmplitudes.length; i++) { Loading @@ -249,14 +249,14 @@ public final class MultiVibratorInfo extends VibratorInfo { } } return new FrequencyProfile(resonantFreq, freqRange.getLower(), return new FrequencyProfileLegacy(resonantFreq, freqRange.getLower(), freqResolution, maxAmplitudes); } @Nullable private static Range<Float> frequencyRangeIntersection(VibratorInfo[] infos, float frequencyResolution) { Range<Float> firstRange = infos[0].getFrequencyProfile().getFrequencyRangeHz(); Range<Float> firstRange = infos[0].getFrequencyProfileLegacy().getFrequencyRangeHz(); if (firstRange == null) { // If one vibrator is undefined then the intersection is undefined. return null; Loading @@ -268,7 +268,7 @@ public final class MultiVibratorInfo extends VibratorInfo { // min supported frequencies are aligned w.r.t. the frequency resolution. for (int i = 1; i < infos.length; i++) { Range<Float> vibratorRange = infos[i].getFrequencyProfile().getFrequencyRangeHz(); Range<Float> vibratorRange = infos[i].getFrequencyProfileLegacy().getFrequencyRangeHz(); if (vibratorRange == null) { // If one vibrator is undefined then the intersection is undefined. return null; Loading Loading
core/api/test-current.txt +2 −2 Original line number Diff line number Diff line Loading @@ -2603,7 +2603,7 @@ package android.os { public abstract class Vibrator { method public int getDefaultVibrationIntensity(int); method @Nullable public android.os.vibrator.VibratorFrequencyProfile getFrequencyProfile(); method @Nullable public android.os.vibrator.VibratorFrequencyProfileLegacy getFrequencyProfileLegacy(); method public boolean hasFrequencyControl(); field public static final int VIBRATION_INTENSITY_HIGH = 3; // 0x3 field public static final int VIBRATION_INTENSITY_LOW = 1; // 0x1 Loading Loading @@ -2793,7 +2793,7 @@ package android.os.vibrator { field @NonNull public static final android.os.Parcelable.Creator<android.os.vibrator.VibrationEffectSegment> CREATOR; } public final class VibratorFrequencyProfile { public final class VibratorFrequencyProfileLegacy { method public float getMaxAmplitudeMeasurementInterval(); method @FloatRange(from=0, to=1) @NonNull public float[] getMaxAmplitudeMeasurements(); method public float getMaxFrequency(); Loading
core/java/android/os/VibrationEffect.java +3 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.vibrator.PrimitiveSegment; import android.os.vibrator.RampSegment; import android.os.vibrator.StepSegment; import android.os.vibrator.VibrationEffectSegment; import android.os.vibrator.VibratorFrequencyProfileLegacy; import android.util.MathUtils; import com.android.internal.util.Preconditions; Loading Loading @@ -1761,7 +1762,7 @@ public abstract class VibrationEffect implements Parcelable { * new value as fast as possible. * * <p>Vibration parameter values will be truncated to conform to the device capabilities * according to the {@link android.os.vibrator.VibratorFrequencyProfile}. * according to the {@link VibratorFrequencyProfileLegacy}. * * @param duration The length of time this transition should take. Value must be * non-negative and will be truncated to milliseconds. Loading Loading @@ -1792,7 +1793,7 @@ public abstract class VibrationEffect implements Parcelable { * new values as fast as possible. * * <p>Vibration parameters values will be truncated to conform to the device capabilities * according to the {@link android.os.vibrator.VibratorFrequencyProfile}. * according to the {@link VibratorFrequencyProfileLegacy}. * * @param duration The length of time this transition should take. Value must be * non-negative and will be truncated to milliseconds. Loading
core/java/android/os/Vibrator.java +7 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.TestApi; Loading @@ -33,7 +34,7 @@ import android.hardware.vibrator.IVibrator; import android.media.AudioAttributes; import android.os.vibrator.Flags; import android.os.vibrator.VibrationConfig; import android.os.vibrator.VibratorFrequencyProfile; import android.os.vibrator.VibratorFrequencyProfileLegacy; import android.util.Log; import android.view.HapticFeedbackConstants; Loading Loading @@ -290,13 +291,15 @@ public abstract class Vibrator { * @hide */ @TestApi @SuppressLint("UnflaggedApi") @Nullable public VibratorFrequencyProfile getFrequencyProfile() { VibratorInfo.FrequencyProfile frequencyProfile = getInfo().getFrequencyProfile(); public VibratorFrequencyProfileLegacy getFrequencyProfileLegacy() { VibratorInfo.FrequencyProfileLegacy frequencyProfile = getInfo().getFrequencyProfileLegacy(); if (frequencyProfile.isEmpty()) { return null; } return new VibratorFrequencyProfile(frequencyProfile); return new VibratorFrequencyProfileLegacy(frequencyProfile); } /** Loading
core/java/android/os/VibratorInfo.java +32 −32 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class VibratorInfo implements Parcelable { private final int mPwlePrimitiveDurationMax; private final int mPwleSizeMax; private final float mQFactor; private final FrequencyProfile mFrequencyProfile; private final FrequencyProfileLegacy mFrequencyProfileLegacy; private final int mMaxEnvelopeEffectSize; private final int mMinEnvelopeEffectControlPointDurationMillis; private final int mMaxEnvelopeEffectControlPointDurationMillis; Loading @@ -75,7 +75,7 @@ public class VibratorInfo implements Parcelable { mPwlePrimitiveDurationMax = in.readInt(); mPwleSizeMax = in.readInt(); mQFactor = in.readFloat(); mFrequencyProfile = FrequencyProfile.CREATOR.createFromParcel(in); mFrequencyProfileLegacy = FrequencyProfileLegacy.CREATOR.createFromParcel(in); mMaxEnvelopeEffectSize = in.readInt(); mMinEnvelopeEffectControlPointDurationMillis = in.readInt(); mMaxEnvelopeEffectControlPointDurationMillis = in.readInt(); Loading @@ -86,7 +86,7 @@ public class VibratorInfo implements Parcelable { baseVibratorInfo.mSupportedBraking, baseVibratorInfo.mSupportedPrimitives, baseVibratorInfo.mPrimitiveDelayMax, baseVibratorInfo.mCompositionSizeMax, baseVibratorInfo.mPwlePrimitiveDurationMax, baseVibratorInfo.mPwleSizeMax, baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfile, baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfileLegacy, baseVibratorInfo.mMaxEnvelopeEffectSize, baseVibratorInfo.mMinEnvelopeEffectControlPointDurationMillis, baseVibratorInfo.mMaxEnvelopeEffectControlPointDurationMillis); Loading @@ -112,7 +112,7 @@ public class VibratorInfo implements Parcelable { * @param pwleSizeMax The maximum number of primitives supported by a PWLE * composition. * @param qFactor The vibrator quality factor. * @param frequencyProfile The description of the vibrator supported frequencies and max * @param frequencyProfileLegacy The description of the vibrator supported frequencies and max * amplitude mappings. * @hide */ Loading @@ -120,11 +120,11 @@ public class VibratorInfo implements Parcelable { @Nullable SparseBooleanArray supportedBraking, @NonNull SparseIntArray supportedPrimitives, int primitiveDelayMax, int compositionSizeMax, int pwlePrimitiveDurationMax, int pwleSizeMax, float qFactor, @NonNull FrequencyProfile frequencyProfile, float qFactor, @NonNull FrequencyProfileLegacy frequencyProfileLegacy, int maxEnvelopeEffectSize, int minEnvelopeEffectControlPointDurationMillis, int maxEnvelopeEffectControlPointDurationMillis) { Preconditions.checkNotNull(supportedPrimitives); Preconditions.checkNotNull(frequencyProfile); Preconditions.checkNotNull(frequencyProfileLegacy); mId = id; mCapabilities = capabilities; mSupportedEffects = supportedEffects == null ? null : supportedEffects.clone(); Loading @@ -135,7 +135,7 @@ public class VibratorInfo implements Parcelable { mPwlePrimitiveDurationMax = pwlePrimitiveDurationMax; mPwleSizeMax = pwleSizeMax; mQFactor = qFactor; mFrequencyProfile = frequencyProfile; mFrequencyProfileLegacy = frequencyProfileLegacy; mMaxEnvelopeEffectSize = maxEnvelopeEffectSize; mMinEnvelopeEffectControlPointDurationMillis = minEnvelopeEffectControlPointDurationMillis; Loading @@ -155,7 +155,7 @@ public class VibratorInfo implements Parcelable { dest.writeInt(mPwlePrimitiveDurationMax); dest.writeInt(mPwleSizeMax); dest.writeFloat(mQFactor); mFrequencyProfile.writeToParcel(dest, flags); mFrequencyProfileLegacy.writeToParcel(dest, flags); dest.writeInt(mMaxEnvelopeEffectSize); dest.writeInt(mMinEnvelopeEffectControlPointDurationMillis); dest.writeInt(mMaxEnvelopeEffectControlPointDurationMillis); Loading Loading @@ -205,7 +205,7 @@ public class VibratorInfo implements Parcelable { && Objects.equals(mSupportedEffects, that.mSupportedEffects) && Objects.equals(mSupportedBraking, that.mSupportedBraking) && Objects.equals(mQFactor, that.mQFactor) && Objects.equals(mFrequencyProfile, that.mFrequencyProfile) && Objects.equals(mFrequencyProfileLegacy, that.mFrequencyProfileLegacy) && mMaxEnvelopeEffectSize == that.mMaxEnvelopeEffectSize && mMinEnvelopeEffectControlPointDurationMillis == that.mMinEnvelopeEffectControlPointDurationMillis Loading @@ -216,7 +216,7 @@ public class VibratorInfo implements Parcelable { @Override public int hashCode() { int hashCode = Objects.hash(mId, mCapabilities, mSupportedEffects, mSupportedBraking, mQFactor, mFrequencyProfile); mQFactor, mFrequencyProfileLegacy); for (int i = 0; i < mSupportedPrimitives.size(); i++) { hashCode = 31 * hashCode + mSupportedPrimitives.keyAt(i); hashCode = 31 * hashCode + mSupportedPrimitives.valueAt(i); Loading @@ -238,7 +238,7 @@ public class VibratorInfo implements Parcelable { + ", mPwlePrimitiveDurationMax=" + mPwlePrimitiveDurationMax + ", mPwleSizeMax=" + mPwleSizeMax + ", mQFactor=" + mQFactor + ", mFrequencyProfile=" + mFrequencyProfile + ", mFrequencyProfileLegacy=" + mFrequencyProfileLegacy + ", mMaxEnvelopeEffectSize=" + mMaxEnvelopeEffectSize + ", mMinEnvelopeEffectControlPointDurationMillis=" + mMinEnvelopeEffectControlPointDurationMillis Loading @@ -262,7 +262,7 @@ public class VibratorInfo implements Parcelable { pw.println("pwlePrimitiveDurationMax = " + mPwlePrimitiveDurationMax); pw.println("pwleSizeMax = " + mPwleSizeMax); pw.println("q-factor = " + mQFactor); pw.println("frequencyProfile = " + mFrequencyProfile); pw.println("frequencyProfileLegacy = " + mFrequencyProfileLegacy); pw.println("mMaxEnvelopeEffectSize = " + mMaxEnvelopeEffectSize); pw.println("mMinEnvelopeEffectControlPointDurationMillis = " + mMinEnvelopeEffectControlPointDurationMillis); Loading Loading @@ -517,7 +517,7 @@ public class VibratorInfo implements Parcelable { * this vibrator is a composite of multiple physical devices. */ public float getResonantFrequencyHz() { return mFrequencyProfile.mResonantFrequencyHz; return mFrequencyProfileLegacy.mResonantFrequencyHz; } /** Loading @@ -537,8 +537,8 @@ public class VibratorInfo implements Parcelable { * <p>If the devices does not have frequency control then the profile should be empty. */ @NonNull public FrequencyProfile getFrequencyProfile() { return mFrequencyProfile; public FrequencyProfileLegacy getFrequencyProfileLegacy() { return mFrequencyProfileLegacy; } /** Returns a single int representing all the capabilities of the vibrator. */ Loading Loading @@ -640,7 +640,7 @@ public class VibratorInfo implements Parcelable { * * @hide */ public static final class FrequencyProfile implements Parcelable { public static final class FrequencyProfileLegacy implements Parcelable { @Nullable private final Range<Float> mFrequencyRangeHz; private final float mMinFrequencyHz; Loading @@ -648,7 +648,7 @@ public class VibratorInfo implements Parcelable { private final float mFrequencyResolutionHz; private final float[] mMaxAmplitudes; FrequencyProfile(Parcel in) { FrequencyProfileLegacy(Parcel in) { this(in.readFloat(), in.readFloat(), in.readFloat(), in.createFloatArray()); } Loading @@ -664,7 +664,7 @@ public class VibratorInfo implements Parcelable { * resolution. * @hide */ public FrequencyProfile(float resonantFrequencyHz, float minFrequencyHz, public FrequencyProfileLegacy(float resonantFrequencyHz, float minFrequencyHz, float frequencyResolutionHz, float[] maxAmplitudes) { mMinFrequencyHz = minFrequencyHz; mResonantFrequencyHz = resonantFrequencyHz; Loading Loading @@ -776,10 +776,10 @@ public class VibratorInfo implements Parcelable { if (this == o) { return true; } if (!(o instanceof FrequencyProfile)) { if (!(o instanceof FrequencyProfileLegacy)) { return false; } FrequencyProfile that = (FrequencyProfile) o; FrequencyProfileLegacy that = (FrequencyProfileLegacy) o; return Float.compare(mMinFrequencyHz, that.mMinFrequencyHz) == 0 && Float.compare(mResonantFrequencyHz, that.mResonantFrequencyHz) == 0 && Float.compare(mFrequencyResolutionHz, that.mFrequencyResolutionHz) == 0 Loading @@ -796,7 +796,7 @@ public class VibratorInfo implements Parcelable { @Override public String toString() { return "FrequencyProfile{" return "FrequencyProfileLegacy{" + "mFrequencyRange=" + mFrequencyRangeHz + ", mMinFrequency=" + mMinFrequencyHz + ", mResonantFrequency=" + mResonantFrequencyHz Loading @@ -806,16 +806,16 @@ public class VibratorInfo implements Parcelable { } @NonNull public static final Creator<FrequencyProfile> CREATOR = new Creator<FrequencyProfile>() { public static final Creator<FrequencyProfileLegacy> CREATOR = new Creator<FrequencyProfileLegacy>() { @Override public FrequencyProfile createFromParcel(Parcel in) { return new FrequencyProfile(in); public FrequencyProfileLegacy createFromParcel(Parcel in) { return new FrequencyProfileLegacy(in); } @Override public FrequencyProfile[] newArray(int size) { return new FrequencyProfile[size]; public FrequencyProfileLegacy[] newArray(int size) { return new FrequencyProfileLegacy[size]; } }; } Loading @@ -832,8 +832,8 @@ public class VibratorInfo implements Parcelable { private int mPwlePrimitiveDurationMax; private int mPwleSizeMax; private float mQFactor = Float.NaN; private FrequencyProfile mFrequencyProfile = new FrequencyProfile(Float.NaN, Float.NaN, Float.NaN, null); private FrequencyProfileLegacy mFrequencyProfileLegacy = new FrequencyProfileLegacy(Float.NaN, Float.NaN, Float.NaN, null); private int mMaxEnvelopeEffectSize; private int mMinEnvelopeEffectControlPointDurationMillis; private int mMaxEnvelopeEffectControlPointDurationMillis; Loading Loading @@ -908,8 +908,8 @@ public class VibratorInfo implements Parcelable { /** Configure the vibrator frequency information like resonant frequency and bandwidth. */ @NonNull public Builder setFrequencyProfile(@NonNull FrequencyProfile frequencyProfile) { mFrequencyProfile = frequencyProfile; public Builder setFrequencyProfileLegacy(@NonNull FrequencyProfileLegacy frequencyProfile) { mFrequencyProfileLegacy = frequencyProfile; return this; } Loading Loading @@ -950,7 +950,7 @@ public class VibratorInfo implements Parcelable { public VibratorInfo build() { return new VibratorInfo(mId, mCapabilities, mSupportedEffects, mSupportedBraking, mSupportedPrimitives, mPrimitiveDelayMax, mCompositionSizeMax, mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfile, mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfileLegacy, mMaxEnvelopeEffectSize, mMinEnvelopeEffectControlPointDurationMillis, mMaxEnvelopeEffectControlPointDurationMillis); } Loading
core/java/android/os/vibrator/MultiVibratorInfo.java +10 −10 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ public final class MultiVibratorInfo extends VibratorInfo { } private MultiVibratorInfo( int id, VibratorInfo[] vibrators, VibratorInfo.FrequencyProfile mergedProfile) { int id, VibratorInfo[] vibrators, FrequencyProfileLegacy mergedProfile) { super(id, capabilitiesIntersection(vibrators, mergedProfile.isEmpty()), supportedEffectsIntersection(vibrators), Loading Loading @@ -209,15 +209,15 @@ public final class MultiVibratorInfo extends VibratorInfo { } @NonNull private static FrequencyProfile frequencyProfileIntersection(VibratorInfo[] infos) { private static FrequencyProfileLegacy frequencyProfileIntersection(VibratorInfo[] infos) { float freqResolution = floatPropertyIntersection(infos, info -> info.getFrequencyProfile().getFrequencyResolutionHz()); info -> info.getFrequencyProfileLegacy().getFrequencyResolutionHz()); float resonantFreq = floatPropertyIntersection(infos, VibratorInfo::getResonantFrequencyHz); Range<Float> freqRange = frequencyRangeIntersection(infos, freqResolution); if ((freqRange == null) || Float.isNaN(freqResolution)) { return new FrequencyProfile(resonantFreq, Float.NaN, freqResolution, null); return new FrequencyProfileLegacy(resonantFreq, Float.NaN, freqResolution, null); } int amplitudeCount = Loading @@ -230,8 +230,8 @@ public final class MultiVibratorInfo extends VibratorInfo { Arrays.fill(maxAmplitudes, Float.MAX_VALUE); for (VibratorInfo info : infos) { Range<Float> vibratorFreqRange = info.getFrequencyProfile().getFrequencyRangeHz(); float[] vibratorMaxAmplitudes = info.getFrequencyProfile().getMaxAmplitudes(); Range<Float> vibratorFreqRange = info.getFrequencyProfileLegacy().getFrequencyRangeHz(); float[] vibratorMaxAmplitudes = info.getFrequencyProfileLegacy().getMaxAmplitudes(); int vibratorStartIdx = Math.round( (freqRange.getLower() - vibratorFreqRange.getLower()) / freqResolution); int vibratorEndIdx = vibratorStartIdx + maxAmplitudes.length - 1; Loading @@ -240,7 +240,7 @@ public final class MultiVibratorInfo extends VibratorInfo { Slog.w(TAG, "Error calculating the intersection of vibrator frequency" + " profiles: attempted to fetch from vibrator " + info.getId() + " max amplitude with bad index " + vibratorStartIdx); return new FrequencyProfile(resonantFreq, Float.NaN, Float.NaN, null); return new FrequencyProfileLegacy(resonantFreq, Float.NaN, Float.NaN, null); } for (int i = 0; i < maxAmplitudes.length; i++) { Loading @@ -249,14 +249,14 @@ public final class MultiVibratorInfo extends VibratorInfo { } } return new FrequencyProfile(resonantFreq, freqRange.getLower(), return new FrequencyProfileLegacy(resonantFreq, freqRange.getLower(), freqResolution, maxAmplitudes); } @Nullable private static Range<Float> frequencyRangeIntersection(VibratorInfo[] infos, float frequencyResolution) { Range<Float> firstRange = infos[0].getFrequencyProfile().getFrequencyRangeHz(); Range<Float> firstRange = infos[0].getFrequencyProfileLegacy().getFrequencyRangeHz(); if (firstRange == null) { // If one vibrator is undefined then the intersection is undefined. return null; Loading @@ -268,7 +268,7 @@ public final class MultiVibratorInfo extends VibratorInfo { // min supported frequencies are aligned w.r.t. the frequency resolution. for (int i = 1; i < infos.length; i++) { Range<Float> vibratorRange = infos[i].getFrequencyProfile().getFrequencyRangeHz(); Range<Float> vibratorRange = infos[i].getFrequencyProfileLegacy().getFrequencyRangeHz(); if (vibratorRange == null) { // If one vibrator is undefined then the intersection is undefined. return null; Loading