Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fd2f7f2 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Add permission for takeScreenshot API.

takeScreenshot is a system API of GameSession and hence should be
guarded by MANAGE_GAME_ACTIVITY permission.

Bug: b/217986003
Test: atest GameServiceTest
Change-Id: I5591435245ba07abf6c9020ef89905f195309a92
parent edcfc18b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11400,7 +11400,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 {
+1 −0
Original line number Diff line number Diff line
@@ -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()");
+3 −0
Original line number Diff line number Diff line
@@ -167,8 +167,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);