summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wilson Wu <wilsonwu@google.com> 2025-02-14 09:09:43 +0000
committer Wilson Wu <wilsonwu@google.com> 2025-02-14 09:34:17 +0000
commit7f8e2cd20cef04afeabd19fdb4b2cfd7506c644c (patch)
treef641d2e63bd7fc4c15c988e8d90e78352cb36fdb
parentfa1ef40638b525d30eb0f66181e21f0af1084afe (diff)
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
-rw-r--r--core/api/test-current.txt6
-rw-r--r--media/java/android/media/Utils.java34
2 files changed, 40 insertions, 0 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 9e9e3c2f13c1..ba186ad7fff9 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -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();
diff --git a/media/java/android/media/Utils.java b/media/java/android/media/Utils.java
index d6e27b0ffa75..9db527bfaa2d 100644
--- a/media/java/android/media/Utils.java
+++ b/media/java/android/media/Utils.java
@@ -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) {