diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureClient.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureClient.java index c8b5505a1411c..d56c806554d47 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureClient.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureClient.java @@ -50,8 +50,6 @@ import javax.inject.Inject; public class ScrollCaptureClient { private static final int TILE_SIZE_PX_MAX = 4 * (1024 * 1024); private static final int TILES_PER_PAGE = 2; // increase once b/174571735 is addressed - private static final float MAX_PAGES = 3f; - private static final int MAX_IMAGE_COUNT = (int) Math.ceil(MAX_PAGES * TILES_PER_PAGE); @VisibleForTesting static final int MATCH_ANY_TASK = ActivityTaskManager.INVALID_TASK_ID; @@ -66,10 +64,11 @@ public class ScrollCaptureClient { /** * Session start should be deferred until UI is active because of resource allocation and * potential visible side effects in the target window. - + * * @param sessionConsumer listener to receive the session once active + * @param maxPages the capture buffer size expressed as a multiple of the content height */ - void start(Consumer sessionConsumer); + void start(Consumer sessionConsumer, float maxPages); /** * Close the connection. @@ -196,6 +195,7 @@ public class ScrollCaptureClient { private int mTileWidth; private Rect mRequestRect; private boolean mStarted; + private int mMaxTiles; private ControllerCallbacks(Consumer connectionConsumer) { mConnectionConsumer = connectionConsumer; @@ -285,12 +285,15 @@ public class ScrollCaptureClient { // ScrollCaptureController.Connection @Override - public void start(Consumer sessionConsumer) { + public void start(Consumer sessionConsumer, float maxPages) { if (DEBUG_SCROLL) { - Log.d(TAG, "start(sessionConsumer=" + sessionConsumer + ")"); + Log.d(TAG, "start(sessionConsumer=" + sessionConsumer + "," + + " maxPages=" + maxPages + ")" + + " [maxHeight: " + (mMaxTiles * mTileHeight) + "px]"); } + mMaxTiles = (int) Math.ceil(maxPages * TILES_PER_PAGE); mReader = ImageReader.newInstance(mTileWidth, mTileHeight, PixelFormat.RGBA_8888, - MAX_IMAGE_COUNT, HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE); + mMaxTiles, HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE); mSessionConsumer = sessionConsumer; try { mConnection.startCapture(mReader.getSurface()); @@ -345,7 +348,7 @@ public class ScrollCaptureClient { @Override public int getMaxTiles() { - return MAX_IMAGE_COUNT; + return mMaxTiles; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureController.java index 44e88471db3ba..acad28db3cd8f 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScrollCaptureController.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.graphics.Rect; import android.net.Uri; import android.os.UserHandle; +import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -51,6 +52,9 @@ import java.util.concurrent.Executor; */ public class ScrollCaptureController implements OnComputeInternalInsetsListener { private static final String TAG = "ScrollCaptureController"; + private static final float MAX_PAGES_DEFAULT = 3f; + + private static final String SETTING_KEY_MAX_PAGES = "screenshot.scroll_max_pages"; private static final int UP = -1; private static final int DOWN = 1; @@ -136,7 +140,9 @@ public class ScrollCaptureController implements OnComputeInternalInsetsListener mEdit.setOnClickListener(this::onClicked); mShare.setOnClickListener(this::onClicked); - mConnection.start(this::startCapture); + float maxPages = Settings.Secure.getFloat(mContext.getContentResolver(), + SETTING_KEY_MAX_PAGES, MAX_PAGES_DEFAULT); + mConnection.start(this::startCapture, maxPages); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureClientTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureClientTest.java index c1c637129d851..580f800fbc440 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureClientTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScrollCaptureClientTest.java @@ -57,6 +57,8 @@ import org.mockito.stubbing.Answer; @SmallTest @RunWith(AndroidTestingRunner.class) public class ScrollCaptureClientTest extends SysuiTestCase { + private static final float MAX_PAGES = 3f; + private Context mContext; private IWindowManager mWm; @@ -96,7 +98,7 @@ public class ScrollCaptureClientTest extends SysuiTestCase { Connection conn = mConnectionConsumer.getValue(); - conn.start(mSessionConsumer); + conn.start(mSessionConsumer, MAX_PAGES); verify(mSessionConsumer, timeout(100)).accept(any(Session.class)); Session session = mSessionConsumer.getValue();