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

Commit 6e6f5551 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Update ImageActionUtils to construct a ScreenshotRequest

Bug: 264457397
Test: atest
Change-Id: Ib629f5d9eed2091f2bc4c1082d5e0dd3d2f9176b
parent 0e89e09f
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
@@ -29,7 +29,6 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutInfo;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler;
@@ -52,10 +51,10 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.annotation.WorkerThread;


import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceId;
import com.android.internal.util.ScreenshotRequest;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.ILauncherUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.ISysuiUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceState;
import com.android.systemui.shared.system.smartspace.SmartspaceState;
@@ -388,14 +387,12 @@ public class SystemUiProxy implements ISystemUiProxy {
    }
    }


    @Override
    @Override
    public void handleImageBundleAsScreenshot(Bundle screenImageBundle, Rect locationInScreen,
    public void takeScreenshot(ScreenshotRequest request) {
            Insets visibleInsets, Task.TaskKey task) {
        if (mSystemUiProxy != null) {
        if (mSystemUiProxy != null) {
            try {
            try {
                mSystemUiProxy.handleImageBundleAsScreenshot(screenImageBundle, locationInScreen,
                mSystemUiProxy.takeScreenshot(request);
                    visibleInsets, task);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call handleImageBundleAsScreenshot");
                Log.w(TAG, "Failed call takeScreenshot");
            }
            }
        }
        }
    }
    }
+14 −6
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.quickstep.util;


import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW;
import static android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE;


import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
@@ -47,7 +49,7 @@ import androidx.annotation.WorkerThread;
import androidx.core.content.FileProvider;
import androidx.core.content.FileProvider;


import com.android.internal.app.ChooserActivity;
import com.android.internal.app.ChooserActivity;
import com.android.internal.util.ScreenshotHelper;
import com.android.internal.util.ScreenshotRequest;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.BuildConfig;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;
@@ -74,11 +76,17 @@ public class ImageActionUtils {
     * Saves screenshot to location determine by SystemUiProxy
     * Saves screenshot to location determine by SystemUiProxy
     */
     */
    public static void saveScreenshot(SystemUiProxy systemUiProxy, Bitmap screenshot,
    public static void saveScreenshot(SystemUiProxy systemUiProxy, Bitmap screenshot,
            Rect screenshotBounds,
            Rect screenshotBounds, Insets visibleInsets, Task.TaskKey task) {
            Insets visibleInsets, Task.TaskKey task) {
        ScreenshotRequest request =
        systemUiProxy.handleImageBundleAsScreenshot(
                new ScreenshotRequest.Builder(TAKE_SCREENSHOT_PROVIDED_IMAGE, SCREENSHOT_OVERVIEW)
                ScreenshotHelper.HardwareBitmapBundler.hardwareBitmapToBundle(screenshot),
                .setTopComponent(task.sourceComponent)
                screenshotBounds, visibleInsets, task);
                .setTaskId(task.id)
                .setUserId(task.userId)
                .setBitmap(screenshot)
                .setBoundsOnScreen(screenshotBounds)
                .setInsets(visibleInsets)
                .build();
        systemUiProxy.takeScreenshot(request);
    }
    }


    /**
    /**