diff options
author | Satakshi <satakshir@google.com> | 2019-10-23 17:31:07 -0700 |
---|---|---|
committer | Satakshi Rana <satakshir@google.com> | 2019-10-24 17:46:22 +0000 |
commit | c45d86fc1574c6466cc2d29e9b47dc82a29e20c6 (patch) | |
tree | ef61132c526e30bf30720e53f926381c8bd6baa1 /services/contentsuggestions | |
parent | a9da1921f05a09bed597cb4c6b13d9e55f384e8c (diff) |
Allow passing the bitmap to ContentSuggestionsService via the extras Bundle
This change creates a constant in ContentSuggestionsManager, which will
be used to pass a hardware bitmap to ContentSuggestionsService.
In the presence of this key in the request extras, we skip taking a
snapshot in ContentSuggestionsPerUserService.
Bitmap is extracted from reading this value from extras in
ContentSuggestionsService.
Test: Manually tested this code in the debugger to verify that snapshot
is not taken when constant is provided in extras.
Change-Id: I4a464d5188bd3eac9afb4ac223611dccab01510f
Diffstat (limited to 'services/contentsuggestions')
-rw-r--r-- | services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java index 06d9395cd7d6..7828050223f4 100644 --- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java +++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java @@ -22,6 +22,7 @@ import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AppGlobals; import android.app.contentsuggestions.ClassificationsRequest; +import android.app.contentsuggestions.ContentSuggestionsManager; import android.app.contentsuggestions.IClassificationsCallback; import android.app.contentsuggestions.ISelectionsCallback; import android.app.contentsuggestions.SelectionsRequest; @@ -97,15 +98,19 @@ public final class ContentSuggestionsPerUserService extends void provideContextImageLocked(int taskId, @NonNull Bundle imageContextRequestExtras) { RemoteContentSuggestionsService service = ensureRemoteServiceLocked(); if (service != null) { - ActivityManager.TaskSnapshot snapshot = - mActivityTaskManagerInternal.getTaskSnapshotNoRestore(taskId, false); GraphicBuffer snapshotBuffer = null; int colorSpaceId = 0; - if (snapshot != null) { - snapshotBuffer = snapshot.getSnapshot(); - ColorSpace colorSpace = snapshot.getColorSpace(); - if (colorSpace != null) { - colorSpaceId = colorSpace.getId(); + + // Skip taking TaskSnapshot when bitmap is provided. + if (!imageContextRequestExtras.containsKey(ContentSuggestionsManager.EXTRA_BITMAP)) { + ActivityManager.TaskSnapshot snapshot = + mActivityTaskManagerInternal.getTaskSnapshotNoRestore(taskId, false); + if (snapshot != null) { + snapshotBuffer = snapshot.getSnapshot(); + ColorSpace colorSpace = snapshot.getColorSpace(); + if (colorSpace != null) { + colorSpaceId = colorSpace.getId(); + } } } |