Avoid unloading ANGLE.
Previously when ANGLE is the default GLES driver and preloaded, by
setting an application to use ANGLE when ANGLE apk doesn't present, the
system ANGLE should be used. However, the loader will unload the default
driver and load ANGLE. And hence when ANGLE is the default GLES driver,
it will be unloaded and then reloaded. This patch makes sure the loader
skips unloading and immediately return in this case.
Minor: Only unload the drivers when there are preloaded drivers.
Bug: b/283858001
Test: verified with camera
Test: verified by forcing GLES driver preloading
Change-Id: I82b6408405ef7c507e50ab259204bdce95fda110
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index b6b0cfb..7eaa18c 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -402,7 +402,7 @@
return mShouldUseAngle;
}
-void GraphicsEnv::setAngleInfo(const std::string& path, const bool useSystemAngle,
+void GraphicsEnv::setAngleInfo(const std::string& path, const bool shouldUseSystemAngle,
const std::string& packageName,
const std::vector<std::string> eglFeatures) {
if (mShouldUseAngle) {
@@ -420,7 +420,7 @@
ALOGV("setting app package name to '%s'", packageName.c_str());
mPackageName = std::move(packageName);
mShouldUseAngle = true;
- mUseSystemAngle = useSystemAngle;
+ mShouldUseSystemAngle = shouldUseSystemAngle;
}
void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace,
@@ -571,7 +571,7 @@
return mAngleNamespace;
}
- if (mAnglePath.empty() && !mUseSystemAngle) {
+ if (mAnglePath.empty() && !mShouldUseSystemAngle) {
ALOGV("mAnglePath is empty and not using system ANGLE, abort creating ANGLE namespace");
return nullptr;
}
@@ -589,18 +589,19 @@
// are properly inherited.
mAngleNamespace =
android_create_namespace("ANGLE",
- mUseSystemAngle ? defaultLibraryPaths
- : mAnglePath.c_str(), // ld_library_path
- mUseSystemAngle ? defaultLibraryPaths
- : mAnglePath.c_str(), // default_library_path
+ mShouldUseSystemAngle ? defaultLibraryPaths
+ : mAnglePath.c_str(), // ld_library_path
+ mShouldUseSystemAngle
+ ? defaultLibraryPaths
+ : mAnglePath.c_str(), // default_library_path
ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED,
nullptr, // permitted_when_isolated_path
- mUseSystemAngle ? android_get_exported_namespace("sphal")
- : nullptr); // parent
+ mShouldUseSystemAngle ? android_get_exported_namespace("sphal")
+ : nullptr); // parent
ALOGD_IF(!mAngleNamespace, "Could not create ANGLE namespace from default");
- if (!mUseSystemAngle) {
+ if (!mShouldUseSystemAngle) {
return mAngleNamespace;
}
@@ -625,4 +626,8 @@
gpuService->toggleAngleAsSystemDriver(enabled);
}
+bool GraphicsEnv::shouldUseSystemAngle() {
+ return mShouldUseSystemAngle;
+}
+
} // namespace android