Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8975ce55 authored by Song Hu's avatar Song Hu
Browse files

Pass ScreenshotSmartActionType as a new parameter into...

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.

Test: test on local device
Bug: 185423664
Change-Id: I7d12244e21d655c10fb842c8f1bb2690499f5412
parent 71ca7dff
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -57,6 +57,13 @@ public class ScreenshotNotificationSmartActionsProvider {
        ERROR,
        ERROR,
        TIMEOUT
        TIMEOUT
    }
    }

    /* Enum to define screenshot smart action types. */
    public enum ScreenshotSmartActionType {
        REGULAR_SMART_ACTIONS,
        QUICK_SHARE_ACTION
    }

    /**
    /**
     * Default implementation that returns an empty list.
     * Default implementation that returns an empty list.
     * This method is overridden in vendor-specific Sys UI implementation.
     * 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
     * @param userHandle         user handle of the foreground task owner
     */
     */
    public CompletableFuture<List<Notification.Action>> getActions(String screenshotId,
    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) {
        if (DEBUG_ACTIONS) {
            Log.d(TAG, "Returning empty smart action list.");
            Log.d(TAG, "Returning empty smart action list.");
        }
        }
+3 −2
Original line number Original line Diff line number Diff line
@@ -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.DEBUG_ACTIONS;
import static com.android.systemui.screenshot.LogConfig.logTag;
import static com.android.systemui.screenshot.LogConfig.logTag;
import static com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider.ScreenshotSmartActionType;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.Notification;
@@ -87,8 +88,8 @@ public class ScreenshotSmartActions {
                    (runningTask != null && runningTask.topActivity != null)
                    (runningTask != null && runningTask.topActivity != null)
                            ? runningTask.topActivity
                            ? runningTask.topActivity
                            : new ComponentName("", "");
                            : new ComponentName("", "");
            smartActionsFuture = smartActionsProvider.getActions(
            smartActionsFuture = smartActionsProvider.getActions(screenshotId, screenshotUri, image,
                    screenshotId, screenshotUri, image, componentName, userHandle);
                    componentName, ScreenshotSmartActionType.REGULAR_SMART_ACTIONS, userHandle);
        } catch (Throwable e) {
        } catch (Throwable e) {
            long waitTimeMs = SystemClock.uptimeMillis() - startTimeMs;
            long waitTimeMs = SystemClock.uptimeMillis() - startTimeMs;
            smartActionsFuture = CompletableFuture.completedFuture(Collections.emptyList());
            smartActionsFuture = CompletableFuture.completedFuture(Collections.emptyList());
+4 −3
Original line number Original line Diff line number Diff line
@@ -82,7 +82,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
        when(bitmap.getConfig()).thenReturn(Bitmap.Config.HARDWARE);
        when(bitmap.getConfig()).thenReturn(Bitmap.Config.HARDWARE);
        ScreenshotNotificationSmartActionsProvider smartActionsProvider = mock(
        ScreenshotNotificationSmartActionsProvider smartActionsProvider = mock(
                ScreenshotNotificationSmartActionsProvider.class);
                ScreenshotNotificationSmartActionsProvider.class);
        when(smartActionsProvider.getActions(any(), any(), any(), any(), any()))
        when(smartActionsProvider.getActions(any(), any(), any(), any(), any(), any()))
            .thenThrow(RuntimeException.class);
            .thenThrow(RuntimeException.class);
        CompletableFuture<List<Notification.Action>> smartActionsFuture =
        CompletableFuture<List<Notification.Action>> smartActionsFuture =
                mScreenshotSmartActions.getSmartActionsFuture(
                mScreenshotSmartActions.getSmartActionsFuture(
@@ -128,7 +128,7 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
                mScreenshotSmartActions.getSmartActionsFuture(
                mScreenshotSmartActions.getSmartActionsFuture(
                        "", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider,
                        "", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider,
                        true, UserHandle.of(UserHandle.myUserId()));
                        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);
        assertNotNull(smartActionsFuture);
        List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
        List<Notification.Action> smartActions = smartActionsFuture.get(5, TimeUnit.MILLISECONDS);
        assertEquals(Collections.emptyList(), smartActions);
        assertEquals(Collections.emptyList(), smartActions);
@@ -142,7 +142,8 @@ public class ScreenshotNotificationSmartActionsTest extends SysuiTestCase {
        mScreenshotSmartActions.getSmartActionsFuture(
        mScreenshotSmartActions.getSmartActionsFuture(
                "", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider, true,
                "", Uri.parse("content://autority/data"), bitmap, mSmartActionsProvider, true,
                UserHandle.of(UserHandle.myUserId()));
                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.
    // Tests for a hardware bitmap, a completed future is returned.