Merge "Remove partial screenshot code" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5caa83b5c6
@@ -776,12 +776,6 @@ public interface WindowManager extends ViewManager {
|
|||||||
*/
|
*/
|
||||||
int TAKE_SCREENSHOT_FULLSCREEN = 1;
|
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.
|
* Invoke screenshot flow with an image provided by the caller.
|
||||||
* @hide
|
* @hide
|
||||||
@@ -794,7 +788,6 @@ public interface WindowManager extends ViewManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@IntDef({TAKE_SCREENSHOT_FULLSCREEN,
|
@IntDef({TAKE_SCREENSHOT_FULLSCREEN,
|
||||||
TAKE_SCREENSHOT_SELECTED_REGION,
|
|
||||||
TAKE_SCREENSHOT_PROVIDED_IMAGE})
|
TAKE_SCREENSHOT_PROVIDED_IMAGE})
|
||||||
@interface ScreenshotType {}
|
@interface ScreenshotType {}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.internal.util;
|
package com.android.internal.util;
|
||||||
|
|
||||||
import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
|
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.assertNull;
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
@@ -84,12 +83,6 @@ public final class ScreenshotHelperTest {
|
|||||||
WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null);
|
WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSelectedRegionScreenshot() {
|
|
||||||
mScreenshotHelper.takeScreenshot(TAKE_SCREENSHOT_SELECTED_REGION,
|
|
||||||
WindowManager.ScreenshotSource.SCREENSHOT_OTHER, mHandler, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProvidedImageScreenshot() {
|
public void testProvidedImageScreenshot() {
|
||||||
mScreenshotHelper.provideScreenshot(
|
mScreenshotHelper.provideScreenshot(
|
||||||
|
|||||||
@@ -35,12 +35,6 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:elevation="7dp"
|
android:elevation="7dp"
|
||||||
android:src="@android:color/white"/>
|
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"
|
<include layout="@layout/screenshot_static"
|
||||||
android:id="@+id/screenshot_static"/>
|
android:id="@+id/screenshot_static"/>
|
||||||
</com.android.systemui.screenshot.ScreenshotView>
|
</com.android.systemui.screenshot.ScreenshotView>
|
||||||
|
|||||||
@@ -407,24 +407,6 @@ public class ScreenshotController {
|
|||||||
showFlash, UserHandle.of(userId));
|
showFlash, UserHandle.of(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Clears current screenshot
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -93,7 +93,6 @@ import com.android.systemui.shared.system.InputMonitorCompat;
|
|||||||
import com.android.systemui.shared.system.QuickStepContract;
|
import com.android.systemui.shared.system.QuickStepContract;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the visual elements and animations for the screenshot flow.
|
* 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 mOrientationPortrait;
|
||||||
private boolean mDirectionLTR;
|
private boolean mDirectionLTR;
|
||||||
|
|
||||||
private ScreenshotSelectorView mScreenshotSelectorView;
|
|
||||||
private ImageView mScrollingScrim;
|
private ImageView mScrollingScrim;
|
||||||
private DraggableConstraintLayout mScreenshotStatic;
|
private DraggableConstraintLayout mScreenshotStatic;
|
||||||
private ImageView mScreenshotPreview;
|
private ImageView mScreenshotPreview;
|
||||||
@@ -361,7 +359,6 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
mDismissButton = requireNonNull(findViewById(R.id.screenshot_dismiss_button));
|
mDismissButton = requireNonNull(findViewById(R.id.screenshot_dismiss_button));
|
||||||
mScrollablePreview = requireNonNull(findViewById(R.id.screenshot_scrollable_preview));
|
mScrollablePreview = requireNonNull(findViewById(R.id.screenshot_scrollable_preview));
|
||||||
mScreenshotFlash = requireNonNull(findViewById(R.id.screenshot_flash));
|
mScreenshotFlash = requireNonNull(findViewById(R.id.screenshot_flash));
|
||||||
mScreenshotSelectorView = requireNonNull(findViewById(R.id.screenshot_selector));
|
|
||||||
mShareChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_share_chip));
|
mShareChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_share_chip));
|
||||||
mEditChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_edit_chip));
|
mEditChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_edit_chip));
|
||||||
mScrollChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_scroll_chip));
|
mScrollChip = requireNonNull(mActionsContainer.findViewById(R.id.screenshot_scroll_chip));
|
||||||
@@ -377,8 +374,6 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
mActionsContainerBackground.setTouchDelegate(actionsDelegate);
|
mActionsContainerBackground.setTouchDelegate(actionsDelegate);
|
||||||
|
|
||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
mScreenshotSelectorView.setFocusable(true);
|
|
||||||
mScreenshotSelectorView.setFocusableInTouchMode(true);
|
|
||||||
mActionsContainer.setScrollX(0);
|
mActionsContainer.setScrollX(0);
|
||||||
|
|
||||||
mNavMode = getResources().getInteger(
|
mNavMode = getResources().getInteger(
|
||||||
@@ -432,12 +427,6 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
mCallbacks = callbacks;
|
mCallbacks = callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void takePartialScreenshot(Consumer<Rect> onPartialScreenshotSelected) {
|
|
||||||
mScreenshotSelectorView.setOnScreenshotSelected(onPartialScreenshotSelected);
|
|
||||||
mScreenshotSelectorView.setVisibility(View.VISIBLE);
|
|
||||||
mScreenshotSelectorView.requestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setScreenshot(Bitmap bitmap, Insets screenInsets) {
|
void setScreenshot(Bitmap bitmap, Insets screenInsets) {
|
||||||
mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
|
mScreenshotPreview.setImageDrawable(createScreenDrawable(mResources, bitmap, screenInsets));
|
||||||
}
|
}
|
||||||
@@ -1031,7 +1020,6 @@ public class ScreenshotView extends FrameLayout implements
|
|||||||
mQuickShareChip = null;
|
mQuickShareChip = null;
|
||||||
setAlpha(1);
|
setAlpha(1);
|
||||||
mScreenshotStatic.setAlpha(1);
|
mScreenshotStatic.setAlpha(1);
|
||||||
mScreenshotSelectorView.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startSharedTransition(ActionTransition transition) {
|
private void startSharedTransition(ActionTransition transition) {
|
||||||
|
|||||||
@@ -249,12 +249,6 @@ public class TakeScreenshotService extends Service {
|
|||||||
}
|
}
|
||||||
mScreenshot.takeScreenshotFullscreen(topComponent, uriConsumer, callback);
|
mScreenshot.takeScreenshotFullscreen(topComponent, uriConsumer, callback);
|
||||||
break;
|
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:
|
case WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE:
|
||||||
if (DEBUG_SERVICE) {
|
if (DEBUG_SERVICE) {
|
||||||
Log.d(TAG, "handleMessage: TAKE_SCREENSHOT_PROVIDED_IMAGE");
|
Log.d(TAG, "handleMessage: TAKE_SCREENSHOT_PROVIDED_IMAGE");
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD
|
|||||||
import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OTHER
|
import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OTHER
|
||||||
import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN
|
import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN
|
||||||
import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE
|
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
|
||||||
import com.android.internal.util.ScreenshotHelper.HardwareBitmapBundler.bundleToHardwareBitmap
|
import com.android.internal.util.ScreenshotHelper.HardwareBitmapBundler.bundleToHardwareBitmap
|
||||||
import com.android.internal.util.ScreenshotHelper.ScreenshotRequest
|
import com.android.internal.util.ScreenshotHelper.ScreenshotRequest
|
||||||
@@ -139,66 +138,6 @@ class RequestProcessorTest {
|
|||||||
assertThat(processedRequest.topComponent).isEqualTo(component)
|
assertThat(processedRequest.topComponent).isEqualTo(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Test
|
||||||
fun testProvidedImageScreenshot_workProfilePolicyDisabled() = runBlocking {
|
fun testProvidedImageScreenshot_workProfilePolicyDisabled() = runBlocking {
|
||||||
flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, false)
|
flags.set(Flags.SCREENSHOT_WORK_PROFILE_POLICY, false)
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_CHORD
|
|||||||
import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW
|
import android.view.WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW
|
||||||
import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN
|
import android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN
|
||||||
import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE
|
import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE
|
||||||
import android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION
|
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.internal.logging.testing.UiEventLoggerFake
|
import com.android.internal.logging.testing.UiEventLoggerFake
|
||||||
import com.android.internal.util.ScreenshotHelper
|
import com.android.internal.util.ScreenshotHelper
|
||||||
@@ -174,28 +173,6 @@ class TakeScreenshotServiceTest : SysuiTestCase() {
|
|||||||
topComponent.packageName, eventLogger.get(0).packageName)
|
topComponent.packageName, eventLogger.get(0).packageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Test
|
||||||
fun takeScreenshotProvidedImage() {
|
fun takeScreenshotProvidedImage() {
|
||||||
val bounds = Rect(50, 50, 150, 150)
|
val bounds = Rect(50, 50, 150, 150)
|
||||||
|
|||||||
@@ -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_CHORD;
|
||||||
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER;
|
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER;
|
||||||
import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
|
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_OKAY;
|
||||||
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
|
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
|
||||||
|
|
||||||
@@ -2816,9 +2815,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_S:
|
case KeyEvent.KEYCODE_S:
|
||||||
if (down && event.isMetaPressed() && event.isCtrlPressed() && repeatCount == 0) {
|
if (down && event.isMetaPressed() && event.isCtrlPressed() && repeatCount == 0) {
|
||||||
int type = event.isShiftPressed() ? TAKE_SCREENSHOT_SELECTED_REGION
|
interceptScreenshotChord(
|
||||||
: TAKE_SCREENSHOT_FULLSCREEN;
|
TAKE_SCREENSHOT_FULLSCREEN, SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/);
|
||||||
interceptScreenshotChord(type, SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/);
|
|
||||||
return key_consumed;
|
return key_consumed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2710,7 +2710,7 @@ public class DisplayPolicy {
|
|||||||
*
|
*
|
||||||
* @param screenshotType The type of screenshot, for example either
|
* @param screenshotType The type of screenshot, for example either
|
||||||
* {@link WindowManager#TAKE_SCREENSHOT_FULLSCREEN} or
|
* {@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)
|
* @param source Where the screenshot originated from (see WindowManager.ScreenshotSource)
|
||||||
*/
|
*/
|
||||||
public void takeScreenshot(int screenshotType, int source) {
|
public void takeScreenshot(int screenshotType, int source) {
|
||||||
|
|||||||
Reference in New Issue
Block a user