Merge "Pass ScreenshotSmartActionType as a new parameter into ScreenshotNotificationSmartActionsProviderGoogle#getActions where it maps to InteractionType to differentiate Quick Share action from regular smart actions. SystemUI side change." into sc-dev

This commit is contained in:
Song Hu
2021-04-16 19:28:02 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 6 deletions

View File

@@ -57,6 +57,13 @@ public class ScreenshotNotificationSmartActionsProvider {
ERROR,
TIMEOUT
}
/* Enum to define screenshot smart action types. */
public enum ScreenshotSmartActionType {
REGULAR_SMART_ACTIONS,
QUICK_SHARE_ACTION
}
/**
* Default implementation that returns an empty list.
* This method is overridden in vendor-specific Sys UI implementation.
@@ -68,7 +75,8 @@ public class ScreenshotNotificationSmartActionsProvider {
* @param userHandle user handle of the foreground task owner
*/
public CompletableFuture<List<Notification.Action>> getActions(String screenshotId,
Uri screenshotUri, Bitmap bitmap, ComponentName componentName, UserHandle userHandle) {
Uri screenshotUri, Bitmap bitmap, ComponentName componentName,
ScreenshotSmartActionType actionType, UserHandle userHandle) {
if (DEBUG_ACTIONS) {
Log.d(TAG, "Returning empty smart action list.");
}

View File

@@ -20,6 +20,7 @@ import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
import static com.android.systemui.screenshot.LogConfig.DEBUG_ACTIONS;
import static com.android.systemui.screenshot.LogConfig.logTag;
import static com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider.ScreenshotSmartActionType;
import android.app.ActivityManager;
import android.app.Notification;
@@ -87,8 +88,8 @@ public class ScreenshotSmartActions {
(runningTask != null && runningTask.topActivity != null)
? runningTask.topActivity
: new ComponentName("", "");
smartActionsFuture = smartActionsProvider.getActions(
screenshotId, screenshotUri, image, componentName, userHandle);
smartActionsFuture = smartActionsProvider.getActions(screenshotId, screenshotUri, image,
componentName, ScreenshotSmartActionType.REGULAR_SMART_ACTIONS, userHandle);
} catch (Throwable e) {
long waitTimeMs = SystemClock.uptimeMillis() - startTimeMs;
smartActionsFuture = CompletableFuture.completedFuture(Collections.emptyList());

View File

@@ -82,7 +82,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
when(bitmap.getConfig()).thenReturn(Bitmap.Config.HARDWARE);
ScreenshotNotificationSmartActionsProvider smartActionsProvider = mock(
ScreenshotNotificationSmartActionsProvider.class);
when(smartActionsProvider.getActions(any(), any(), any(), any(), any()))
when(smartActionsProvider.getActions(any(), any(), any(), any(), any(), any()))
.thenThrow(RuntimeException.class);
CompletableFuture<List<Notification.Action>> smartActionsFuture =
mScreenshotSmartActions.getSmartActionsFuture(
@@ -128,7 +128,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
mScreenshotSmartActions.getSmartActionsFuture(
"", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider,
true, UserHandle.of(UserHandle.myUserId()));
verify(mSmartActionsProvider, never()).getActions(any(), any(), any(), any(), any());
verify(mSmartActionsProvider, never()).getActions(any(), any(), any(), any(), any(), any());
assertNotNull(smartActionsFuture);
List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
assertEquals(Collections.emptyList(), smartActions);
@@ -142,7 +142,8 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
mScreenshotSmartActions.getSmartActionsFuture(
"", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider, true,
UserHandle.of(UserHandle.myUserId()));
verify(mSmartActionsProvider, times(1)).getActions(any(), any(), any(), any(), any());
verify(mSmartActionsProvider, times(1)).getActions(
any(), any(), any(), any(), any(), any());
}
// Tests for a hardware bitmap, a completed future is returned.