summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sungsoo Lim <sungsoo@google.com> 2019-01-22 15:38:29 +0900
committer Sungsoo Lim <sungsoo@google.com> 2019-01-23 13:46:09 +0900
commit6003d8f4f653d9edecece1278bb2a87c4a336815 (patch)
tree0bdcd922c93f4978efe367b5042421b706f22c5b
parentf1cef973457809c9f8563c6119006dbe1e1d87ce (diff)
Allow onSessionCommand return null
Bug: 123206059 Test: atest -t CtsMediaTestCases:android.media.cts.MediaSession2Test Change-Id: Iab51c2e618f67bf7cf6b17ae33b379c5c3a4b677
-rw-r--r--media/java/android/media/MediaController2.java6
-rw-r--r--media/java/android/media/MediaSession2.java6
2 files changed, 6 insertions, 6 deletions
diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java
index dd971959dd25..28e6637e76ce 100644
--- a/media/java/android/media/MediaController2.java
+++ b/media/java/android/media/MediaController2.java
@@ -316,7 +316,7 @@ public class MediaController2 implements AutoCloseable {
MediaController2.this, command, args);
if (resultReceiver != null) {
if (result == null) {
- throw new RuntimeException("onSessionCommand shouldn't return null");
+ resultReceiver.send(Session2Command.RESULT_INFO_SKIPPED, null);
} else {
resultReceiver.send(result.getResultCode(), result.getResultData());
}
@@ -433,8 +433,8 @@ public class MediaController2 implements AutoCloseable {
* @param controller the controller for this event
* @param command the session command
* @param args optional arguments
- * @return the result for the session command. A runtime exception will be thrown if null
- * is returned.
+ * @return the result for the session command. If {@code null}, RESULT_INFO_SKIPPED
+ * will be sent to the session.
*/
@Nullable
public Session2Command.Result onSessionCommand(@NonNull MediaController2 controller,
diff --git a/media/java/android/media/MediaSession2.java b/media/java/android/media/MediaSession2.java
index 3adac7295fff..4ec25ce0dd5e 100644
--- a/media/java/android/media/MediaSession2.java
+++ b/media/java/android/media/MediaSession2.java
@@ -373,7 +373,7 @@ public class MediaSession2 implements AutoCloseable {
MediaSession2.this, controllerInfo, command, args);
if (resultReceiver != null) {
if (result == null) {
- throw new RuntimeException("onSessionCommand shouldn't return null");
+ resultReceiver.send(Session2Command.RESULT_INFO_SKIPPED, null);
} else {
resultReceiver.send(result.getResultCode(), result.getResultData());
}
@@ -731,8 +731,8 @@ public class MediaSession2 implements AutoCloseable {
* @param controller controller information
* @param command the session command
* @param args optional arguments
- * @return the result for the session command. A runtime exception will be thrown if null
- * is returned.
+ * @return the result for the session command. If {@code null}, RESULT_INFO_SKIPPED
+ * will be sent to the session.
*/
@Nullable
public Session2Command.Result onSessionCommand(@NonNull MediaSession2 session,