MediaCodec/Drm: move from getErrorCode to getDiagnosticInfo
Bug: 17059255
Change-Id: I9f5f0be61e94795d90ad29e94b3a1a6e6aedfb1d
diff --git a/api/current.txt b/api/current.txt
index ba8551a..8a04e4a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -14664,7 +14664,7 @@
}
public static final class MediaCodec.CodecException extends java.lang.IllegalStateException {
- method public int getErrorCode();
+ method public java.lang.String getDiagnosticInfo();
method public boolean isRecoverable();
method public boolean isTransient();
}
@@ -15002,7 +15002,7 @@
public static final class MediaDrm.MediaDrmStateException extends java.lang.IllegalStateException {
ctor public MediaDrm.MediaDrmStateException(int, java.lang.String);
- method public int getErrorCode();
+ method public java.lang.String getDiagnosticInfo();
}
public static abstract interface MediaDrm.OnEventListener {
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 81ebb14..1c7c9ea 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -672,6 +672,11 @@
super(detailMessage);
mErrorCode = errorCode;
mActionCode = actionCode;
+
+ // TODO get this from codec
+ final String sign = errorCode < 0 ? "neg_" : "";
+ mDiagnosticInfo =
+ "android.media.MediaCodec.error_" + sign + Math.abs(errorCode);
}
/**
@@ -696,15 +701,28 @@
* Retrieve the error code associated with a CodecException.
* This is opaque diagnostic information and may depend on
* hardware or API level.
+ *
+ * @hide
*/
public int getErrorCode() {
return mErrorCode;
}
+ /**
+ * Retrieve a human readable diagnostic information string
+ * associated with the exception. DO NOT SHOW THIS TO END-USERS!
+ * This string will not be localized or generally comprehensible
+ * to end-users.
+ */
+ public String getDiagnosticInfo() {
+ return mDiagnosticInfo;
+ }
+
/* Must be in sync with android_media_MediaCodec.cpp */
private final static int ACTION_TRANSIENT = 1;
private final static int ACTION_RECOVERABLE = 2;
+ private final String mDiagnosticInfo;
private final int mErrorCode;
private final int mActionCode;
}
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index ca707d8..1490732 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -188,18 +188,37 @@
*/
public static final class MediaDrmStateException extends java.lang.IllegalStateException {
private final int mErrorCode;
+ private final String mDiagnosticInfo;
public MediaDrmStateException(int errorCode, String detailMessage) {
super(detailMessage);
mErrorCode = errorCode;
+
+ // TODO get this from DRM session
+ final String sign = errorCode < 0 ? "neg_" : "";
+ mDiagnosticInfo =
+ "android.media.MediaDrm.error_" + sign + Math.abs(errorCode);
+
}
/**
* Retrieve the associated error code
+ *
+ * @hide
*/
public int getErrorCode() {
return mErrorCode;
}
+
+ /**
+ * Retrieve a human readable diagnostic information string
+ * associated with the exception. DO NOT SHOW THIS TO END-USERS!
+ * This string will not be localized or generally comprehensible
+ * to end-users.
+ */
+ public String getDiagnosticInfo() {
+ return mDiagnosticInfo;
+ }
}
/**