s/thumbnail/icon in the browsing api.
Change-Id: I73bf76ed9628872094db74aef48a8e68864d6b4d
diff --git a/api/current.txt b/api/current.txt
index b39f200..90c3994 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -16186,7 +16186,7 @@
method public android.net.Uri getRoot();
method public android.media.session.MediaSession.Token getSessionToken();
method public boolean isConnected();
- method public void loadThumbnail(android.net.Uri, int, int, android.media.browse.MediaBrowser.ThumbnailCallback);
+ method public void loadIcon(android.net.Uri, int, int, android.media.browse.MediaBrowser.IconCallback);
method public void subscribe(android.net.Uri, android.media.browse.MediaBrowser.SubscriptionCallback);
method public void unsubscribe(android.net.Uri);
}
@@ -16198,18 +16198,18 @@
method public void onConnectionSuspended();
}
+ public static abstract class MediaBrowser.IconCallback {
+ ctor public MediaBrowser.IconCallback();
+ method public void onError(android.net.Uri);
+ method public void onIconLoaded(android.net.Uri, android.graphics.Bitmap);
+ }
+
public static abstract class MediaBrowser.SubscriptionCallback {
ctor public MediaBrowser.SubscriptionCallback();
method public void onChildrenLoaded(android.net.Uri, java.util.List<android.media.browse.MediaBrowserItem>);
method public void onError(android.net.Uri);
}
- public static abstract class MediaBrowser.ThumbnailCallback {
- ctor public MediaBrowser.ThumbnailCallback();
- method public void onError(android.net.Uri);
- method public void onThumbnailLoaded(android.net.Uri, android.graphics.Bitmap);
- }
-
public final class MediaBrowserItem implements android.os.Parcelable {
method public int describeContents();
method public android.os.Bundle getExtras();
@@ -16244,7 +16244,7 @@
method public android.os.IBinder onBind(android.content.Intent);
method public abstract android.media.browse.MediaBrowserService.BrowserRoot onGetRoot(java.lang.String, int, android.os.Bundle);
method public abstract void onLoadChildren(android.net.Uri, android.media.browse.MediaBrowserService.Result<java.util.List<android.media.browse.MediaBrowserItem>>);
- method public abstract void onLoadThumbnail(android.net.Uri, int, int, android.media.browse.MediaBrowserService.Result<android.graphics.Bitmap>);
+ method public abstract void onLoadIcon(android.net.Uri, int, int, android.media.browse.MediaBrowserService.Result<android.graphics.Bitmap>);
method public void setSessionToken(android.media.session.MediaSession.Token);
field public static final java.lang.String SERVICE_ACTION = "android.media.browse.MediaBrowserService";
}
diff --git a/media/java/android/media/browse/IMediaBrowserService.aidl b/media/java/android/media/browse/IMediaBrowserService.aidl
index 5126f6bd..8acd724 100644
--- a/media/java/android/media/browse/IMediaBrowserService.aidl
+++ b/media/java/android/media/browse/IMediaBrowserService.aidl
@@ -18,6 +18,6 @@
void addSubscription(in Uri uri, IMediaBrowserServiceCallbacks callbacks);
void removeSubscription(in Uri uri, IMediaBrowserServiceCallbacks callbacks);
- void loadThumbnail(in int seqNum, in Uri uri, int width, int height,
+ void loadIcon(in int seqNum, in Uri uri, int width, int height,
IMediaBrowserServiceCallbacks callbacks);
}
\ No newline at end of file
diff --git a/media/java/android/media/browse/IMediaBrowserServiceCallbacks.aidl b/media/java/android/media/browse/IMediaBrowserServiceCallbacks.aidl
index f6d5dae..06fabcc 100644
--- a/media/java/android/media/browse/IMediaBrowserServiceCallbacks.aidl
+++ b/media/java/android/media/browse/IMediaBrowserServiceCallbacks.aidl
@@ -24,5 +24,5 @@
void onConnect(in Uri root, in MediaSession.Token session, in Bundle extras);
void onConnectFailed();
void onLoadChildren(in Uri uri, in ParceledListSlice list);
- void onLoadThumbnail(int seqNum, in Bitmap bitmap);
+ void onLoadIcon(int seqNum, in Bitmap bitmap);
}
diff --git a/media/java/android/media/browse/MediaBrowser.java b/media/java/android/media/browse/MediaBrowser.java
index f6ea360..858383e 100644
--- a/media/java/android/media/browse/MediaBrowser.java
+++ b/media/java/android/media/browse/MediaBrowser.java
@@ -67,8 +67,8 @@
private final Handler mHandler = new Handler();
private final ArrayMap<Uri,Subscription> mSubscriptions =
new ArrayMap<Uri, MediaBrowser.Subscription>();
- private final SparseArray<ThumbnailRequest> mThumbnailRequests =
- new SparseArray<ThumbnailRequest>();
+ private final SparseArray<IconRequest> mIconRequests =
+ new SparseArray<IconRequest>();
private int mState = CONNECT_STATE_DISCONNECTED;
private MediaServiceConnection mServiceConnection;
@@ -352,42 +352,42 @@
}
/**
- * Loads the thumbnail of a media item.
+ * Loads the icon of a media item.
*
- * @param uri The uri of the thumbnail.
+ * @param uri The uri of the Icon.
* @param width The preferred width of the icon in dp.
* @param height The preferred width of the icon in dp.
- * @param callback The callback to receive the thumbnail.
+ * @param callback The callback to receive the icon.
*/
- public void loadThumbnail(final @NonNull Uri uri, final int width, final int height,
- final @NonNull ThumbnailCallback callback) {
+ public void loadIcon(final @NonNull Uri uri, final int width, final int height,
+ final @NonNull IconCallback callback) {
if (uri == null) {
- throw new IllegalArgumentException("thumbnail uri cannot be null");
+ throw new IllegalArgumentException("Icon uri cannot be null");
}
if (callback == null) {
- throw new IllegalArgumentException("thumbnail callback cannot be null");
+ throw new IllegalArgumentException("Icon callback cannot be null");
}
mHandler.post(new Runnable() {
@Override
public void run() {
- for (int i = 0; i < mThumbnailRequests.size(); i++) {
- ThumbnailRequest existingRequest = mThumbnailRequests.valueAt(i);
+ for (int i = 0; i < mIconRequests.size(); i++) {
+ IconRequest existingRequest = mIconRequests.valueAt(i);
if (existingRequest.isSameRequest(uri, width, height)) {
existingRequest.addCallback(callback);
return;
}
}
final int seq = mNextSeq++;
- ThumbnailRequest request = new ThumbnailRequest(seq, uri, width, height);
+ IconRequest request = new IconRequest(seq, uri, width, height);
request.addCallback(callback);
- mThumbnailRequests.put(seq, request);
+ mIconRequests.put(seq, request);
if (mState == CONNECT_STATE_CONNECTED) {
try {
- mServiceBinder.loadThumbnail(seq, uri, width, height, mServiceCallbacks);
+ mServiceBinder.loadIcon(seq, uri, width, height, mServiceCallbacks);
} catch (RemoteException e) {
// Process is crashing. We will disconnect, and upon reconnect we will
- // automatically reload the thumbnails. So nothing to do here.
- Log.d(TAG, "loadThumbnail failed with RemoteException uri=" + uri);
+ // automatically reload the icons. So nothing to do here.
+ Log.d(TAG, "loadIcon failed with RemoteException uri=" + uri);
}
}
}
@@ -451,15 +451,15 @@
}
}
- for (int i = 0; i < mThumbnailRequests.size(); i++) {
- ThumbnailRequest request = mThumbnailRequests.valueAt(i);
+ for (int i = 0; i < mIconRequests.size(); i++) {
+ IconRequest request = mIconRequests.valueAt(i);
try {
- mServiceBinder.loadThumbnail(request.mSeq, request.mUri,
+ mServiceBinder.loadIcon(request.mSeq, request.mUri,
request.mWidth, request.mHeight, mServiceCallbacks);
} catch (RemoteException e) {
// Process is crashing. We will disconnect, and upon reconnect we will
// automatically reload. So nothing to do here.
- Log.d(TAG, "loadThumbnail failed with RemoteException request=" + request);
+ Log.d(TAG, "loadIcon failed with RemoteException request=" + request);
}
}
}
@@ -528,26 +528,26 @@
});
}
- private final void onLoadThumbnail(final IMediaBrowserServiceCallbacks callback,
+ private final void onLoadIcon(final IMediaBrowserServiceCallbacks callback,
final int seqNum, final Bitmap bitmap) {
mHandler.post(new Runnable() {
@Override
public void run() {
// Check that there hasn't been a disconnect or a different
// ServiceConnection.
- if (!isCurrent(callback, "onLoadThumbnail")) {
+ if (!isCurrent(callback, "onLoadIcon")) {
return;
}
- ThumbnailRequest request = mThumbnailRequests.get(seqNum);
+ IconRequest request = mIconRequests.get(seqNum);
if (request == null) {
- Log.d(TAG, "onLoadThumbnail called for seqNum=" + seqNum + " request="
+ Log.d(TAG, "onLoadIcon called for seqNum=" + seqNum + " request="
+ request + " but the request is not registered");
return;
}
- mThumbnailRequests.delete(seqNum);
- for (ThumbnailCallback thumbnailCallback : request.getCallbacks()) {
- thumbnailCallback.onThumbnailLoaded(request.mUri, bitmap);
+ mIconRequests.delete(seqNum);
+ for (IconCallback IconCallback : request.getCallbacks()) {
+ IconCallback.onIconLoaded(request.mUri, bitmap);
}
}
});
@@ -636,13 +636,13 @@
}
/**
- * Callbacks for thumbnail loading.
+ * Callbacks for icon loading.
*/
- public static abstract class ThumbnailCallback {
+ public static abstract class IconCallback {
/**
- * Called when the thumbnail is loaded.
+ * Called when the icon is loaded.
*/
- public void onThumbnailLoaded(@NonNull Uri uri, @NonNull Bitmap bitmap) {
+ public void onIconLoaded(@NonNull Uri uri, @NonNull Bitmap bitmap) {
}
/**
@@ -652,38 +652,38 @@
}
}
- private static class ThumbnailRequest {
+ private static class IconRequest {
final int mSeq;
final Uri mUri;
final int mWidth;
final int mHeight;
- final List<ThumbnailCallback> mCallbacks;
+ final List<IconCallback> mCallbacks;
/**
- * Constructs a thumbnail request.
+ * Constructs an icon request.
* @param seq The unique sequence number assigned to the request by the media browser.
- * @param uri The Uri for the thumbnail.
- * @param width The width for the thumbnail.
- * @param height The height for the thumbnail.
+ * @param uri The Uri for the icon.
+ * @param width The width for the icon.
+ * @param height The height for the icon.
*/
- ThumbnailRequest(int seq, @NonNull Uri uri, int width, int height) {
+ IconRequest(int seq, @NonNull Uri uri, int width, int height) {
if (uri == null) {
- throw new IllegalArgumentException("thumbnail uri cannot be null");
+ throw new IllegalArgumentException("Icon uri cannot be null");
}
this.mSeq = seq;
this.mUri = uri;
this.mWidth = width;
this.mHeight = height;
- mCallbacks = new ArrayList<ThumbnailCallback>();
+ mCallbacks = new ArrayList<IconCallback>();
}
/**
- * Adds a callback to the thumbnail request.
+ * Adds a callback to the icon request.
* If the callback already exists, it will not be added again.
*/
- public void addCallback(@NonNull ThumbnailCallback callback) {
+ public void addCallback(@NonNull IconCallback callback) {
if (callback == null) {
- throw new IllegalArgumentException("callback cannot be null in ThumbnailRequest");
+ throw new IllegalArgumentException("callback cannot be null in IconRequest");
}
if (!mCallbacks.contains(callback)) {
mCallbacks.add(callback);
@@ -691,7 +691,7 @@
}
/**
- * Checks if the thumbnail request has the same uri, width, and height as the given values.
+ * Checks if the icon request has the same uri, width, and height as the given values.
*/
public boolean isSameRequest(@Nullable Uri uri, int width, int height) {
return Objects.equals(mUri, uri) && mWidth == width && mHeight == height;
@@ -699,7 +699,7 @@
@Override
public String toString() {
- final StringBuilder sb = new StringBuilder("ThumbnailRequest{");
+ final StringBuilder sb = new StringBuilder("IconRequest{");
sb.append("uri=").append(mUri);
sb.append(", width=").append(mWidth);
sb.append(", height=").append(mHeight);
@@ -711,7 +711,7 @@
/**
* Gets an unmodifiable view of the list of callbacks associated with the request.
*/
- public List<ThumbnailCallback> getCallbacks() {
+ public List<IconCallback> getCallbacks() {
return Collections.unmodifiableList(mCallbacks);
}
}
@@ -843,10 +843,10 @@
}
@Override
- public void onLoadThumbnail(final int seqNum, final Bitmap bitmap) {
+ public void onLoadIcon(final int seqNum, final Bitmap bitmap) {
MediaBrowser mediaBrowser = mMediaBrowser.get();
if (mediaBrowser != null) {
- mediaBrowser.onLoadThumbnail(this, seqNum, bitmap);
+ mediaBrowser.onLoadIcon(this, seqNum, bitmap);
}
}
}
diff --git a/media/java/android/media/browse/MediaBrowserService.java b/media/java/android/media/browse/MediaBrowserService.java
index c940259..99126c9 100644
--- a/media/java/android/media/browse/MediaBrowserService.java
+++ b/media/java/android/media/browse/MediaBrowserService.java
@@ -105,7 +105,7 @@
* be thrown.
*
* @see MediaBrowserService#onLoadChildren
- * @see MediaBrowserService#onLoadThumbnail
+ * @see MediaBrowserService#onLoadIcon
*/
public class Result<T> {
private Object mDebug;
@@ -266,10 +266,10 @@
}
@Override
- public void loadThumbnail(final int seq, final Uri uri, final int width, final int height,
+ public void loadIcon(final int seq, final Uri uri, final int width, final int height,
final IMediaBrowserServiceCallbacks callbacks) {
if (uri == null) {
- throw new IllegalStateException("loadThumbnail sent null list for uri " + uri);
+ throw new IllegalStateException("loadIcon sent null list for uri " + uri);
}
mHandler.post(new Runnable() {
@Override
@@ -291,7 +291,7 @@
void onResultSent(Bitmap bitmap) {
if (mConnections.get(connection.callbacks.asBinder()) != connection) {
if (DBG) {
- Log.d(TAG, "Not sending onLoadThumbnail result for connection"
+ Log.d(TAG, "Not sending onLoadIcon result for connection"
+ " that has been disconnected. pkg=" + connection.pkg
+ " uri=" + uri);
}
@@ -299,18 +299,18 @@
}
try {
- callbacks.onLoadThumbnail(seq, bitmap);
+ callbacks.onLoadIcon(seq, bitmap);
} catch (RemoteException e) {
// The other side is in the process of crashing.
- Log.w(TAG, "RemoteException in calling onLoadThumbnail", e);
+ Log.w(TAG, "RemoteException in calling onLoadIcon", e);
}
}
};
- onLoadThumbnail(uri, width, height, result);
+ onLoadIcon(uri, width, height, result);
if (!result.isDone()) {
- throw new IllegalStateException("onLoadThumbnail must call detach() or"
+ throw new IllegalStateException("onLoadIcon must call detach() or"
+ " sendResult() before returning for package=" + connection.pkg
+ " uri=" + uri);
}
@@ -375,7 +375,7 @@
@NonNull Result<List<MediaBrowserItem>> result);
/**
- * Called to get the thumbnail of a particular media item.
+ * Called to get the icon of a particular media item.
* <p>
* Implementations must call result.{@link Result#sendResult result.sendResult} with the bitmap.
* If loading the bitmap will be an expensive operation that should be performed
@@ -387,10 +387,10 @@
* @param width The requested width of the icon in dp.
* @param height The requested height of the icon in dp.
*
- * @return The file descriptor of the thumbnail, which may then be loaded
- * using a bitmap factory, or null if the item does not have a thumbnail.
+ * @return The file descriptor of the icon, which may then be loaded
+ * using a bitmap factory, or null if the item does not have an icon.
*/
- public abstract void onLoadThumbnail(@NonNull Uri uri, int width, int height,
+ public abstract void onLoadIcon(@NonNull Uri uri, int width, int height,
@NonNull Result<Bitmap> result);
/**
diff --git a/tests/MusicServiceDemo/src/com/example/android/musicservicedemo/BrowserService.java b/tests/MusicServiceDemo/src/com/example/android/musicservicedemo/BrowserService.java
index 035b3ea..937f1e6 100644
--- a/tests/MusicServiceDemo/src/com/example/android/musicservicedemo/BrowserService.java
+++ b/tests/MusicServiceDemo/src/com/example/android/musicservicedemo/BrowserService.java
@@ -142,7 +142,7 @@
}
@Override
- public void onLoadThumbnail(Uri uri, int width, int height, Result<Bitmap> result) {
+ public void onLoadIcon(Uri uri, int width, int height, Result<Bitmap> result) {
result.sendResult(null);
}