Add new API to toggle ANGLE as the default system GLES driver
Bug:b/270994705
Test: Flash, verify Pixel 7 can boot.
Toggle the developer option switch.
adb shell getprop persist.graphics.egl is returning
right values with switch set on and off.
Change-Id: Idce453d79e97c48cc965900315799784a001e053
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 46dd62d..c480056 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -689,4 +689,13 @@
return mAngleNamespace;
}
+void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) {
+ const sp<IGpuService> gpuService = getGpuService();
+ if (!gpuService) {
+ ALOGE("No GPU service");
+ return;
+ }
+ gpuService->toggleAngleAsSystemDriver(enabled);
+}
+
} // namespace android
diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp
index ceb52f7..4c070ae 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -78,6 +78,15 @@
IBinder::FLAG_ONEWAY);
}
+ void toggleAngleAsSystemDriver(bool enabled) override {
+ Parcel data, reply;
+ data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
+ data.writeBool(enabled);
+
+ remote()->transact(BnGpuService::TOGGLE_ANGLE_AS_SYSTEM_DRIVER, data, &reply,
+ IBinder::FLAG_ONEWAY);
+ }
+
std::string getUpdatableDriverPath() override {
Parcel data, reply;
data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
@@ -189,6 +198,15 @@
return OK;
}
+ case TOGGLE_ANGLE_AS_SYSTEM_DRIVER: {
+ CHECK_INTERFACE(IGpuService, data, reply);
+
+ bool enableAngleAsSystemDriver;
+ if ((status = data.readBool(&enableAngleAsSystemDriver)) != OK) return status;
+
+ toggleAngleAsSystemDriver(enableAngleAsSystemDriver);
+ return OK;
+ }
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index b58a6d9..1274c46 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -142,6 +142,8 @@
const std::string& getDebugLayers();
// Get the debug layers to load.
const std::string& getDebugLayersGLES();
+ // Set the persist.graphics.egl system property value.
+ void nativeToggleAngleAsSystemDriver(bool enabled);
private:
enum UseAngle { UNKNOWN, YES, NO };
diff --git a/libs/graphicsenv/include/graphicsenv/IGpuService.h b/libs/graphicsenv/include/graphicsenv/IGpuService.h
index b708b0f..e3857d2 100644
--- a/libs/graphicsenv/include/graphicsenv/IGpuService.h
+++ b/libs/graphicsenv/include/graphicsenv/IGpuService.h
@@ -50,6 +50,9 @@
// setter and getter for updatable driver path.
virtual void setUpdatableDriverPath(const std::string& driverPath) = 0;
virtual std::string getUpdatableDriverPath() = 0;
+
+ // sets ANGLE as system GLES driver if enabled==true by setting persist.graphics.egl to true.
+ virtual void toggleAngleAsSystemDriver(bool enabled) = 0;
};
class BnGpuService : public BnInterface<IGpuService> {
@@ -59,6 +62,7 @@
SET_TARGET_STATS,
SET_UPDATABLE_DRIVER_PATH,
GET_UPDATABLE_DRIVER_PATH,
+ TOGGLE_ANGLE_AS_SYSTEM_DRIVER,
// Always append new enum to the end.
};