Handle media transcoding enqueue failures
If the media transcoding service is unavailable, enqueing transcoding
requests will fail. Because of the early failure, we wouldn't have
created a transcoding session. This caused an NPE.
Now, we handle null transcoding sessions and log metrics as failed in
those cases
Bug: 188740213
Test: Manual
Change-Id: I5c115a1636a4b10815e323ccaf804f3fbe1c0637
diff --git a/src/com/android/providers/media/TranscodeHelper.java b/src/com/android/providers/media/TranscodeHelper.java
index e1ffbca..9a74ddc 100644
--- a/src/com/android/providers/media/TranscodeHelper.java
+++ b/src/com/android/providers/media/TranscodeHelper.java
@@ -437,8 +437,8 @@
CountDownLatch latch = null;
long startTime = SystemClock.elapsedRealtime();
boolean result = false;
- int errorCode = TranscodingSession.ERROR_NONE;
- int failureReason = TRANSCODING_DATA__FAILURE_CAUSE__CAUSE_UNKNOWN;
+ int errorCode = TranscodingSession.ERROR_SERVICE_DIED;
+ int failureReason = TRANSCODING_DATA__FAILURE_CAUSE__TRANSCODING_SERVICE_ERROR;
try {
synchronized (mLock) {
@@ -481,6 +481,16 @@
transcodingSession.cancel();
}
} finally {
+ if (storageSession == null) {
+ Log.w(TAG, "Failed to create a StorageTranscodingSession");
+ // We were unable to even queue the request. Which means the media service is
+ // in a very bad state
+ reportTranscodingResult(uid, result, errorCode, failureReason,
+ SystemClock.elapsedRealtime() - startTime, reason,
+ src, dst, false /* hasAnr */);
+ return false;
+ }
+
storageSession.notifyFinished(failureReason, errorCode);
if (errorCode == TranscodingSession.ERROR_DROPPED_BY_SERVICE) {
// If the transcoding service drops a request for a uid the uid will be denied