summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSatakshi Rana <satakshir@google.com>2019-10-25 14:59:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-25 14:59:15 +0000
commit70694b005db2fdd1a9fcd752b24fb25e60b8a632 (patch)
treeb6804f935a768ecfde5f587eb7501ce6d420dfe5 /core/java/android
parent645256e6be0fa97a3a9c1f335517f32691ae0b98 (diff)
parentc45d86fc1574c6466cc2d29e9b47dc82a29e20c6 (diff)
Merge "Allow passing the bitmap to ContentSuggestionsService via the extras Bundle"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/contentsuggestions/ContentSuggestionsManager.java13
-rw-r--r--core/java/android/service/contentsuggestions/ContentSuggestionsService.java15
2 files changed, 22 insertions, 6 deletions
diff --git a/core/java/android/app/contentsuggestions/ContentSuggestionsManager.java b/core/java/android/app/contentsuggestions/ContentSuggestionsManager.java
index 1bb81b1487af..1e6ab4136187 100644
--- a/core/java/android/app/contentsuggestions/ContentSuggestionsManager.java
+++ b/core/java/android/app/contentsuggestions/ContentSuggestionsManager.java
@@ -45,6 +45,17 @@ import java.util.concurrent.Executor;
*/
@SystemApi
public final class ContentSuggestionsManager {
+ /**
+ * Key into the extras Bundle passed to {@link #provideContextImage(int, Bundle)}.
+ * This can be used to provide the bitmap to
+ * {@link android.service.contentsuggestions.ContentSuggestionsService}.
+ * The value must be a {@link android.graphics.Bitmap} with the
+ * config {@link android.graphics.Bitmap.Config.HARDWARE}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_BITMAP = "android.contentsuggestions.extra.BITMAP";
+
private static final String TAG = ContentSuggestionsManager.class.getSimpleName();
/**
@@ -70,7 +81,7 @@ public final class ContentSuggestionsManager {
* system content suggestions service.
*
* @param taskId of the task to snapshot.
- * @param imageContextRequestExtras sent with with request to provide implementation specific
+ * @param imageContextRequestExtras sent with request to provide implementation specific
* extra information.
*/
public void provideContextImage(
diff --git a/core/java/android/service/contentsuggestions/ContentSuggestionsService.java b/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
index efc8e877f3c3..4bcd39fbd41f 100644
--- a/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
+++ b/core/java/android/service/contentsuggestions/ContentSuggestionsService.java
@@ -66,12 +66,17 @@ public abstract class ContentSuggestionsService extends Service {
int colorSpaceId, Bundle imageContextRequestExtras) {
Bitmap wrappedBuffer = null;
- if (contextImage != null) {
- ColorSpace colorSpace = null;
- if (colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length) {
- colorSpace = ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]);
+ if (imageContextRequestExtras.containsKey(ContentSuggestionsManager.EXTRA_BITMAP)) {
+ wrappedBuffer = imageContextRequestExtras.getParcelable(
+ ContentSuggestionsManager.EXTRA_BITMAP);
+ } else {
+ if (contextImage != null) {
+ ColorSpace colorSpace = null;
+ if (colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length) {
+ colorSpace = ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]);
+ }
+ wrappedBuffer = Bitmap.wrapHardwareBuffer(contextImage, colorSpace);
}
- wrappedBuffer = Bitmap.wrapHardwareBuffer(contextImage, colorSpace);
}
mHandler.sendMessage(