GpuStats: Cache the gpu service binder
Cache the gpu service binder in the app process so that sending stats pieces
won't try to find gpu service every time. If gpu service accidentally restarts,
just ignore the later stats from the app, since the memory that holds GpuStats
for that app is gone already during the gpu service restart.
Test: systrace while try killing gpu service
Change-Id: Ib9c38a3592f509f18d146b6c6e8f14e9e997c994
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index a411dd5..1eedac1 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -258,7 +258,7 @@
}
static sp<IGpuService> getGpuService() {
- const sp<IBinder> binder = defaultServiceManager()->checkService(String16("gpu"));
+ static const sp<IBinder> binder = defaultServiceManager()->checkService(String16("gpu"));
if (!binder) {
ALOGE("Failed to get gpu service");
return nullptr;