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

Commit 32f6ff7e authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Add GameManager service.

GameManager service is a service to manage game related features. This
patch creates the initial service to manage the game mode and persist
the data across reboot.

Bug: b/174956354
Test: atest GameManagerTests
Test: atest GameManagerServiceTests
Test: atest GameManagerServiceSettingsTests
Change-Id: Iee2ab47c79d29f48847bc6d4b3eb781a5af18ff4
parent 19c6e42b
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -72,6 +72,7 @@ import android.content.res.Resources;
import android.content.rollback.RollbackManagerFrameworkInitializer;
import android.content.rollback.RollbackManagerFrameworkInitializer;
import android.debug.AdbManager;
import android.debug.AdbManager;
import android.debug.IAdbManager;
import android.debug.IAdbManager;
import android.graphics.GameManager;
import android.graphics.fonts.FontManager;
import android.graphics.fonts.FontManager;
import android.hardware.ConsumerIrManager;
import android.hardware.ConsumerIrManager;
import android.hardware.ISerialManager;
import android.hardware.ISerialManager;
@@ -1426,6 +1427,16 @@ public final class SystemServiceRegistry {
                        return new MediaMetricsManager(service, ctx.getUserId());
                        return new MediaMetricsManager(service, ctx.getUserId());
                    }});
                    }});


        registerService(Context.GAME_SERVICE, GameManager.class,
                new CachedServiceFetcher<GameManager>() {
                    @Override
                    public GameManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        return new GameManager(ctx.getOuterContext(),
                                ctx.mMainThread.getHandler());
                    }
                });

        sInitializing = true;
        sInitializing = true;
        try {
        try {
            // Note: the following functions need to be @SystemApis, once they become mainline
            // Note: the following functions need to be @SystemApis, once they become mainline
+10 −0
Original line number Original line Diff line number Diff line
@@ -5417,6 +5417,16 @@ public abstract class Context {
    */
    */
    public static final String SPEECH_RECOGNITION_SERVICE = "speech_recognition";
    public static final String SPEECH_RECOGNITION_SERVICE = "speech_recognition";


    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.graphics.GameManager}.
     *
     * @see #getSystemService(String)
     *
     * @hide
     */
    public static final String GAME_SERVICE = "game";

    /**
    /**
     * Determine whether the given permission is allowed for a particular
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
     * process and user ID running in the system.
+29 −0
Original line number Original line Diff line number Diff line
// Copyright (C) 2021 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.

android_test {
    name: "FrameworksCoreGameManagerTests",
    // Include all test java files
    srcs: ["src/**/*.java"],
    static_libs: [
        "androidx.test.rules",
        "frameworks-base-testutils",
        "junit",
        "truth-prebuilt",
    ],
    libs: ["android.test.runner"],
    platform_apis: true,
    certificate: "platform",
    test_suites: ["device-tests"],
}
+30 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.graphics.gamemanagertests"
          android:sharedUserId="android.uid.system" >

    <application>
        <uses-library android:name="android.test.runner" />
    </application>

    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
                     android:targetPackage="com.android.graphics.gamemanagertests"
                     android:label="Game Manager Tests"/>

</manifest>
+32 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->

<configuration description="Runs Game Manager Tests.">
    <option name="test-suite-tag" value="apct"/>
    <option name="test-suite-tag" value="apct-instrumentation"/>

    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true" />
        <option name="test-file-name" value="FrameworksCoreGameManagerTests.apk" />
    </target_preparer>

    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
        <option name="package" value="com.android.graphics.gamemanagertests" />
        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
        <option name="hidden-api-checks" value="false" />
    </test>
</configuration>
Loading