Exposing AudioAttributes#usageToString as public API

Bug: 159623196
Test: atest CtsMediaTestCases:android.media.cts.AudioAttributesTest
Change-Id: I111f78e4bb1e7cf193085c172db5520d25100d6e
This commit is contained in:
Antonio Kantek
2020-12-03 16:53:45 -08:00
parent 7afa84bb4d
commit 3935bdf708
2 changed files with 31 additions and 24 deletions

View File

@@ -24237,6 +24237,7 @@ package android.media {
method public int getFlags();
method public int getUsage();
method public int getVolumeControlStream();
method @NonNull public static String usageToString(int);
method public void writeToParcel(android.os.Parcel, int);
field public static final int ALLOW_CAPTURE_BY_ALL = 1; // 0x1
field public static final int ALLOW_CAPTURE_BY_NONE = 3; // 0x3

View File

@@ -1235,53 +1235,59 @@ public final class AudioAttributes implements Parcelable {
return usageToString(mUsage);
}
/** @hide */
public static String usageToString(int usage) {
/**
* Returns the string representation for the usage constant passed as parameter.
*
* @param usage one of the {@link AudioAttributes} usage constants
* @return string representing the {@link AudioAttributes} usage constant passed as a parameter
*/
@NonNull
public static String usageToString(@AttributeSdkUsage int usage) {
switch(usage) {
case USAGE_UNKNOWN:
return new String("USAGE_UNKNOWN");
return "USAGE_UNKNOWN";
case USAGE_MEDIA:
return new String("USAGE_MEDIA");
return "USAGE_MEDIA";
case USAGE_VOICE_COMMUNICATION:
return new String("USAGE_VOICE_COMMUNICATION");
return "USAGE_VOICE_COMMUNICATION";
case USAGE_VOICE_COMMUNICATION_SIGNALLING:
return new String("USAGE_VOICE_COMMUNICATION_SIGNALLING");
return "USAGE_VOICE_COMMUNICATION_SIGNALLING";
case USAGE_ALARM:
return new String("USAGE_ALARM");
return "USAGE_ALARM";
case USAGE_NOTIFICATION:
return new String("USAGE_NOTIFICATION");
return "USAGE_NOTIFICATION";
case USAGE_NOTIFICATION_RINGTONE:
return new String("USAGE_NOTIFICATION_RINGTONE");
return "USAGE_NOTIFICATION_RINGTONE";
case USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
return new String("USAGE_NOTIFICATION_COMMUNICATION_REQUEST");
return "USAGE_NOTIFICATION_COMMUNICATION_REQUEST";
case USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
return new String("USAGE_NOTIFICATION_COMMUNICATION_INSTANT");
return "USAGE_NOTIFICATION_COMMUNICATION_INSTANT";
case USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
return new String("USAGE_NOTIFICATION_COMMUNICATION_DELAYED");
return "USAGE_NOTIFICATION_COMMUNICATION_DELAYED";
case USAGE_NOTIFICATION_EVENT:
return new String("USAGE_NOTIFICATION_EVENT");
return "USAGE_NOTIFICATION_EVENT";
case USAGE_ASSISTANCE_ACCESSIBILITY:
return new String("USAGE_ASSISTANCE_ACCESSIBILITY");
return "USAGE_ASSISTANCE_ACCESSIBILITY";
case USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
return new String("USAGE_ASSISTANCE_NAVIGATION_GUIDANCE");
return "USAGE_ASSISTANCE_NAVIGATION_GUIDANCE";
case USAGE_ASSISTANCE_SONIFICATION:
return new String("USAGE_ASSISTANCE_SONIFICATION");
return "USAGE_ASSISTANCE_SONIFICATION";
case USAGE_GAME:
return new String("USAGE_GAME");
return "USAGE_GAME";
case USAGE_ASSISTANT:
return new String("USAGE_ASSISTANT");
return "USAGE_ASSISTANT";
case USAGE_CALL_ASSISTANT:
return new String("USAGE_CALL_ASSISTANT");
return "USAGE_CALL_ASSISTANT";
case USAGE_EMERGENCY:
return new String("USAGE_EMERGENCY");
return "USAGE_EMERGENCY";
case USAGE_SAFETY:
return new String("USAGE_SAFETY");
return "USAGE_SAFETY";
case USAGE_VEHICLE_STATUS:
return new String("USAGE_VEHICLE_STATUS");
return "USAGE_VEHICLE_STATUS";
case USAGE_ANNOUNCEMENT:
return new String("USAGE_ANNOUNCEMENT");
return "USAGE_ANNOUNCEMENT";
default:
return new String("unknown usage " + usage);
return "unknown usage " + usage;
}
}