Merge "Game Driver: Add support for prerelease channel" into qt-dev
am: ba3f191bd5
Change-Id: I43d18ab2eeb588454b1c0752630bf1a0ee82d372
This commit is contained in:
@@ -62,6 +62,7 @@ public class GraphicsEnvironment {
|
|||||||
private static final String SYSTEM_DRIVER_VERSION_NAME = "";
|
private static final String SYSTEM_DRIVER_VERSION_NAME = "";
|
||||||
private static final long SYSTEM_DRIVER_VERSION_CODE = 0;
|
private static final long SYSTEM_DRIVER_VERSION_CODE = 0;
|
||||||
private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0";
|
private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0";
|
||||||
|
private static final String PROPERTY_GFX_DRIVER_PRERELEASE = "ro.gfx.driver.1";
|
||||||
private static final String PROPERTY_GFX_DRIVER_BUILD_TIME = "ro.gfx.driver_build_time";
|
private static final String PROPERTY_GFX_DRIVER_BUILD_TIME = "ro.gfx.driver_build_time";
|
||||||
private static final String METADATA_DRIVER_BUILD_TIME = "com.android.gamedriver.build_time";
|
private static final String METADATA_DRIVER_BUILD_TIME = "com.android.gamedriver.build_time";
|
||||||
private static final String ANGLE_RULES_FILE = "a4a_rules.json";
|
private static final String ANGLE_RULES_FILE = "a4a_rules.json";
|
||||||
@@ -113,65 +114,6 @@ public class GraphicsEnvironment {
|
|||||||
*/
|
*/
|
||||||
public static native void hintActivityLaunch();
|
public static native void hintActivityLaunch();
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow to query whether an application will use Game Driver.
|
|
||||||
*/
|
|
||||||
public static boolean shouldUseGameDriver(Context context, Bundle coreSettings,
|
|
||||||
ApplicationInfo applicationInfo) {
|
|
||||||
final String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER);
|
|
||||||
if (driverPackageName == null || driverPackageName.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
if (applicationInfo.isPrivilegedApp() || (applicationInfo.isSystemApp()
|
|
||||||
&& !applicationInfo.isUpdatedSystemApp())) {
|
|
||||||
if (DEBUG) Log.v(TAG, "ignoring driver package for privileged/non-updated system app");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final ContentResolver contentResolver = context.getContentResolver();
|
|
||||||
final String packageName = applicationInfo.packageName;
|
|
||||||
final int globalOptIn;
|
|
||||||
if (coreSettings != null) {
|
|
||||||
globalOptIn = coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0);
|
|
||||||
} else {
|
|
||||||
globalOptIn = Settings.Global.getInt(contentResolver,
|
|
||||||
Settings.Global.GAME_DRIVER_ALL_APPS, 0);
|
|
||||||
}
|
|
||||||
if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_ALL) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_NONE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GAME_DRIVER_OPT_OUT_APPS has higher priority than GAME_DRIVER_OPT_IN_APPS
|
|
||||||
if (getGlobalSettingsString(contentResolver, coreSettings,
|
|
||||||
Settings.Global.GAME_DRIVER_OPT_OUT_APPS).contains(packageName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final boolean isOptIn = getGlobalSettingsString(contentResolver, coreSettings,
|
|
||||||
Settings.Global.GAME_DRIVER_OPT_IN_APPS).contains(packageName);
|
|
||||||
final List<String> whitelist = getGlobalSettingsString(contentResolver, coreSettings,
|
|
||||||
Settings.Global.GAME_DRIVER_WHITELIST);
|
|
||||||
if (!isOptIn && whitelist.indexOf(GAME_DRIVER_WHITELIST_ALL) != 0
|
|
||||||
&& !whitelist.contains(packageName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the application is not opted-in, then check whether it's on the blacklist,
|
|
||||||
// terminate early if it's on the blacklist and fallback to system driver.
|
|
||||||
if (!isOptIn
|
|
||||||
&& getGlobalSettingsString(contentResolver, coreSettings,
|
|
||||||
Settings.Global.GAME_DRIVER_BLACKLIST)
|
|
||||||
.contains(packageName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query to determine if ANGLE should be used
|
* Query to determine if ANGLE should be used
|
||||||
*/
|
*/
|
||||||
@@ -741,13 +683,99 @@ public class GraphicsEnvironment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the driver package name to use. Return null for system driver.
|
||||||
|
*/
|
||||||
|
private static String chooseDriverInternal(Context context, Bundle coreSettings) {
|
||||||
|
final String gameDriver = SystemProperties.get(PROPERTY_GFX_DRIVER);
|
||||||
|
final boolean hasGameDriver = gameDriver != null && !gameDriver.isEmpty();
|
||||||
|
|
||||||
|
final String prereleaseDriver = SystemProperties.get(PROPERTY_GFX_DRIVER_PRERELEASE);
|
||||||
|
final boolean hasPrereleaseDriver = prereleaseDriver != null && !prereleaseDriver.isEmpty();
|
||||||
|
|
||||||
|
if (!hasGameDriver && !hasPrereleaseDriver) {
|
||||||
|
if (DEBUG) Log.v(TAG, "Neither Game Driver nor prerelease driver is supported.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
final 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 null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority for Game Driver settings global on confliction (Higher priority comes first):
|
||||||
|
// 1. GAME_DRIVER_ALL_APPS
|
||||||
|
// 2. GAME_DRIVER_OPT_OUT_APPS
|
||||||
|
// 3. GAME_DRIVER_PRERELEASE_OPT_IN_APPS
|
||||||
|
// 4. GAME_DRIVER_OPT_IN_APPS
|
||||||
|
// 5. GAME_DRIVER_BLACKLIST
|
||||||
|
// 6. GAME_DRIVER_WHITELIST
|
||||||
|
final int globalOptIn = coreSettings.getInt(Settings.Global.GAME_DRIVER_ALL_APPS, 0);
|
||||||
|
if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_NONE) {
|
||||||
|
if (DEBUG) Log.v(TAG, "Game Driver is turned off on this device.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalOptIn == GAME_DRIVER_GLOBAL_OPT_IN_ALL) {
|
||||||
|
if (DEBUG) Log.v(TAG, "All apps opt in to use Game Driver.");
|
||||||
|
return hasGameDriver ? gameDriver : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String appPackageName = ai.packageName;
|
||||||
|
if (getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_OPT_OUT_APPS)
|
||||||
|
.contains(appPackageName)) {
|
||||||
|
if (DEBUG) Log.v(TAG, "App opts out for Game Driver.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getGlobalSettingsString(
|
||||||
|
null, coreSettings, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS)
|
||||||
|
.contains(appPackageName)) {
|
||||||
|
if (DEBUG) Log.v(TAG, "App opts in for prerelease Game Driver.");
|
||||||
|
return hasPrereleaseDriver ? prereleaseDriver : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Early return here since the rest logic is only for Game Driver.
|
||||||
|
if (!hasGameDriver) {
|
||||||
|
if (DEBUG) Log.v(TAG, "Game Driver is not supported on the device.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean isOptIn =
|
||||||
|
getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_OPT_IN_APPS)
|
||||||
|
.contains(appPackageName);
|
||||||
|
final List<String> whitelist =
|
||||||
|
getGlobalSettingsString(null, coreSettings, Settings.Global.GAME_DRIVER_WHITELIST);
|
||||||
|
if (!isOptIn && whitelist.indexOf(GAME_DRIVER_WHITELIST_ALL) != 0
|
||||||
|
&& !whitelist.contains(appPackageName)) {
|
||||||
|
if (DEBUG) Log.v(TAG, "App is not on the whitelist for Game Driver.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the application is not opted-in, then check whether it's on the blacklist,
|
||||||
|
// terminate early if it's on the blacklist and fallback to system driver.
|
||||||
|
if (!isOptIn
|
||||||
|
&& getGlobalSettingsString(
|
||||||
|
null, coreSettings, Settings.Global.GAME_DRIVER_BLACKLIST)
|
||||||
|
.contains(appPackageName)) {
|
||||||
|
if (DEBUG) Log.v(TAG, "App is on the blacklist for Game Driver.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameDriver;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Choose whether the current process should use the builtin or an updated driver.
|
* Choose whether the current process should use the builtin or an updated driver.
|
||||||
*/
|
*/
|
||||||
private static boolean chooseDriver(
|
private static boolean chooseDriver(
|
||||||
Context context, Bundle coreSettings, PackageManager pm, String packageName) {
|
Context context, Bundle coreSettings, PackageManager pm, String packageName) {
|
||||||
final String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER);
|
final String driverPackageName = chooseDriverInternal(context, coreSettings);
|
||||||
if (driverPackageName == null || driverPackageName.isEmpty()) {
|
if (driverPackageName == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,10 +798,6 @@ public class GraphicsEnvironment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldUseGameDriver(context, coreSettings, context.getApplicationInfo())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String abi = chooseAbi(driverAppInfo);
|
final String abi = chooseAbi(driverAppInfo);
|
||||||
if (abi == null) {
|
if (abi == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
Reference in New Issue
Block a user