summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hyundo Moon <hdmoon@google.com> 2017-03-09 15:26:39 +0900
committer Hyundo Moon <hdmoon@google.com> 2017-03-10 19:27:16 +0900
commitb0b212014bbff37e61c8bdde4081c55bdfe36f12 (patch)
tree0c9ed138f0a732a8a959387ba31d38ad078d5929
parentd5386fd4ef6cddd9dbc9f3f157d2a09a8577b545 (diff)
Throw IllegalStateException in MediaBrowser.search()
This CL makes MediaBrowser.search() throw IllegalStateException when the browser is not connected to the service. Bug: 35346000 Test: Flashed the image on angler and locally tested. Change-Id: I8fda53e31555337107c4e42f388ff82a7929b084
-rw-r--r--media/java/android/media/browse/MediaBrowser.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/media/java/android/media/browse/MediaBrowser.java b/media/java/android/media/browse/MediaBrowser.java
index 81db37ea3ad8..7122eaf3563b 100644
--- a/media/java/android/media/browse/MediaBrowser.java
+++ b/media/java/android/media/browse/MediaBrowser.java
@@ -471,6 +471,7 @@ public final class MediaBrowser {
* @param extras The bundle of service-specific arguments to send to the media browser
* service. The contents of this bundle may affect the search result.
* @param callback The callback to receive the search result.
+ * @throws IllegalStateException if the browser is not connected to the media browser service.
*/
public void search(@NonNull final String query, final Bundle extras, SearchCallback callback) {
if (TextUtils.isEmpty(query)) {
@@ -480,14 +481,8 @@ public final class MediaBrowser {
throw new IllegalArgumentException("callback cannot be null.");
}
if (mState != CONNECT_STATE_CONNECTED) {
- Log.i(TAG, "Not connected, unable to search.");
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- callback.onError(query, extras);
- }
- });
- return;
+ throw new IllegalStateException("search() called while not connected (state="
+ + getStateLabel(mState) + ")");
}
ResultReceiver receiver = new ResultReceiver(mHandler) {
@Override