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

Commit d5846ad2 authored by shannonchen's avatar shannonchen Committed by Shannon Chen
Browse files

Add a test API allowing overriding the GameService provider.

This is so that CTS tests can be run against a test GameService
rather than against whatever GameService a particular device
has set as its default.

Ignore-AOSP-First: GameService incomplete in AOSP
Test: atest CtsGameServiceTestCases GameServiceProviderSelectorImplTest
Bug: 202417555
Bug: 206128693
Change-Id: I5d0d1a4047949117850818c14b5df617314efcf5
parent 78f3eb7a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ package android {
    field public static final String RESET_APP_ERRORS = "android.permission.RESET_APP_ERRORS";
    field public static final String REVOKE_POST_NOTIFICATIONS_WITHOUT_KILL = "android.permission.REVOKE_POST_NOTIFICATIONS_WITHOUT_KILL";
    field public static final String SET_AND_VERIFY_LOCKSCREEN_CREDENTIALS = "android.permission.SET_AND_VERIFY_LOCKSCREEN_CREDENTIALS";
    field public static final String SET_GAME_SERVICE = "android.permission.SET_GAME_SERVICE";
    field public static final String SET_KEYBOARD_LAYOUT = "android.permission.SET_KEYBOARD_LAYOUT";
    field public static final String START_TASKS_FROM_RECENTS = "android.permission.START_TASKS_FROM_RECENTS";
    field public static final String SUSPEND_APPS = "android.permission.SUSPEND_APPS";
@@ -274,6 +275,10 @@ package android.app {
    method @RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE) public void stopDream();
  }

  public final class GameManager {
    method public void setGameServiceProvider(@Nullable String);
  }

  public abstract class HomeVisibilityListener {
    ctor public HomeVisibilityListener();
    method public abstract void onHomeVisibilityChanged(boolean);
+17 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserHandleAware;
import android.content.Context;
import android.os.Handler;
@@ -204,4 +205,20 @@ public final class GameManager {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Sets the game service provider to the given package name for test only.
     *
     * <p>Passing in {@code null} will clear a previously set value.
     * @hide
     */
    @TestApi
    public void setGameServiceProvider(@Nullable String packageName) {
        try {
            mService.setGameServiceProvider(packageName);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -29,4 +29,5 @@ interface IGameManagerService {
    boolean getAngleEnabled(String packageName, int userId);
    void setGameState(String packageName, in GameState gameState, int userId);
    GameModeInfo getGameModeInfo(String packageName, int userId);
    void setGameServiceProvider(String packageName);
}
+5 −0
Original line number Diff line number Diff line
@@ -6131,6 +6131,11 @@
    <permission android:name="android.permission.MANAGE_GAME_MODE"
                android:protectionLevel="signature|privileged" />

    <!-- @TestApi Allows setting the game service provider, meant for tests only.
     @hide -->
    <permission android:name="android.permission.SET_GAME_SERVICE"
                android:protectionLevel="signature" />

    <!-- @SystemApi Allows accessing the frame rate per second of a given application
     @hide -->
    <permission android:name="android.permission.ACCESS_FPS_COUNTER"
+3 −0
Original line number Diff line number Diff line
@@ -557,6 +557,9 @@
    <!-- Permission required for CTS test - CtsGameManagerTestCases -->
    <uses-permission android:name="android.permission.MANAGE_GAME_MODE" />

    <!-- Permission required for CTS test - CtsGameServiceTestCases -->
    <uses-permission android:name="android.permission.SET_GAME_SERVICE" />

    <!-- Permission required for CTS test - ClipboardManagerTest -->
    <uses-permission android:name="android.permission.SET_CLIP_SOURCE" />

Loading