Merge "Remove support: libfeature_support_angle.so" into sc-qpr1-dev am: e61852b9c3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15613738 Change-Id: I13d5e72892cb2072ec17aa23d3adda3c72eb5c2f
This commit is contained in:
@@ -26,8 +26,6 @@ import android.content.pm.IPackageManager;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.res.AssetFileDescriptor;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -37,9 +35,6 @@ import dalvik.system.VMRuntime;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileDescriptor;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -88,9 +83,6 @@ public class GraphicsEnvironment {
|
|||||||
private static final String UPDATABLE_DRIVER_ALLOWLIST_ALL = "*";
|
private static final String UPDATABLE_DRIVER_ALLOWLIST_ALL = "*";
|
||||||
private static final String UPDATABLE_DRIVER_SPHAL_LIBRARIES_FILENAME = "sphal_libraries.txt";
|
private static final String UPDATABLE_DRIVER_SPHAL_LIBRARIES_FILENAME = "sphal_libraries.txt";
|
||||||
|
|
||||||
// ANGLE related properties.
|
|
||||||
private static final String ANGLE_RULES_FILE = "a4a_rules.json";
|
|
||||||
private static final String ANGLE_TEMP_RULES = "debug.angle.rules";
|
|
||||||
private static final String ACTION_ANGLE_FOR_ANDROID = "android.app.action.ANGLE_FOR_ANDROID";
|
private static final String ACTION_ANGLE_FOR_ANDROID = "android.app.action.ANGLE_FOR_ANDROID";
|
||||||
private static final String ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE =
|
private static final String ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE =
|
||||||
"android.app.action.ANGLE_FOR_ANDROID_TOAST_MESSAGE";
|
"android.app.action.ANGLE_FOR_ANDROID_TOAST_MESSAGE";
|
||||||
@@ -164,21 +156,14 @@ public class GraphicsEnvironment {
|
|||||||
Log.v(TAG, "ANGLE Developer option for '" + packageName + "' "
|
Log.v(TAG, "ANGLE Developer option for '" + packageName + "' "
|
||||||
+ "set to: '" + devOptIn + "'");
|
+ "set to: '" + devOptIn + "'");
|
||||||
|
|
||||||
// We only want to use ANGLE if the app is in the allowlist, or the developer has
|
// We only want to use ANGLE if the developer has explicitly chosen something other than
|
||||||
// explicitly chosen something other than default driver.
|
// default driver.
|
||||||
// The allowlist will be generated by the ANGLE APK at both boot time and
|
|
||||||
// ANGLE update time. It will only include apps mentioned in the rules file.
|
|
||||||
final boolean allowed = checkAngleAllowlist(context, coreSettings, packageName);
|
|
||||||
final boolean requested = devOptIn.equals(ANGLE_GL_DRIVER_CHOICE_ANGLE);
|
final boolean requested = devOptIn.equals(ANGLE_GL_DRIVER_CHOICE_ANGLE);
|
||||||
|
|
||||||
if (allowed) {
|
|
||||||
Log.v(TAG, "ANGLE allowlist includes " + packageName);
|
|
||||||
}
|
|
||||||
if (requested) {
|
if (requested) {
|
||||||
Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn);
|
Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return allowed || requested;
|
return requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVulkanVersion(PackageManager pm) {
|
private int getVulkanVersion(PackageManager pm) {
|
||||||
@@ -474,117 +459,6 @@ public class GraphicsEnvironment {
|
|||||||
return debugPackage;
|
return debugPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt to setup ANGLE with a temporary rules file.
|
|
||||||
* True: Temporary rules file was loaded.
|
|
||||||
* False: Temporary rules file was *not* loaded.
|
|
||||||
*/
|
|
||||||
private boolean setupAngleWithTempRulesFile(Context context,
|
|
||||||
String packageName,
|
|
||||||
String paths,
|
|
||||||
String devOptIn) {
|
|
||||||
/**
|
|
||||||
* We only want to load a temp rules file for:
|
|
||||||
* - apps that are marked 'debuggable' in their manifest
|
|
||||||
* - devices that are running a userdebug build (ro.debuggable) or can inject libraries for
|
|
||||||
* debugging (PR_SET_DUMPABLE).
|
|
||||||
*/
|
|
||||||
if (!isDebuggable()) {
|
|
||||||
Log.v(TAG, "Skipping loading temporary rules file");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String angleTempRules = SystemProperties.get(ANGLE_TEMP_RULES);
|
|
||||||
|
|
||||||
if (TextUtils.isEmpty(angleTempRules)) {
|
|
||||||
Log.v(TAG, "System property '" + ANGLE_TEMP_RULES + "' is not set or is empty");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i(TAG, "Detected system property " + ANGLE_TEMP_RULES + ": " + angleTempRules);
|
|
||||||
|
|
||||||
final File tempRulesFile = new File(angleTempRules);
|
|
||||||
if (tempRulesFile.exists()) {
|
|
||||||
Log.i(TAG, angleTempRules + " exists, loading file.");
|
|
||||||
try {
|
|
||||||
final FileInputStream stream = new FileInputStream(angleTempRules);
|
|
||||||
|
|
||||||
try {
|
|
||||||
final FileDescriptor rulesFd = stream.getFD();
|
|
||||||
final long rulesOffset = 0;
|
|
||||||
final long rulesLength = stream.getChannel().size();
|
|
||||||
Log.i(TAG, "Loaded temporary ANGLE rules from " + angleTempRules);
|
|
||||||
|
|
||||||
setAngleInfo(paths, packageName, devOptIn, null,
|
|
||||||
rulesFd, rulesOffset, rulesLength);
|
|
||||||
|
|
||||||
stream.close();
|
|
||||||
|
|
||||||
// We successfully setup ANGLE, so return with good status
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, "Hit IOException thrown by FileInputStream: " + e);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
Log.w(TAG, "Temp ANGLE rules file not found: " + e);
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
Log.w(TAG, "Temp ANGLE rules file not accessible: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt to setup ANGLE with a rules file loaded from the ANGLE APK.
|
|
||||||
* True: APK rules file was loaded.
|
|
||||||
* False: APK rules file was *not* loaded.
|
|
||||||
*/
|
|
||||||
private boolean setupAngleRulesApk(String anglePkgName,
|
|
||||||
ApplicationInfo angleInfo,
|
|
||||||
PackageManager pm,
|
|
||||||
String packageName,
|
|
||||||
String paths,
|
|
||||||
String devOptIn,
|
|
||||||
String[] features) {
|
|
||||||
// Pass the rules file to loader for ANGLE decisions
|
|
||||||
try {
|
|
||||||
final AssetManager angleAssets = pm.getResourcesForApplication(angleInfo).getAssets();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final AssetFileDescriptor assetsFd = angleAssets.openFd(ANGLE_RULES_FILE);
|
|
||||||
|
|
||||||
setAngleInfo(paths, packageName, devOptIn, features, assetsFd.getFileDescriptor(),
|
|
||||||
assetsFd.getStartOffset(), assetsFd.getLength());
|
|
||||||
|
|
||||||
assetsFd.close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, "Failed to get AssetFileDescriptor for " + ANGLE_RULES_FILE
|
|
||||||
+ " from '" + anglePkgName + "': " + e);
|
|
||||||
}
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
Log.w(TAG, "Failed to get AssetManager for '" + anglePkgName + "': " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pull ANGLE allowlist from GlobalSettings and compare against current package
|
|
||||||
*/
|
|
||||||
private boolean checkAngleAllowlist(Context context, Bundle bundle, String packageName) {
|
|
||||||
final ContentResolver contentResolver = context.getContentResolver();
|
|
||||||
final List<String> angleAllowlist =
|
|
||||||
getGlobalSettingsString(contentResolver, bundle,
|
|
||||||
Settings.Global.ANGLE_ALLOWLIST);
|
|
||||||
|
|
||||||
if (DEBUG) Log.v(TAG, "ANGLE allowlist: " + angleAllowlist);
|
|
||||||
|
|
||||||
return angleAllowlist.contains(packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass ANGLE details down to trigger enable logic
|
* Pass ANGLE details down to trigger enable logic
|
||||||
*
|
*
|
||||||
@@ -648,29 +522,18 @@ public class GraphicsEnvironment {
|
|||||||
if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths);
|
if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths);
|
||||||
|
|
||||||
// If the user has set the developer option to something other than default,
|
// If the user has set the developer option to something other than default,
|
||||||
// we need to call setupAngleRulesApk() with the package name and the developer
|
// we need to call setAngleInfo() with the package name and the developer
|
||||||
// option value (native/angle/other). Then later when we are actually trying to
|
// option value (native/angle/other). Then later when we are actually trying to
|
||||||
// load a driver, GraphicsEnv::getShouldUseAngle() has seen the package name before
|
// load a driver, GraphicsEnv::getShouldUseAngle() has seen the package name before
|
||||||
// and can confidently answer yes/no based on the previously set developer
|
// and can confidently answer yes/no based on the previously set developer
|
||||||
// option value.
|
// option value.
|
||||||
final String devOptIn = getDriverForPackage(context, bundle, packageName);
|
final String devOptIn = getDriverForPackage(context, bundle, packageName);
|
||||||
|
final String[] features = getAngleEglFeatures(context, bundle);
|
||||||
|
|
||||||
if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) {
|
setAngleInfo(paths, packageName, devOptIn, features);
|
||||||
// We setup ANGLE with a temp rules file, so we're done here.
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] features = getAngleEglFeatures(context, bundle);
|
|
||||||
|
|
||||||
if (setupAngleRulesApk(
|
|
||||||
anglePkgName, angleInfo, pm, packageName, paths, devOptIn, features)) {
|
|
||||||
// ANGLE with rules is set up from the APK, hence return.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the "ANGLE In Use" dialog box should be shown.
|
* Determine if the "ANGLE In Use" dialog box should be shown.
|
||||||
*/
|
*/
|
||||||
@@ -956,7 +819,7 @@ public class GraphicsEnvironment {
|
|||||||
private static native void setGpuStats(String driverPackageName, String driverVersionName,
|
private static native void setGpuStats(String driverPackageName, String driverVersionName,
|
||||||
long driverVersionCode, long driverBuildTime, String appPackageName, int vulkanVersion);
|
long driverVersionCode, long driverBuildTime, String appPackageName, int vulkanVersion);
|
||||||
private static native void setAngleInfo(String path, String appPackage, String devOptIn,
|
private static native void setAngleInfo(String path, String appPackage, String devOptIn,
|
||||||
String[] features, FileDescriptor rulesFd, long rulesOffset, long rulesLength);
|
String[] features);
|
||||||
private static native boolean getShouldUseAngle(String packageName);
|
private static native boolean getShouldUseAngle(String packageName);
|
||||||
private static native boolean setInjectLayersPrSetDumpable();
|
private static native boolean setInjectLayersPrSetDumpable();
|
||||||
|
|
||||||
|
|||||||
@@ -13735,13 +13735,6 @@ public final class Settings {
|
|||||||
public static final String ANGLE_GL_DRIVER_SELECTION_VALUES =
|
public static final String ANGLE_GL_DRIVER_SELECTION_VALUES =
|
||||||
"angle_gl_driver_selection_values";
|
"angle_gl_driver_selection_values";
|
||||||
|
|
||||||
/**
|
|
||||||
* List of package names that should check ANGLE rules
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
@Readable
|
|
||||||
public static final String ANGLE_ALLOWLIST = "angle_allowlist";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists of ANGLE EGL features for debugging.
|
* Lists of ANGLE EGL features for debugging.
|
||||||
* Each list of features is separated by a comma, each feature in each list is separated by
|
* Each list of features is separated by a comma, each feature in each list is separated by
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ void setGpuStats_native(JNIEnv* env, jobject clazz, jstring driverPackageName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jstring appName,
|
void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jstring appName,
|
||||||
jstring devOptIn, jobjectArray featuresObj, jobject rulesFd,
|
jstring devOptIn, jobjectArray featuresObj) {
|
||||||
jlong rulesOffset, jlong rulesLength) {
|
|
||||||
ScopedUtfChars pathChars(env, path);
|
ScopedUtfChars pathChars(env, path);
|
||||||
ScopedUtfChars appNameChars(env, appName);
|
ScopedUtfChars appNameChars(env, appName);
|
||||||
ScopedUtfChars devOptInChars(env, devOptIn);
|
ScopedUtfChars devOptInChars(env, devOptIn);
|
||||||
@@ -74,11 +73,8 @@ void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jstring appNa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rulesFd_native = jniGetFDFromFileDescriptor(env, rulesFd);
|
|
||||||
|
|
||||||
android::GraphicsEnv::getInstance().setAngleInfo(pathChars.c_str(), appNameChars.c_str(),
|
android::GraphicsEnv::getInstance().setAngleInfo(pathChars.c_str(), appNameChars.c_str(),
|
||||||
devOptInChars.c_str(), features,
|
devOptInChars.c_str(), features);
|
||||||
rulesFd_native, rulesOffset, rulesLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldUseAngle_native(JNIEnv* env, jobject clazz, jstring appName) {
|
bool shouldUseAngle_native(JNIEnv* env, jobject clazz, jstring appName) {
|
||||||
@@ -124,8 +120,7 @@ const JNINativeMethod g_methods[] = {
|
|||||||
{"setInjectLayersPrSetDumpable", "()Z",
|
{"setInjectLayersPrSetDumpable", "()Z",
|
||||||
reinterpret_cast<void*>(setInjectLayersPrSetDumpable_native)},
|
reinterpret_cast<void*>(setInjectLayersPrSetDumpable_native)},
|
||||||
{"setAngleInfo",
|
{"setAngleInfo",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/io/"
|
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V",
|
||||||
"FileDescriptor;JJ)V",
|
|
||||||
reinterpret_cast<void*>(setAngleInfo_native)},
|
reinterpret_cast<void*>(setAngleInfo_native)},
|
||||||
{"getShouldUseAngle", "(Ljava/lang/String;)Z",
|
{"getShouldUseAngle", "(Ljava/lang/String;)Z",
|
||||||
reinterpret_cast<void*>(shouldUseAngle_native)},
|
reinterpret_cast<void*>(shouldUseAngle_native)},
|
||||||
|
|||||||
@@ -762,9 +762,6 @@ class SettingsProtoDumpUtil {
|
|||||||
dumpSetting(s, p,
|
dumpSetting(s, p,
|
||||||
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES,
|
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES,
|
||||||
GlobalSettingsProto.Gpu.ANGLE_GL_DRIVER_SELECTION_VALUES);
|
GlobalSettingsProto.Gpu.ANGLE_GL_DRIVER_SELECTION_VALUES);
|
||||||
dumpSetting(s, p,
|
|
||||||
Settings.Global.ANGLE_ALLOWLIST,
|
|
||||||
GlobalSettingsProto.Gpu.ANGLE_ALLOWLIST);
|
|
||||||
dumpSetting(s, p,
|
dumpSetting(s, p,
|
||||||
Settings.Global.ANGLE_EGL_FEATURES,
|
Settings.Global.ANGLE_EGL_FEATURES,
|
||||||
GlobalSettingsProto.Gpu.ANGLE_EGL_FEATURES);
|
GlobalSettingsProto.Gpu.ANGLE_EGL_FEATURES);
|
||||||
|
|||||||
@@ -508,7 +508,6 @@ public class SettingsBackupTest {
|
|||||||
Settings.Global.ANGLE_GL_DRIVER_ALL_ANGLE,
|
Settings.Global.ANGLE_GL_DRIVER_ALL_ANGLE,
|
||||||
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS,
|
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS,
|
||||||
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES,
|
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES,
|
||||||
Settings.Global.ANGLE_ALLOWLIST,
|
|
||||||
Settings.Global.ANGLE_EGL_FEATURES,
|
Settings.Global.ANGLE_EGL_FEATURES,
|
||||||
Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
|
Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
|
||||||
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS,
|
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS,
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ final class CoreSettingsObserver extends ContentObserver {
|
|||||||
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS, String.class);
|
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS, String.class);
|
||||||
sGlobalSettingToTypeMap.put(
|
sGlobalSettingToTypeMap.put(
|
||||||
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class);
|
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class);
|
||||||
sGlobalSettingToTypeMap.put(
|
|
||||||
Settings.Global.ANGLE_ALLOWLIST, String.class);
|
|
||||||
sGlobalSettingToTypeMap.put(
|
sGlobalSettingToTypeMap.put(
|
||||||
Settings.Global.ANGLE_EGL_FEATURES, String.class);
|
Settings.Global.ANGLE_EGL_FEATURES, String.class);
|
||||||
sGlobalSettingToTypeMap.put(
|
sGlobalSettingToTypeMap.put(
|
||||||
|
|||||||
Reference in New Issue
Block a user