diff options
author | Perumaal S <perumaal@google.com> | 2020-01-13 21:01:35 -0800 |
---|---|---|
committer | Perumaal S <perumaal@google.com> | 2020-01-21 18:44:38 -0800 |
commit | 3c78cc58c7a4f9fef0d13528633796218c104e30 (patch) | |
tree | faec87bbc2ea145154f170ab3299a8b340a5e89b /services/contentsuggestions | |
parent | 41d2cdf3d1774f7a41c212532a29842dde22c36f (diff) |
Change provideContextImage() API to accept Bitmap
provideContextImage currently takes in taskId which works for the
Recents screen.
In Android QPR2 timeframe, content suggestions also powers Screenshots
feature which requires passing an explicit Bitmap.
This change adds a Bitmap parameter to the 'provideContextImage'.
Launcher/Recents will continue using the taskId-based API to obtain a
fresh snapshot using the Activity/Window Manager; or obtain an on-disk one for paused tasks.
Bug: 147324195
Test: atest ContentSuggestionsManagerTest
in separate CL ag/10146598
Change-Id: I686eb8d90a4a44fdd80403ef2df58020c82ca69a
Diffstat (limited to 'services/contentsuggestions')
-rw-r--r-- | services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java index 9cdb58d8c019..b54ec4ea9441 100644 --- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java +++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java @@ -27,6 +27,7 @@ import android.app.contentsuggestions.IContentSuggestionsManager; import android.app.contentsuggestions.ISelectionsCallback; import android.app.contentsuggestions.SelectionsRequest; import android.content.Context; +import android.graphics.Bitmap; import android.os.Binder; import android.os.Bundle; import android.os.RemoteException; @@ -61,6 +62,10 @@ public class ContentSuggestionsManagerService extends private static final boolean VERBOSE = false; // TODO: make dynamic private static final int MAX_TEMP_SERVICE_DURATION_MS = 1_000 * 60 * 2; // 2 minutes + /** + * Key into the extras Bundle passed to {@link #provideContextImage(int, Bundle)}. + */ + private static final String EXTRA_BITMAP = "android.contentsuggestions.extra.BITMAP"; private ActivityTaskManagerInternal mActivityTaskManagerInternal; @@ -111,6 +116,33 @@ public class ContentSuggestionsManagerService extends private class ContentSuggestionsManagerStub extends IContentSuggestionsManager.Stub { @Override + public void provideContextBitmap( + int userId, + @NonNull Bitmap bitmap, + @NonNull Bundle imageContextRequestExtras) { + if (bitmap == null) { + throw new IllegalArgumentException("Expected non-null bitmap"); + } + if (imageContextRequestExtras == null) { + throw new IllegalArgumentException("Expected non-null imageContextRequestExtras"); + } + enforceCaller(UserHandle.getCallingUserId(), "provideContextBitmap"); + + synchronized (mLock) { + final ContentSuggestionsPerUserService service = getServiceForUserLocked(userId); + if (service != null) { + // TODO(b/147324195): Temporarily pass bitmap until we change the service API. + imageContextRequestExtras.putParcelable(EXTRA_BITMAP, bitmap); + service.provideContextImageLocked(/* taskId = */ -1, imageContextRequestExtras); + } else { + if (VERBOSE) { + Slog.v(TAG, "provideContextImageLocked: no service for " + userId); + } + } + } + } + + @Override public void provideContextImage( int userId, int taskId, |