Merge "Add permission for takeScreenshot API." into tm-dev

This commit is contained in:
Peiyong Lin
2022-03-19 01:53:16 +00:00
committed by Android (Google) Code Review
3 changed files with 5 additions and 1 deletions

View File

@@ -11410,7 +11410,7 @@ package android.service.games {
method @RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY) public final boolean restartGame();
method public void setTaskOverlayView(@NonNull android.view.View, @NonNull android.view.ViewGroup.LayoutParams);
method @RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY) public final void startActivityFromGameSessionForResult(@NonNull android.content.Intent, @Nullable android.os.Bundle, @NonNull java.util.concurrent.Executor, @NonNull android.service.games.GameSessionActivityCallback);
method public void takeScreenshot(@NonNull java.util.concurrent.Executor, @NonNull android.service.games.GameSession.ScreenshotCallback);
method @RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY) public void takeScreenshot(@NonNull java.util.concurrent.Executor, @NonNull android.service.games.GameSession.ScreenshotCallback);
}
public static interface GameSession.ScreenshotCallback {

View File

@@ -426,6 +426,7 @@ public abstract class GameSession {
* or failed.
* @throws IllegalStateException if this method is called prior to {@link #onCreate}.
*/
@RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY)
public void takeScreenshot(@NonNull Executor executor, @NonNull ScreenshotCallback callback) {
if (mGameSessionController == null) {
throw new IllegalStateException("Can not call before onCreate()");

View File

@@ -192,8 +192,11 @@ final class GameServiceProviderInstanceImpl implements GameServiceProviderInstan
private final IGameSessionController mGameSessionController =
new IGameSessionController.Stub() {
@Override
@RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY)
public void takeScreenshot(int taskId,
@NonNull AndroidFuture gameScreenshotResultFuture) {
mContext.enforceCallingPermission(Manifest.permission.MANAGE_GAME_ACTIVITY,
"takeScreenshot()");
mBackgroundExecutor.execute(() -> {
GameServiceProviderInstanceImpl.this.takeScreenshot(taskId,
gameScreenshotResultFuture);