Loading libs/graphicsenv/GraphicsEnv.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -689,4 +689,13 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { return mAngleNamespace; } void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) { const sp<IGpuService> gpuService = getGpuService(); if (!gpuService) { ALOGE("No GPU service"); return; } gpuService->toggleAngleAsSystemDriver(enabled); } } // namespace android libs/graphicsenv/IGpuService.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,15 @@ public: 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()); Loading Loading @@ -189,6 +198,15 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep 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); } Loading libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +2 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,8 @@ public: 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 }; Loading libs/graphicsenv/include/graphicsenv/IGpuService.h +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public: // 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> { Loading @@ -59,6 +62,7 @@ public: SET_TARGET_STATS, SET_UPDATABLE_DRIVER_PATH, GET_UPDATABLE_DRIVER_PATH, TOGGLE_ANGLE_AS_SYSTEM_DRIVER, // Always append new enum to the end. }; Loading services/gpuservice/GpuService.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "GpuService.h" #include <android-base/stringprintf.h> #include <android-base/properties.h> #include <binder/IPCThreadState.h> #include <binder/IResultReceiver.h> #include <binder/Parcel.h> Loading Loading @@ -46,6 +47,8 @@ void dumpGameDriverInfo(std::string* result); } // namespace const String16 sDump("android.permission.DUMP"); const String16 sAccessGpuServicePermission("android.permission.ACCESS_GPU_SERVICE"); const std::string sAngleGlesDriverSuffix = "angle"; const char* const GpuService::SERVICE_NAME = "gpu"; Loading Loading @@ -88,6 +91,29 @@ void GpuService::setTargetStatsArray(const std::string& appPackageName, mGpuStats->insertTargetStatsArray(appPackageName, driverVersionCode, stats, values, valueCount); } void GpuService::toggleAngleAsSystemDriver(bool enabled) { IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); // only system_server with the ACCESS_GPU_SERVICE permission is allowed to set // persist.graphics.egl if (uid != AID_SYSTEM || !PermissionCache::checkPermission(sAccessGpuServicePermission, pid, uid)) { ALOGE("Permission Denial: can't set persist.graphics.egl from setAngleAsSystemDriver() " "pid=%d, uid=%d\n", pid, uid); return; } std::lock_guard<std::mutex> lock(mLock); if (enabled) { android::base::SetProperty("persist.graphics.egl", sAngleGlesDriverSuffix); } else { android::base::SetProperty("persist.graphics.egl", ""); } } void GpuService::setUpdatableDriverPath(const std::string& driverPath) { IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); Loading Loading
libs/graphicsenv/GraphicsEnv.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -689,4 +689,13 @@ android_namespace_t* GraphicsEnv::getAngleNamespace() { return mAngleNamespace; } void GraphicsEnv::nativeToggleAngleAsSystemDriver(bool enabled) { const sp<IGpuService> gpuService = getGpuService(); if (!gpuService) { ALOGE("No GPU service"); return; } gpuService->toggleAngleAsSystemDriver(enabled); } } // namespace android
libs/graphicsenv/IGpuService.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,15 @@ public: 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()); Loading Loading @@ -189,6 +198,15 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep 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); } Loading
libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +2 −0 Original line number Diff line number Diff line Loading @@ -142,6 +142,8 @@ public: 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 }; Loading
libs/graphicsenv/include/graphicsenv/IGpuService.h +4 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,9 @@ public: // 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> { Loading @@ -59,6 +62,7 @@ public: SET_TARGET_STATS, SET_UPDATABLE_DRIVER_PATH, GET_UPDATABLE_DRIVER_PATH, TOGGLE_ANGLE_AS_SYSTEM_DRIVER, // Always append new enum to the end. }; Loading
services/gpuservice/GpuService.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "GpuService.h" #include <android-base/stringprintf.h> #include <android-base/properties.h> #include <binder/IPCThreadState.h> #include <binder/IResultReceiver.h> #include <binder/Parcel.h> Loading Loading @@ -46,6 +47,8 @@ void dumpGameDriverInfo(std::string* result); } // namespace const String16 sDump("android.permission.DUMP"); const String16 sAccessGpuServicePermission("android.permission.ACCESS_GPU_SERVICE"); const std::string sAngleGlesDriverSuffix = "angle"; const char* const GpuService::SERVICE_NAME = "gpu"; Loading Loading @@ -88,6 +91,29 @@ void GpuService::setTargetStatsArray(const std::string& appPackageName, mGpuStats->insertTargetStatsArray(appPackageName, driverVersionCode, stats, values, valueCount); } void GpuService::toggleAngleAsSystemDriver(bool enabled) { IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); // only system_server with the ACCESS_GPU_SERVICE permission is allowed to set // persist.graphics.egl if (uid != AID_SYSTEM || !PermissionCache::checkPermission(sAccessGpuServicePermission, pid, uid)) { ALOGE("Permission Denial: can't set persist.graphics.egl from setAngleAsSystemDriver() " "pid=%d, uid=%d\n", pid, uid); return; } std::lock_guard<std::mutex> lock(mLock); if (enabled) { android::base::SetProperty("persist.graphics.egl", sAngleGlesDriverSuffix); } else { android::base::SetProperty("persist.graphics.egl", ""); } } void GpuService::setUpdatableDriverPath(const std::string& driverPath) { IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); Loading