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

Commit 7f8e2cd2 authored by Wilson Wu's avatar Wilson Wu
Browse files

Add test API for Telecomm cts testing

The Ringer CTS test cannot access the @hide API
under android/media/Utils.

Add TestAPi annotation for following:
-. VIBRATION_URI_PARAM
-. SYNCHRONIZED_VIBRATION

Flag: EXEMPT TEST_ONLY
Bug: 394231980
Test: presubmit
Change-Id: Iaf32e3fb530f800260f5a8ca98b708c88655e424
parent fa1ef406
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2115,6 +2115,12 @@ package android.media {
    method public android.media.PlaybackParams setAudioStretchMode(int);
  }

  public class Utils {
    ctor public Utils();
    field public static final String SYNCHRONIZED_VIBRATION = "synchronized";
    field public static final String VIBRATION_URI_PARAM = "vibration_uri";
  }

  public final class VolumePolicy implements android.os.Parcelable {
    ctor public VolumePolicy(boolean, boolean, boolean, int);
    method public int describeContents();
+34 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.media;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
@@ -61,16 +63,30 @@ import java.util.concurrent.Executor;
 *
 * @hide
 */
@TestApi
@SuppressLint({"UnflaggedApi", "StaticUtils"}) // Test API
public class Utils {
    private static final String TAG = "Utils";

    /** @hide
     * The vibration uri key parameter
     */
    @TestApi
    @SuppressLint("UnflaggedApi") // Test API
    public static final String VIBRATION_URI_PARAM = "vibration_uri";

    /** @hide
     * Indicates the synchronized vibration
     */
    @TestApi
    @SuppressLint("UnflaggedApi") // Test API
    public static final String SYNCHRONIZED_VIBRATION = "synchronized";

    /**
     * Sorts distinct (non-intersecting) range array in ascending order.
     * @throws java.lang.IllegalArgumentException if ranges are not distinct
     *
     * @hide
     */
    public static <T extends Comparable<? super T>> void sortDistinctRanges(Range<T>[] ranges) {
        Arrays.sort(ranges, new Comparator<Range<T>>() {
@@ -92,6 +108,8 @@ public class Utils {
     * @param one a sorted set of non-intersecting ranges in ascending order
     * @param another another sorted set of non-intersecting ranges in ascending order
     * @return the intersection of the two sets, sorted in ascending order
     *
     * @hide
     */
    public static <T extends Comparable<? super T>>
            Range<T>[] intersectSortedDistinctRanges(Range<T>[] one, Range<T>[] another) {
@@ -124,6 +142,8 @@ public class Utils {
     * @return if the value is in one of the ranges, it returns the index of that range.  Otherwise,
     * the return value is {@code (-1-index)} for the {@code index} of the range that is
     * immediately following {@code value}.
     *
     * @hide
     */
    public static <T extends Comparable<? super T>>
            int binarySearchDistinctRanges(Range<T>[] ranges, T value) {
@@ -358,6 +378,8 @@ public class Utils {
     * @param fileName desired name for the file.
     * @param mimeType MIME type of the file to create.
     * @return the File object in the storage, or null if an error occurs.
     *
     * @hide
     */
    public static File getUniqueExternalFile(Context context, String subdirectory, String fileName,
            String mimeType) {
@@ -676,6 +698,8 @@ public class Utils {
     * Must match the implementation of BluetoothUtils.toAnonymizedAddress()
     * @param address MAC address to be anonymized
     * @return anonymized MAC address
     *
     * @hide
     */
    public static @Nullable String anonymizeBluetoothAddress(@Nullable String address) {
        if (address == null) {
@@ -693,6 +717,8 @@ public class Utils {
     * @param deviceType the internal type of the audio device
     * @param address MAC address to be anonymized
     * @return anonymized MAC address
     *
     * @hide
     */
    public static @Nullable String anonymizeBluetoothAddress(
            int deviceType, @Nullable String address) {
@@ -707,6 +733,8 @@ public class Utils {
     *
     * @param context the {@link Context}
     * @return {@code true} if the device supports ringtone vibration
     *
     * @hide
     */
    public static boolean isRingtoneVibrationSettingsSupported(Context context) {
        final Resources res = context.getResources();
@@ -719,6 +747,8 @@ public class Utils {
     *
     * @param ringtoneUri the ringtone Uri
     * @return {@code true} if the Uri has vibration parameter
     *
     * @hide
     */
    public static boolean hasVibration(Uri ringtoneUri) {
        if (ringtoneUri == null) {
@@ -734,6 +764,8 @@ public class Utils {
     * @param ringtoneUri the ringtone Uri
     * @return parsed {@link Uri} of vibration parameter, {@code null} if the vibration parameter
     * is not found.
     *
     * @hide
     */
    public static @Nullable Uri getVibrationUri(Uri ringtoneUri) {
        if (ringtoneUri == null) {
@@ -751,6 +783,8 @@ public class Utils {
     *
     * @param vibrator the vibrator to resolve the vibration file
     * @param vibrationUri the vibration file Uri to represent a vibration
     *
     * @hide
     */
    @SuppressWarnings("FlaggedApi") // VibrationXmlParser is available internally as hidden APIs.
    public static VibrationEffect parseVibrationEffect(Vibrator vibrator, Uri vibrationUri) {