Move Util.getErrorCodeFromPlatformDiagnosticsInfo into common
Will be needed for error code assignment. PiperOrigin-RevId: 382305328
This commit is contained in:
parent
7b0a7f1295
commit
2ca7432bf6
@ -145,6 +145,9 @@ public final class Util {
|
|||||||
+ "(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$");
|
+ "(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$");
|
||||||
private static final Pattern ESCAPED_CHARACTER_PATTERN = Pattern.compile("%([A-Fa-f0-9]{2})");
|
private static final Pattern ESCAPED_CHARACTER_PATTERN = Pattern.compile("%([A-Fa-f0-9]{2})");
|
||||||
|
|
||||||
|
/** Pattern to extract error code from platform diagnostics info. */
|
||||||
|
private static final Pattern DIAGNOSTIC_INFO_CODE_PATTERN = Pattern.compile(".*?_(neg_|)(\\d+)");
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-deliver-content-overview#URLs.
|
// https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-deliver-content-overview#URLs.
|
||||||
private static final Pattern ISM_URL_PATTERN = Pattern.compile(".*\\.isml?(?:/(manifest(.*))?)?");
|
private static final Pattern ISM_URL_PATTERN = Pattern.compile(".*\\.isml?(?:/(manifest(.*))?)?");
|
||||||
private static final String ISM_HLS_FORMAT_EXTENSION = "format=m3u8-aapl";
|
private static final String ISM_HLS_FORMAT_EXTENSION = "format=m3u8-aapl";
|
||||||
@ -2377,6 +2380,26 @@ public final class Util {
|
|||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to parse an error code from a diagnostic string found in framework media exceptions.
|
||||||
|
* For example: android.media.MediaCodec.error_1 or android.media.MediaDrm.error_neg_2.
|
||||||
|
*/
|
||||||
|
public static int getErrorCodeFromPlatformDiagnosticsInfo(@Nullable String diagnosticsInfo) {
|
||||||
|
if (diagnosticsInfo == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Matcher matcher = DIAGNOSTIC_INFO_CODE_PATTERN.matcher(diagnosticsInfo);
|
||||||
|
if (!matcher.matches()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int errorCode = Integer.parseInt(Assertions.checkNotNull(matcher.group(2)));
|
||||||
|
return Assertions.checkNotNull(matcher.group(1)).isEmpty() ? errorCode : -errorCode;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static String getSystemProperty(String name) {
|
private static String getSystemProperty(String name) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user