From 3cc1076a7c8d3b4e25f197703d6292f51bae3160 Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Fri, 26 Feb 2016 12:13:04 -0800 Subject: [PATCH] Refresh the native app ops manager's token if needed. The app ops manager serivce keeps track of started app ops by a process by stashing them in a binder object that is passed to the remote process to hold on to. Hence, the data is in the system process and is referenced by the client process it tracks to prevent garbage collaction and limit risk of resource leaks. It is possible that the client process is longer lived than the system seriver, e.g. camera server starts an app op, the system server dies for some reason, the camera server's app ops manager ends up with a stale token. The solution is to check the validity of the token and refresh it if needed. bug:27344593 Change-Id: I0abb39e777b7b66b1b5cefede7e7b41c4404c4b1 --- libs/binder/AppOpsManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp index e4d82019f1..9a061a0ceb 100644 --- a/libs/binder/AppOpsManager.cpp +++ b/libs/binder/AppOpsManager.cpp @@ -28,7 +28,7 @@ static sp gToken; static const sp& getToken(const sp& service) { pthread_mutex_lock(&gTokenMutex); - if (gToken == NULL) { + if (gToken == NULL || gToken->pingBinder() != NO_ERROR) { gToken = service->getToken(new BBinder()); } pthread_mutex_unlock(&gTokenMutex); -- 2.11.0