Remove support: libfeature_support_angle.so

Remove support for ANGLE's libfeature_support_angle.so.

This also removes all of the logic related to checking the rules file,
since libfeature_support_angle.so is what parsed the JSON rules file.

Bug: b/187342779
Bug: b/184757175
Test: make and manual verification ANGLE is loaded
Change-Id: I02ac083fb8144465b60ac0ed2738c73b31addda1
Merged-In: I02ac083fb8144465b60ac0ed2738c73b31addda1
This commit is contained in:
Tim Van Patten
2021-05-21 17:53:53 -06:00
parent c8f21f3bb0
commit de31075f7c
6 changed files with 11 additions and 166 deletions

View File

@@ -26,8 +26,6 @@ import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
@@ -37,9 +35,6 @@ import dalvik.system.VMRuntime;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
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_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_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 + "' "
+ "set to: '" + devOptIn + "'");
// We only want to use ANGLE if the app is in the allowlist, or the developer has
// explicitly chosen something other than 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);
// We only want to use ANGLE if the developer has explicitly chosen something other than
// default driver.
final boolean requested = devOptIn.equals(ANGLE_GL_DRIVER_CHOICE_ANGLE);
if (allowed) {
Log.v(TAG, "ANGLE allowlist includes " + packageName);
}
if (requested) {
Log.v(TAG, "ANGLE developer option for " + packageName + ": " + devOptIn);
}
return allowed || requested;
return requested;
}
private int getVulkanVersion(PackageManager pm) {
@@ -474,117 +459,6 @@ public class GraphicsEnvironment {
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
*
@@ -648,27 +522,16 @@ public class GraphicsEnvironment {
if (DEBUG) Log.v(TAG, "ANGLE package libs: " + paths);
// 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
// load a driver, GraphicsEnv::getShouldUseAngle() has seen the package name before
// and can confidently answer yes/no based on the previously set developer
// option value.
final String devOptIn = getDriverForPackage(context, bundle, packageName);
final String[] features = getAngleEglFeatures(context, bundle);
if (setupAngleWithTempRulesFile(context, packageName, paths, devOptIn)) {
// We setup ANGLE with a temp rules file, so we're done here.
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;
setAngleInfo(paths, packageName, devOptIn, features);
return true;
}
/**
@@ -956,7 +819,7 @@ public class GraphicsEnvironment {
private static native void setGpuStats(String driverPackageName, String driverVersionName,
long driverVersionCode, long driverBuildTime, String appPackageName, int vulkanVersion);
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 setInjectLayersPrSetDumpable();

View File

@@ -13669,13 +13669,6 @@ public final class Settings {
public static final String 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.
* Each list of features is separated by a comma, each feature in each list is separated by

View File

@@ -50,8 +50,7 @@ void setGpuStats_native(JNIEnv* env, jobject clazz, jstring driverPackageName,
}
void setAngleInfo_native(JNIEnv* env, jobject clazz, jstring path, jstring appName,
jstring devOptIn, jobjectArray featuresObj, jobject rulesFd,
jlong rulesOffset, jlong rulesLength) {
jstring devOptIn, jobjectArray featuresObj) {
ScopedUtfChars pathChars(env, path);
ScopedUtfChars appNameChars(env, appName);
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(),
devOptInChars.c_str(), features,
rulesFd_native, rulesOffset, rulesLength);
devOptInChars.c_str(), features);
}
bool shouldUseAngle_native(JNIEnv* env, jobject clazz, jstring appName) {
@@ -124,8 +120,7 @@ const JNINativeMethod g_methods[] = {
{"setInjectLayersPrSetDumpable", "()Z",
reinterpret_cast<void*>(setInjectLayersPrSetDumpable_native)},
{"setAngleInfo",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/io/"
"FileDescriptor;JJ)V",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V",
reinterpret_cast<void*>(setAngleInfo_native)},
{"getShouldUseAngle", "(Ljava/lang/String;)Z",
reinterpret_cast<void*>(shouldUseAngle_native)},

View File

@@ -762,9 +762,6 @@ class SettingsProtoDumpUtil {
dumpSetting(s, p,
Settings.Global.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,
Settings.Global.ANGLE_EGL_FEATURES,
GlobalSettingsProto.Gpu.ANGLE_EGL_FEATURES);

View File

@@ -509,7 +509,6 @@ public class SettingsBackupTest {
Settings.Global.ANGLE_GL_DRIVER_ALL_ANGLE,
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS,
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES,
Settings.Global.ANGLE_ALLOWLIST,
Settings.Global.ANGLE_EGL_FEATURES,
Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS,

View File

@@ -93,8 +93,6 @@ final class CoreSettingsObserver extends ContentObserver {
Settings.Global.ANGLE_GL_DRIVER_SELECTION_PKGS, String.class);
sGlobalSettingToTypeMap.put(
Settings.Global.ANGLE_GL_DRIVER_SELECTION_VALUES, String.class);
sGlobalSettingToTypeMap.put(
Settings.Global.ANGLE_ALLOWLIST, String.class);
sGlobalSettingToTypeMap.put(
Settings.Global.ANGLE_EGL_FEATURES, String.class);
sGlobalSettingToTypeMap.put(