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

Commit 14a7334f authored by junseok01.lee's avatar junseok01.lee Committed by Rachit Jain
Browse files

Fix takeScreenshot for visible background users.

There is some implementation in UiAutomation and UiAutomationConnection
for cases where visible background users take screenshots.
However, currently, even if visible background users take screenshots,
it is set to take screenshots of the default display rather than
the secondary display used by the visible background users.
This modifies to take screenshots from the display used by the user
who requested it, during taking screenshots through UiAutomation.

Bug: 355647098
Flag: EXEMPT (bug fix)
Test: atest CtsUiRenderingTestCases:android.uirendering.cts.testclasses.SurfaceViewTests
Test: atest CtsUiRenderingTestCases:android.uirendering.cts.testclasses.SurfaceViewTests --user-type secondary_user
Test: atest CtsUiRenderingTestCases:android.uirendering.cts.testclasses.SurfaceViewTests --user-type secondary_user_on_secondary_display
Test: atest CtsWindowManagerDeviceAnimations:android.server.wm.animations.BlurTests
Test: atest CtsWindowManagerDeviceAnimations:android.server.wm.animations.BlurTests --user-type secondary_user
Test: atest CtsWindowManagerDeviceAnimations:android.server.wm.animations.BlurTests --user-type secondary_user_on_secondary_display
Change-Id: I6f261c18f2807ff038ae93d1306934f31922fb82
parent b31e37a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ interface IUiAutomationConnection {
    void injectInputEventToInputFilter(in InputEvent event);
    void syncInputTransactions(boolean waitForAnimations);
    boolean setRotation(int rotation);
    boolean takeScreenshot(in Rect crop, in ScreenCaptureListener listener);
    boolean takeScreenshot(in Rect crop, in ScreenCaptureListener listener, int displayId);
    boolean takeSurfaceControlScreenshot(in SurfaceControl surfaceControl, in ScreenCaptureListener listener);
    boolean clearWindowContentFrameStats(int windowId);
    WindowContentFrameStats getWindowContentFrameStats(int windowId);
+1 −1
Original line number Diff line number Diff line
@@ -1274,7 +1274,7 @@ public final class UiAutomation {
                ScreenCapture.createSyncCaptureListener();
        try {
            if (!mUiAutomationConnection.takeScreenshot(
                    new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture)) {
                    new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture, mDisplayId)) {
                return null;
            }
        } catch (RemoteException re) {
+3 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.app;

import static android.view.Display.DEFAULT_DISPLAY;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.accessibilityservice.IAccessibilityServiceClient;
import android.annotation.NonNull;
@@ -228,7 +226,8 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
    }

    @Override
    public boolean takeScreenshot(Rect crop, ScreenCapture.ScreenCaptureListener listener) {
    public boolean takeScreenshot(Rect crop, ScreenCapture.ScreenCaptureListener listener,
            int displayId) {
        synchronized (mLock) {
            throwIfCalledByNotTrustedUidLocked();
            throwIfShutdownLocked();
@@ -240,7 +239,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
            final CaptureArgs captureArgs = new CaptureArgs.Builder<>()
                    .setSourceCrop(crop)
                    .build();
            mWindowManager.captureDisplay(DEFAULT_DISPLAY, captureArgs, listener);
            mWindowManager.captureDisplay(displayId, captureArgs, listener);
        } catch (RemoteException re) {
            re.rethrowAsRuntimeException();
        } finally {