libbinder: move AppOpManager globals into function
Bug: 148177595
Test: N/A
Change-Id: Ibf19d8fbe82595f249fddf8c918c1750bc750f66
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index aeca12b..b2a6f3b 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -43,11 +43,10 @@
} // namespace
-static String16 _appops("appops");
-static pthread_mutex_t gClientIdMutex = PTHREAD_MUTEX_INITIALIZER;
-static sp<IBinder> gClientId;
-
static const sp<IBinder>& getClientId() {
+ static pthread_mutex_t gClientIdMutex = PTHREAD_MUTEX_INITIALIZER;
+ static sp<IBinder> gClientId;
+
pthread_mutex_lock(&gClientIdMutex);
if (gClientId == nullptr) {
gClientId = new BBinder();
@@ -72,6 +71,7 @@
#else
sp<IAppOpsService> AppOpsManager::getService()
{
+ static String16 _appops("appops");
std::lock_guard<Mutex> scoped_lock(mLock);
int64_t startTime = 0;