Merge changes from topic "GameDriver2"
* changes: Game Driver: rename GUP to Game Driver [Game Driver] Add support for whitelist. [Game Driver] Add blacklist mechanism. GUP: Add a global property for genreal preference GUP: Update global property for the new dev opt GUP: Add metrics constant for GUP UI
This commit is contained in:
@@ -687,6 +687,7 @@ java_defaults {
|
||||
static_libs: [
|
||||
"apex_aidl_interface-java",
|
||||
"framework-protos",
|
||||
"game-driver-protos",
|
||||
"android.hidl.base-V1.0-java",
|
||||
"android.hardware.cas-V1.0-java",
|
||||
"android.hardware.contexthub-V1.0-java",
|
||||
|
||||
@@ -20,12 +20,17 @@ import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetManager;
|
||||
import android.gamedriver.GameDriverProto.Blacklist;
|
||||
import android.gamedriver.GameDriverProto.Blacklists;
|
||||
import android.opengl.EGL14;
|
||||
import android.os.Build;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.Settings;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.framework.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import dalvik.system.VMRuntime;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -33,6 +38,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/** @hide */
|
||||
public class GraphicsEnvironment {
|
||||
@@ -49,7 +57,9 @@ public class GraphicsEnvironment {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String TAG = "GraphicsEnvironment";
|
||||
private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0";
|
||||
private static final String GUP_WHITELIST_FILENAME = "whitelist.txt";
|
||||
private static final String GAME_DRIVER_WHITELIST_FILENAME = "whitelist.txt";
|
||||
private static final String GAME_DRIVER_BLACKLIST_FLAG = "blacklist";
|
||||
private static final int BASE64_FLAGS = Base64.NO_PADDING | Base64.NO_WRAP;
|
||||
|
||||
private ClassLoader mClassLoader;
|
||||
private String mLayerPath;
|
||||
@@ -136,6 +146,19 @@ public class GraphicsEnvironment {
|
||||
setLayerPaths(mClassLoader, layerPaths);
|
||||
}
|
||||
|
||||
private static List<String> getGlobalSettingsString(Bundle bundle, String globalSetting) {
|
||||
List<String> valueList = null;
|
||||
String settingsValue = bundle.getString(globalSetting);
|
||||
|
||||
if (settingsValue != null) {
|
||||
valueList = new ArrayList<>(Arrays.asList(settingsValue.split(",")));
|
||||
} else {
|
||||
valueList = new ArrayList<>();
|
||||
}
|
||||
|
||||
return valueList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose whether the current process should use the builtin or an updated driver.
|
||||
*/
|
||||
@@ -145,27 +168,6 @@ public class GraphicsEnvironment {
|
||||
return;
|
||||
}
|
||||
|
||||
// To minimize risk of driver updates crippling the device beyond user repair, never use an
|
||||
// updated driver for privileged or non-updated system apps. Presumably pre-installed apps
|
||||
// were tested thoroughly with the pre-installed driver.
|
||||
ApplicationInfo ai = context.getApplicationInfo();
|
||||
if (ai.isPrivilegedApp() || (ai.isSystemApp() && !ai.isUpdatedSystemApp())) {
|
||||
if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app");
|
||||
return;
|
||||
}
|
||||
|
||||
String applicationPackageName = context.getPackageName();
|
||||
String devOptInApplicationName = coreSettings.getString(
|
||||
Settings.Global.GUP_DEV_OPT_IN_APPS);
|
||||
boolean devOptIn = applicationPackageName.equals(devOptInApplicationName);
|
||||
boolean whitelisted = onWhitelist(context, driverPackageName, ai.packageName);
|
||||
if (!devOptIn && !whitelisted) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, applicationPackageName + " is not on the whitelist.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ApplicationInfo driverInfo;
|
||||
try {
|
||||
driverInfo = context.getPackageManager().getApplicationInfo(driverPackageName,
|
||||
@@ -184,6 +186,78 @@ public class GraphicsEnvironment {
|
||||
return;
|
||||
}
|
||||
|
||||
// To minimize risk of driver updates crippling the device beyond user repair, never use an
|
||||
// updated driver for privileged or non-updated system apps. Presumably pre-installed apps
|
||||
// were tested thoroughly with the pre-installed driver.
|
||||
ApplicationInfo ai = context.getApplicationInfo();
|
||||
if (ai.isPrivilegedApp() || (ai.isSystemApp() && !ai.isUpdatedSystemApp())) {
|
||||
if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app");
|
||||
return;
|
||||
}
|
||||
|
||||
// GAME_DRIVER_ALL_APPS
|
||||
// 0: Default (Invalid values fallback to default as well)
|
||||
// 1: All apps use Game Driver
|
||||
// 2: All apps use system graphics driver
|
||||
int gameDriverAllApps = coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0);
|
||||
if (gameDriverAllApps == 2) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, "Game Driver is turned off on this device");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameDriverAllApps != 1) {
|
||||
// GAME_DRIVER_OPT_OUT_APPS has higher priority than GAME_DRIVER_OPT_IN_APPS
|
||||
if (getGlobalSettingsString(coreSettings, Settings.Global.GAME_DRIVER_OPT_OUT_APPS)
|
||||
.contains(ai.packageName)) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, ai.packageName + " opts out from Game Driver.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
boolean isOptIn =
|
||||
getGlobalSettingsString(coreSettings, Settings.Global.GAME_DRIVER_OPT_IN_APPS)
|
||||
.contains(ai.packageName);
|
||||
|
||||
if (!isOptIn && !onWhitelist(context, driverPackageName, ai.packageName)) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, ai.packageName + " is not on the whitelist.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isOptIn) {
|
||||
// At this point, the application is on the whitelist only, check whether it's
|
||||
// on the blacklist, terminate early when it's on the blacklist.
|
||||
try {
|
||||
// TODO(b/121350991) Switch to DeviceConfig with property listener.
|
||||
String base64String =
|
||||
coreSettings.getString(Settings.Global.GAME_DRIVER_BLACKLIST);
|
||||
if (base64String != null && !base64String.isEmpty()) {
|
||||
Blacklists blacklistsProto = Blacklists.parseFrom(
|
||||
Base64.decode(base64String, BASE64_FLAGS));
|
||||
List<Blacklist> blacklists = blacklistsProto.getBlacklistsList();
|
||||
long driverVersionCode = driverInfo.longVersionCode;
|
||||
for (Blacklist blacklist : blacklists) {
|
||||
if (blacklist.getVersionCode() == driverVersionCode) {
|
||||
for (String packageName : blacklist.getPackageNamesList()) {
|
||||
if (packageName == ai.packageName) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, "Can't parse blacklist, skip and continue...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String abi = chooseAbi(driverInfo);
|
||||
if (abi == null) {
|
||||
if (DEBUG) {
|
||||
@@ -245,7 +319,7 @@ public class GraphicsEnvironment {
|
||||
Context driverContext = context.createPackageContext(driverPackageName,
|
||||
Context.CONTEXT_RESTRICTED);
|
||||
AssetManager assets = driverContext.getAssets();
|
||||
InputStream stream = assets.open(GUP_WHITELIST_FILENAME);
|
||||
InputStream stream = assets.open(GAME_DRIVER_WHITELIST_FILENAME);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
for (String packageName; (packageName = reader.readLine()) != null; ) {
|
||||
if (packageName.equals(applicationPackageName)) {
|
||||
|
||||
@@ -11446,16 +11446,41 @@ public final class Settings {
|
||||
public static final String GPU_DEBUG_APP = "gpu_debug_app";
|
||||
|
||||
/**
|
||||
* Apps that are selected to use Game Update Package.
|
||||
* Game Driver global preference for all Apps.
|
||||
* 0 = Default
|
||||
* 1 = All Apps use Game Driver
|
||||
* 2 = All Apps use system graphics driver
|
||||
* @hide
|
||||
*/
|
||||
public static final String GUP_DEV_OPT_IN_APPS = "gup_dev_opt_in_apps";
|
||||
public static final String GAME_DRIVER_ALL_APPS = "game_driver_all_apps";
|
||||
|
||||
/**
|
||||
* Apps on the black list that are forbidden to useGame Update Package.
|
||||
* List of Apps selected to use Game Driver.
|
||||
* i.e. <pkg1>,<pkg2>,...,<pkgN>
|
||||
* @hide
|
||||
*/
|
||||
public static final String GUP_BLACK_LIST = "gup_black_list";
|
||||
public static final String GAME_DRIVER_OPT_IN_APPS = "game_driver_opt_in_apps";
|
||||
|
||||
/**
|
||||
* List of Apps selected not to use Game Driver.
|
||||
* i.e. <pkg1>,<pkg2>,...,<pkgN>
|
||||
* @hide
|
||||
*/
|
||||
public static final String GAME_DRIVER_OPT_OUT_APPS = "game_driver_opt_out_apps";
|
||||
|
||||
/**
|
||||
* Apps on the blacklist that are forbidden to use Game Driver.
|
||||
* @hide
|
||||
*/
|
||||
public static final String GAME_DRIVER_BLACKLIST = "game_driver_blacklist";
|
||||
|
||||
/**
|
||||
* Apps on the whitelist that are allowed to use Game Driver.
|
||||
* The string is a list of application package names, seperated by comma.
|
||||
* i.e. <apk1>,<apk2>,...,<apkN>
|
||||
* @hide
|
||||
*/
|
||||
public static final String GAME_DRIVER_WHITELIST = "game_driver_whitelist";
|
||||
|
||||
/**
|
||||
* Ordered GPU debug layer list
|
||||
|
||||
@@ -384,11 +384,21 @@ message GlobalSettingsProto {
|
||||
// App allowed to load GPU debug layers.
|
||||
optional SettingProto debug_app = 1;
|
||||
optional SettingProto debug_layers = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
|
||||
// Apps opt in to load graphics driver from Game Update Package
|
||||
// instead of native graphcis driver through developer options.
|
||||
optional SettingProto gup_dev_opt_in_apps = 8;
|
||||
// Apps on the black list that are forbidden to useGame Update Package.
|
||||
optional SettingProto gup_black_list = 9;
|
||||
// Game Driver - global preference for all Apps
|
||||
// 0 = Default
|
||||
// 1 = All Apps use Game Driver
|
||||
// 2 = All Apps use system graphics driver
|
||||
optional SettingProto game_driver_all_apps = 8;
|
||||
// Game Driver - List of Apps selected to use Game Driver
|
||||
// i.e. <pkg1>,<pkg2>,...,<pkgN>
|
||||
optional SettingProto game_driver_opt_in_apps = 9;
|
||||
// Game Driver - List of Apps selected not to use Game Driver
|
||||
// i.e. <pkg1>,<pkg2>,...,<pkgN>
|
||||
optional SettingProto game_driver_opt_out_apps = 10;
|
||||
// Game Driver - List of Apps that are forbidden to use Game Driver
|
||||
optional SettingProto game_driver_blacklist = 11;
|
||||
// Game Driver - List of Apps that are allowed to use Game Driver
|
||||
optional SettingProto game_driver_whitelist = 12;
|
||||
}
|
||||
optional Gpu gpu = 59;
|
||||
|
||||
|
||||
@@ -444,8 +444,11 @@ public class SettingsBackupTest {
|
||||
Settings.Global.ENABLE_GPU_DEBUG_LAYERS,
|
||||
Settings.Global.GPU_DEBUG_APP,
|
||||
Settings.Global.GPU_DEBUG_LAYERS,
|
||||
Settings.Global.GUP_DEV_OPT_IN_APPS,
|
||||
Settings.Global.GUP_BLACK_LIST,
|
||||
Settings.Global.GAME_DRIVER_ALL_APPS,
|
||||
Settings.Global.GAME_DRIVER_OPT_IN_APPS,
|
||||
Settings.Global.GAME_DRIVER_OPT_OUT_APPS,
|
||||
Settings.Global.GAME_DRIVER_BLACKLIST,
|
||||
Settings.Global.GAME_DRIVER_WHITELIST,
|
||||
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING,
|
||||
Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT,
|
||||
Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS,
|
||||
|
||||
11
graphics/proto/Android.bp
Normal file
11
graphics/proto/Android.bp
Normal file
@@ -0,0 +1,11 @@
|
||||
java_library_static {
|
||||
name: "game-driver-protos",
|
||||
host_supported: true,
|
||||
proto: {
|
||||
type: "lite",
|
||||
},
|
||||
srcs: ["game_driver.proto"],
|
||||
no_framework_libs: true,
|
||||
jarjar_rules: "jarjar-rules.txt",
|
||||
sdk_version: "28",
|
||||
}
|
||||
31
graphics/proto/game_driver.proto
Normal file
31
graphics/proto/game_driver.proto
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2019 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.
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package android.gamedriver;
|
||||
|
||||
option java_package = "android.gamedriver";
|
||||
option java_outer_classname = "GameDriverProto";
|
||||
|
||||
message Blacklist {
|
||||
optional int64 version_code = 1;
|
||||
repeated string package_names = 2;
|
||||
}
|
||||
|
||||
message Blacklists {
|
||||
repeated Blacklist blacklists = 1;
|
||||
}
|
||||
1
graphics/proto/jarjar-rules.txt
Normal file
1
graphics/proto/jarjar-rules.txt
Normal file
@@ -0,0 +1 @@
|
||||
rule com.google.protobuf.** com.android.framework.protobuf.@1
|
||||
@@ -1131,7 +1131,4 @@
|
||||
|
||||
<!-- The notice header of Third-party licenses. not translatable -->
|
||||
<string name="notice_header" translatable="false"></string>
|
||||
|
||||
<!-- UI debug setting: opt in to use updated graphics driver? [CHAR LIMIT=100] -->
|
||||
<string name="gup_dev_opt_in_app_summary">Opt in app to use Game Update Package in developement</string>
|
||||
</resources>
|
||||
|
||||
@@ -648,11 +648,20 @@ class SettingsProtoDumpUtil {
|
||||
Settings.Global.GPU_DEBUG_LAYERS,
|
||||
GlobalSettingsProto.Gpu.DEBUG_LAYERS);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GUP_DEV_OPT_IN_APPS,
|
||||
GlobalSettingsProto.Gpu.GUP_DEV_OPT_IN_APPS);
|
||||
Settings.Global.GAME_DRIVER_ALL_APPS,
|
||||
GlobalSettingsProto.Gpu.GAME_DRIVER_ALL_APPS);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GUP_BLACK_LIST,
|
||||
GlobalSettingsProto.Gpu.GUP_BLACK_LIST);
|
||||
Settings.Global.GAME_DRIVER_OPT_IN_APPS,
|
||||
GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_IN_APPS);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GAME_DRIVER_OPT_OUT_APPS,
|
||||
GlobalSettingsProto.Gpu.GAME_DRIVER_OPT_OUT_APPS);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GAME_DRIVER_BLACKLIST,
|
||||
GlobalSettingsProto.Gpu.GAME_DRIVER_BLACKLIST);
|
||||
dumpSetting(s, p,
|
||||
Settings.Global.GAME_DRIVER_WHITELIST,
|
||||
GlobalSettingsProto.Gpu.GAME_DRIVER_WHITELIST);
|
||||
p.end(gpuToken);
|
||||
|
||||
final long hdmiToken = p.start(GlobalSettingsProto.HDMI);
|
||||
|
||||
@@ -6492,6 +6492,11 @@ message MetricsEvent {
|
||||
// OS: Q
|
||||
ACTION_EMERGENCY_DIALER_FROM_POWER_MENU = 1569;
|
||||
|
||||
// OPEN: Settings > Developer Options > Game Driver Preference
|
||||
// CATEGORY: SETTINGS
|
||||
// OS: Q
|
||||
SETTINGS_GAME_DRIVER_DASHBOARD = 1613;
|
||||
|
||||
// ---- End Q Constants, all Q constants go above this line ----
|
||||
|
||||
// Add new aosp constants above this line.
|
||||
|
||||
@@ -55,8 +55,11 @@ final class CoreSettingsObserver extends ContentObserver {
|
||||
// add other system settings here...
|
||||
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.DEBUG_VIEW_ATTRIBUTES, int.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GUP_DEV_OPT_IN_APPS, String.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GUP_BLACK_LIST, String.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_ALL_APPS, int.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_OPT_IN_APPS, String.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_OPT_OUT_APPS, String.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_BLACKLIST, String.class);
|
||||
sGlobalSettingToTypeMap.put(Settings.Global.GAME_DRIVER_WHITELIST, String.class);
|
||||
// add other global settings here...
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user