summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorchaviw <chaviw@google.com>2022-01-25 18:05:16 -0600
committerchaviw <chaviw@google.com>2022-02-04 16:27:26 -0600
commit62df8ad0938b877db77079ea7a403e8da8a7d032 (patch)
treeca1874e80a520746d25c77f9482c2f691ef03a87 /core/java/android
parent083297ec6b392920831da2d29f62c32ca3463f33 (diff)
Make setRecentsScreenshotEnabled public
Enable setRecentsScreenshotEnabled as a public API to allow apps to disable the screenshot that is shown in recents. There's no need for a getter method because it's only set by the app so it will not be changed by system Test: SnapshotTaskTests Fixes: 166729178 Change-Id: I06f1e4fa62ad50c050b6259e04a4af27cd25be67
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Activity.java22
-rw-r--r--core/java/android/app/ActivityClient.java4
-rw-r--r--core/java/android/app/IActivityClientController.aidl4
-rw-r--r--core/java/android/view/IWindowManager.aidl10
-rw-r--r--core/java/android/view/WindowManager.java18
-rw-r--r--core/java/android/view/WindowManagerImpl.java11
6 files changed, 58 insertions, 11 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 530666b8f1d7..d31cb49714f5 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -8517,8 +8517,18 @@ public class Activity extends ContextThemeWrapper
}
/**
- * If set to true, this indicates to the system that it should never take a
- * screenshot of the activity to be used as a representation while it is not in a started state.
+ * @hide
+ */
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.S,
+ publicAlternatives = "Use {@link #setRecentsScreenshotEnabled(boolean)} instead.")
+ public void setDisablePreviewScreenshots(boolean disable) {
+ setRecentsScreenshotEnabled(!disable);
+ }
+
+ /**
+ * If set to false, this indicates to the system that it should never take a
+ * screenshot of the activity to be used as a representation in recents screen. By default, this
+ * value is {@code true}.
* <p>
* Note that the system may use the window background of the theme instead to represent
* the window when it is not running.
@@ -8531,12 +8541,10 @@ public class Activity extends ContextThemeWrapper
* {@link android.service.voice.VoiceInteractionService} requests a screenshot via
* {@link android.service.voice.VoiceInteractionSession#SHOW_WITH_SCREENSHOT}.
*
- * @param disable {@code true} to disable preview screenshots; {@code false} otherwise.
- * @hide
+ * @param enabled {@code true} to enable recents screenshots; {@code false} otherwise.
*/
- @UnsupportedAppUsage
- public void setDisablePreviewScreenshots(boolean disable) {
- ActivityClient.getInstance().setDisablePreviewScreenshots(mToken, disable);
+ public void setRecentsScreenshotEnabled(boolean enabled) {
+ ActivityClient.getInstance().setRecentsScreenshotEnabled(mToken, enabled);
}
/**
diff --git a/core/java/android/app/ActivityClient.java b/core/java/android/app/ActivityClient.java
index 605a1fa82254..4715e0f2cec8 100644
--- a/core/java/android/app/ActivityClient.java
+++ b/core/java/android/app/ActivityClient.java
@@ -438,9 +438,9 @@ public class ActivityClient {
}
}
- void setDisablePreviewScreenshots(IBinder token, boolean disable) {
+ void setRecentsScreenshotEnabled(IBinder token, boolean enabled) {
try {
- getActivityClientController().setDisablePreviewScreenshots(token, disable);
+ getActivityClientController().setRecentsScreenshotEnabled(token, enabled);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/IActivityClientController.aidl b/core/java/android/app/IActivityClientController.aidl
index 396e5528ab0c..f9439cb6d770 100644
--- a/core/java/android/app/IActivityClientController.aidl
+++ b/core/java/android/app/IActivityClientController.aidl
@@ -115,8 +115,8 @@ interface IActivityClientController {
int enterAnim, int exitAnim, int backgroundColor);
int setVrMode(in IBinder token, boolean enabled, in ComponentName packageName);
- /** See {@link android.app.Activity#setDisablePreviewScreenshots}. */
- oneway void setDisablePreviewScreenshots(in IBinder token, boolean disable);
+ /** See {@link android.app.Activity#setRecentsScreenshotEnabled}. */
+ oneway void setRecentsScreenshotEnabled(in IBinder token, boolean enabled);
/**
* It should only be called from home activity to remove its outdated snapshot. The home
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index c5ccc18b0cd4..36baa0447176 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -941,4 +941,14 @@ interface IWindowManager
* @hide
*/
void unregisterTaskFpsCallback(in IOnFpsCallbackListener listener);
+
+ /**
+ * Take a snapshot using the same path that's used for Recents. This is used for Testing only.
+ *
+ * @param taskId to take the snapshot of
+ *
+ * Returns a bitmap of the screenshot or {@code null} if it was unable to screenshot.
+ * @hide
+ */
+ Bitmap snapshotTaskForRecents(int taskId);
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index ca7f90080c6c..771d40bdf655 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -97,6 +97,7 @@ import android.content.ClipData;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
@@ -4886,4 +4887,21 @@ public interface WindowManager extends ViewManager {
*/
@SystemApi
default void unregisterTaskFpsCallback(@NonNull TaskFpsCallback callback) {}
+
+ /**
+ * Take a snapshot using the same path that's used for Recents. This is used for Testing only.
+ *
+ * @param taskId to take the snapshot of
+ *
+ * @return a bitmap of the screenshot or {@code null} if it was unable to screenshot. The
+ * screenshot can fail if the taskId is invalid or if there's no SurfaceControl associated with
+ * that task.
+ *
+ * @hide
+ */
+ @TestApi
+ @Nullable
+ default Bitmap snapshotTaskForRecents(@IntRange(from = 0) int taskId) {
+ return null;
+ }
}
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index c16703ef50ef..f4353eb5b397 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -32,6 +32,7 @@ import android.app.ResourcesManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Bundle;
@@ -439,4 +440,14 @@ public final class WindowManagerImpl implements WindowManager {
} catch (RemoteException e) {
}
}
+
+ @Override
+ public Bitmap snapshotTaskForRecents(int taskId) {
+ try {
+ return WindowManagerGlobal.getWindowManagerService().snapshotTaskForRecents(taskId);
+ } catch (RemoteException e) {
+ e.rethrowAsRuntimeException();
+ }
+ return null;
+ }
}