diff options
11 files changed, 3 insertions, 264 deletions
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 218ca58dee54..2f779010be0e 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -777,12 +777,6 @@ public interface WindowManager extends ViewManager { int TAKE_SCREENSHOT_FULLSCREEN = 1; /** - * Invoke screenshot flow allowing the user to select a region. - * @hide - */ - int TAKE_SCREENSHOT_SELECTED_REGION = 2; - - /** * Invoke screenshot flow with an image provided by the caller. * @hide */ @@ -794,7 +788,6 @@ public interface WindowManager extends ViewManager { * @hide */ @IntDef({TAKE_SCREENSHOT_FULLSCREEN, - TAKE_SCREENSHOT_SELECTED_REGION, TAKE_SCREENSHOT_PROVIDED_IMAGE}) @interface ScreenshotType {} diff --git a/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java index fd4fb133ef12..2719431a536e 100644 --- a/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java +++ b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java @@ -17,7 +17,6 @@ package com.android.internal.util; import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN; -import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.fail; @@ -85,12 +84,6 @@ public final class ScreenshotHelperTest { } @Test - public void testSelectedRegionScreenshot() { - mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_SELECTED_REGION, - WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null); - } - - @Test public void testProvidedImageScreenshot() { mScreenshotHelper.provideScreenshot( new Bundle(), new Rect(), Insets.of(0, 0, 0, 0), 1, 1, new ComponentName("", ""), diff --git a/packages/SystemUI/res/layout/screenshot.xml b/packages/SystemUI/res/layout/screenshot.xml index c29e11bff624..c134c8e2d339 100644 --- a/packages/SystemUI/res/layout/screenshot.xml +++ b/packages/SystemUI/res/layout/screenshot.xml @@ -35,12 +35,6 @@ android:visibility="gone" android:elevation="7dp" android:src="@android:color/white"/> - <com.android.systemui.screenshot.ScreenshotSelectorView - android:id="@+id/screenshot_selector" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:visibility="gone" - android:pointerIcon="crosshair"/> <include layout="@layout/screenshot_static" android:id="@+id/screenshot_static"/> </com.android.systemui.screenshot.ScreenshotView> diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java index df32d2081fde..704e11512b37 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java @@ -408,24 +408,6 @@ public class ScreenshotController { } /** - * Displays a screenshot selector - */ - @MainThread - void takeScreenshotPartial(ComponentName topComponent, - final Consumer<Uri> finisher, RequestCallback requestCallback) { - Assert.isMainThread(); - mScreenshotView.reset(); - mCurrentRequestCallback = requestCallback; - - attachWindow(); - mWindow.setContentView(mScreenshotView); - mScreenshotView.requestApplyInsets(); - - mScreenshotView.takePartialScreenshot( - rect -> takeScreenshotInternal(topComponent, finisher, rect)); - } - - /** * Clears current screenshot */ void dismissScreenshot(boolean immediate) { diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSelectorView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSelectorView.java deleted file mode 100644 index c793b5b9639e..000000000000 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotSelectorView.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.systemui.screenshot; - -import android.annotation.Nullable; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Point; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; - -import java.util.function.Consumer; - -/** - * Draws a selection rectangle while taking screenshot - */ -public class ScreenshotSelectorView extends View { - private Point mStartPoint; - private Rect mSelectionRect; - private final Paint mPaintSelection, mPaintBackground; - - private Consumer<Rect> mOnScreenshotSelected; - - public ScreenshotSelectorView(Context context) { - this(context, null); - } - - public ScreenshotSelectorView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - mPaintBackground = new Paint(Color.BLACK); - mPaintBackground.setAlpha(160); - mPaintSelection = new Paint(Color.TRANSPARENT); - mPaintSelection.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - - setOnTouchListener((v, event) -> { - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - startSelection((int) event.getX(), (int) event.getY()); - return true; - case MotionEvent.ACTION_MOVE: - updateSelection((int) event.getX(), (int) event.getY()); - return true; - case MotionEvent.ACTION_UP: - setVisibility(View.GONE); - final Rect rect = getSelectionRect(); - if (mOnScreenshotSelected != null - && rect != null - && rect.width() != 0 && rect.height() != 0) { - mOnScreenshotSelected.accept(rect); - } - stopSelection(); - return true; - } - return false; - }); - } - - @Override - public void draw(Canvas canvas) { - canvas.drawRect(mLeft, mTop, mRight, mBottom, mPaintBackground); - if (mSelectionRect != null) { - canvas.drawRect(mSelectionRect, mPaintSelection); - } - } - - void setOnScreenshotSelected(Consumer<Rect> onScreenshotSelected) { - mOnScreenshotSelected = onScreenshotSelected; - } - - void stop() { - if (getSelectionRect() != null) { - stopSelection(); - } - } - - private void startSelection(int x, int y) { - mStartPoint = new Point(x, y); - mSelectionRect = new Rect(x, y, x, y); - } - - private void updateSelection(int x, int y) { - if (mSelectionRect != null) { - mSelectionRect.left = Math.min(mStartPoint.x, x); - mSelectionRect.right = Math.max(mStartPoint.x, x); - mSelectionRect.top = Math.min(mStartPoint.y, y); - mSelectionRect.bottom = Math.max(mStartPoint.y, y); - invalidate(); - } - } - - private Rect getSelectionRect() { - return mSelectionRect; - } - - private void stopSelection() { - mStartPoint = null; - mSelectionRect = null; - } -} diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index 360fc879731c..be41a6b0d376 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -93,7 +93,6 @@ import com.android.systemui.shared.system.InputMonitorCompat; import com.android.systemui.shared.system.QuickStepContract; import java.util.ArrayList; -import java.util.function.Consumer; /** * Handles the visual elements and animations for the screenshot flow. @@ -141,7 +140,6 @@ public class ScreenshotView extends FrameLayout implements private boolean mOrientationPortrait; private boolean mDirectionLTR; - private ScreenshotSelectorView mScreenshotSelectorView; private ImageView mScrollingScrim; private DraggableConstraintLayout mScreenshotStatic; private ImageView mScreenshotPreview; @@ -361,7 +359,6 @@ public class ScreenshotView extends FrameLayout implements mDismissButton = requireNonNull(findViewById(R.id.screenshot_dismiss_button)); mScrollablePreview = requireNonNull(findViewById(R.id.screenshot_scrollable_preview)); mScreenshotFlash = requireNonNull(findViewById(R.id.screenshot_flash)); - mScreenshotSelectorView = requireNonNull(findViewById(R.id.screenshot_selector)); mShareChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_share_chip)); mEditChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_edit_chip)); mScrollChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_scroll_chip)); @@ -377,8 +374,6 @@ public class ScreenshotView extends FrameLayout implements mActionsContainerBackground.setTouchDelegate(actionsDelegate); setFocusable(true); - mScreenshotSelectorView.setFocusable(true); - mScreenshotSelectorView.setFocusableInTouchMode(true); mActionsContainer.setScrollX(0); mNavMode = getResources().getInteger( @@ -432,12 +427,6 @@ public class ScreenshotView extends FrameLayout implements mCallbacks = callbacks; } - void takePartialScreenshot(Consumer<Rect> onPartialScreenshotSelected) { - mScreenshotSelectorView.setOnScreenshotSelected(onPartialScreenshotSelected); - mScreenshotSelectorView.setVisibility(View.VISIBLE); - mScreenshotSelectorView.requestFocus(); - } - void setScreenshot(Bitmap bitmap, Insets screenInsets) { mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets)); } @@ -1031,7 +1020,6 @@ public class ScreenshotView extends FrameLayout implements mQuickShareChip = null; setAlpha(1); mScreenshotStatic.setAlpha(1); - mScreenshotSelectorView.stop(); } private void startSharedTransition(ActionTransition transition) { diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotService.java b/packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotService.java index 695a80b2b95d..a4a59ce52c7a 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotService.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotService.java @@ -249,12 +249,6 @@ public class TakeScreenshotService extends Service { } mScreenshot.takeScreenshotFullscreen(topComponent, uriConsumer, callback); break; - case WindowManager.TAKE_SCREENSHOT_SELECTED_REGION: - if (DEBUG_SERVICE) { - Log.d(TAG, "handleMessage: TAKE_SCREENSHOT_SELECTED_REGION"); - } - mScreenshot.takeScreenshotPartial(topComponent, uriConsumer, callback); - break; case WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE: if (DEBUG_SERVICE) { Log.d(TAG, "handleMessage: TAKE_SCREENSHOT_PROVIDED_IMAGE"); diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/RequestProcessorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/RequestProcessorTest.kt index 073c23cec569..5cb27a47d384 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/RequestProcessorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/RequestProcessorTest.kt @@ -28,7 +28,6 @@ import android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OTHER import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE -import android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION import com.android.internal.util.ScreenshotHelper.HardwareBitmapBundler import com.android.internal.util.ScreenshotHelper.HardwareBitmapBundler.bundleToHardwareBitmap import com.android.internal.util.ScreenshotHelper.ScreenshotRequest @@ -140,66 +139,6 @@ class RequestProcessorTest { } @Test - fun testSelectedRegionScreenshot_workProfilePolicyDisabled() = runBlocking { - flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, false) - - val request = ScreenshotRequest(TAKE_SCREENSHOT_SELECTED_REGION, SCREENSHOT_KEY_CHORD) - val processor = RequestProcessor(imageCapture, policy, flags, scope) - - val processedRequest = processor.process(request) - - // No changes - assertThat(processedRequest).isEqualTo(request) - } - - @Test - fun testSelectedRegionScreenshot() = runBlocking { - flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, true) - - val request = ScreenshotRequest(TAKE_SCREENSHOT_SELECTED_REGION, SCREENSHOT_KEY_CHORD) - val processor = RequestProcessor(imageCapture, policy, flags, scope) - - policy.setManagedProfile(USER_ID, false) - policy.setDisplayContentInfo(policy.getDefaultDisplayId(), - DisplayContentInfo(component, bounds, UserHandle.of(USER_ID), TASK_ID)) - - val processedRequest = processor.process(request) - - // Request has topComponent added, but otherwise unchanged. - assertThat(processedRequest.type).isEqualTo(TAKE_SCREENSHOT_FULLSCREEN) - assertThat(processedRequest.topComponent).isEqualTo(component) - } - - @Test - fun testSelectedRegionScreenshot_managedProfile() = runBlocking { - flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, true) - - // Provide a fake task bitmap when asked - val bitmap = makeHardwareBitmap(100, 100) - imageCapture.image = bitmap - - val request = ScreenshotRequest(TAKE_SCREENSHOT_SELECTED_REGION, SCREENSHOT_KEY_CHORD) - val processor = RequestProcessor(imageCapture, policy, flags, scope) - - // Indicate that the primary content belongs to a manged profile - policy.setManagedProfile(USER_ID, true) - policy.setDisplayContentInfo(policy.getDefaultDisplayId(), - DisplayContentInfo(component, bounds, UserHandle.of(USER_ID), TASK_ID)) - - val processedRequest = processor.process(request) - - // Expect a task snapshot is taken, overriding the selected region mode - assertThat(processedRequest.type).isEqualTo(TAKE_SCREENSHOT_PROVIDED_IMAGE) - assertThat(bitmap.equalsHardwareBitmapBundle(processedRequest.bitmapBundle)).isTrue() - assertThat(processedRequest.boundsInScreen).isEqualTo(bounds) - assertThat(processedRequest.insets).isEqualTo(Insets.NONE) - assertThat(processedRequest.taskId).isEqualTo(TASK_ID) - assertThat(imageCapture.requestedTaskId).isEqualTo(TASK_ID) - assertThat(processedRequest.userId).isEqualTo(USER_ID) - assertThat(processedRequest.topComponent).isEqualTo(component) - } - - @Test fun testProvidedImageScreenshot_workProfilePolicyDisabled() = runBlocking { flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, false) diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotServiceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotServiceTest.kt index 002ef2962b03..3a4da86b8045 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotServiceTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotServiceTest.kt @@ -33,7 +33,6 @@ import android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE -import android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION import androidx.test.filters.SmallTest import com.android.internal.logging.testing.UiEventLoggerFake import com.android.internal.util.ScreenshotHelper @@ -175,28 +174,6 @@ class TakeScreenshotServiceTest : SysuiTestCase() { } @Test - fun takeScreenshotPartial() { - val request = ScreenshotRequest( - TAKE_SCREENSHOT_SELECTED_REGION, - SCREENSHOT_KEY_CHORD, - /* topComponent = */ null) - - service.handleRequest(request, { /* onSaved */ }, callback) - - verify(controller, times(1)).takeScreenshotPartial( - /* topComponent = */ isNull(), - /* onSavedListener = */ any(), - /* requestCallback = */ any()) - - assertEquals("Expected one UiEvent", eventLogger.numLogs(), 1) - val logEvent = eventLogger.get(0) - - assertEquals("Expected SCREENSHOT_REQUESTED UiEvent", - logEvent.eventId, SCREENSHOT_REQUESTED_KEY_CHORD.id) - assertEquals("Expected empty package name in UiEvent", "", eventLogger.get(0).packageName) - } - - @Test fun takeScreenshotProvidedImage() { val bounds = Rect(50, 50, 150, 150) val bitmap = makeHardwareBitmap(100, 100) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 05cb42973a00..eba5bafe3f72 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -63,7 +63,6 @@ import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType; import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD; import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER; import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN; -import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION; import static android.view.WindowManagerGlobal.ADD_OKAY; import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED; @@ -2816,9 +2815,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; case KeyEvent.KEYCODE_S: if (down && event.isMetaPressed() && event.isCtrlPressed() && repeatCount == 0) { - int type = event.isShiftPressed() ? TAKE_SCREENSHOT_SELECTED_REGION - : TAKE_SCREENSHOT_FULLSCREEN; - interceptScreenshotChord(type, SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/); + interceptScreenshotChord( + TAKE_SCREENSHOT_FULLSCREEN, SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/); return key_consumed; } break; diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 4c69f87106d1..42a3ec6abbc5 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -2710,7 +2710,7 @@ public class DisplayPolicy { * * @param screenshotType The type of screenshot, for example either * {@link WindowManager#TAKE_SCREENSHOT_FULLSCREEN} or - * {@link WindowManager#TAKE_SCREENSHOT_SELECTED_REGION} + * {@link WindowManager#TAKE_SCREENSHOT_PROVIDED_IMAGE} * @param source Where the screenshot originated from (see WindowManager.ScreenshotSource) */ public void takeScreenshot(int screenshotType, int source) { |