diff options
| author | 2019-02-06 20:22:59 -0800 | |
|---|---|---|
| committer | 2019-02-08 20:22:30 -0800 | |
| commit | cb9d4e403492412f83be15df7e279fb6a8d9bb17 (patch) | |
| tree | 15d5d7f3968bbcb603474a42df9ff01a548f8c6c /libs/graphicsenv/GraphicsEnv.cpp | |
| parent | 8c8c18169a37d829ef04c0f08ac08298f62bd359 (diff) | |
Game Driver: make GpuService the GpuStats holder
Move IGpuService to graphicsenv to avoid dependency circle. Add ATRACE
to GraphicsEnv. Implement the prototype SET_GPU_STATS IPC to collect
GpuStats from applications.
Bug: 123529932
Test: Build, flash and boot.
Change-Id: I7d76324c5adb6ad00f1e5420ab2c7f4067f33253
Diffstat (limited to 'libs/graphicsenv/GraphicsEnv.cpp')
| -rw-r--r-- | libs/graphicsenv/GraphicsEnv.cpp | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index 337308b813..c20d54b7f2 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -14,8 +14,11 @@ * limitations under the License. */ +#define ATRACE_TAG ATRACE_TAG_GRAPHICS + //#define LOG_NDEBUG 1 #define LOG_TAG "GraphicsEnv" + #include <graphicsenv/GraphicsEnv.h> #include <dlfcn.h> @@ -25,15 +28,16 @@ #include <android-base/properties.h> #include <android-base/strings.h> #include <android/dlext.h> +#include <binder/IServiceManager.h> #include <cutils/properties.h> +#include <graphicsenv/IGpuService.h> #include <log/log.h> #include <sys/prctl.h> +#include <utils/Trace.h> #include <memory> #include <string> -#include <dlfcn.h> - // TODO(b/37049319) Get this from a header once one exists extern "C" { android_namespace_t* android_get_exported_namespace(const char*); @@ -155,9 +159,16 @@ void GraphicsEnv::setDriverPath(const std::string path) { void GraphicsEnv::setGpuStats(const std::string driverPackageName, const std::string driverVersionName, const uint64_t driverVersionCode, const std::string appPackageName) { - ALOGV("setGpuStats: drvPkgName[%s], drvVerName[%s], drvVerCode[%lld], appPkgName[%s]", - driverPackageName.c_str(), driverVersionName.c_str(), (long long)driverVersionCode, - appPackageName.c_str()); + ATRACE_CALL(); + + ALOGV("setGpuStats:\n" + "\tdriverPackageName[%s]\n" + "\tdriverVersionName[%s]\n" + "\tdriverVersionCode[%llu]\n" + "\tappPackageName[%s]\n", + driverPackageName.c_str(), driverVersionName.c_str(), + (unsigned long long)driverVersionCode, appPackageName.c_str()); + mGpuStats = { .driverPackageName = driverPackageName, .driverVersionName = driverVersionName, @@ -166,6 +177,32 @@ void GraphicsEnv::setGpuStats(const std::string driverPackageName, }; } +void GraphicsEnv::sendGpuStats() { + ATRACE_CALL(); + + // Do not sendGpuStats for those skipping the GraphicsEnvironment setup + if (mGpuStats.appPackageName.empty()) return; + + ALOGV("sendGpuStats:\n" + "\tdriverPackageName[%s]\n" + "\tdriverVersionName[%s]\n" + "\tdriverVersionCode[%llu]\n" + "\tappPackageName[%s]\n", + mGpuStats.driverPackageName.c_str(), mGpuStats.driverVersionName.c_str(), + (unsigned long long)mGpuStats.driverVersionCode, mGpuStats.appPackageName.c_str()); + + const sp<IBinder> binder = defaultServiceManager()->checkService(String16("gpu")); + if (!binder) { + ALOGE("Failed to get gpu service for [%s]", mGpuStats.appPackageName.c_str()); + return; + } + + interface_cast<IGpuService>(binder)->setGpuStats(mGpuStats.driverPackageName, + mGpuStats.driverVersionName, + mGpuStats.driverVersionCode, + mGpuStats.appPackageName); +} + void* GraphicsEnv::loadLibrary(std::string name) { const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, |