PermissionCache caches permission checks

This is intended to absorb the cost of the IPC
to the permission controller.
Cached permission checks cost about 3us, while
full blown ones are two orders of magnitude slower.

CAVEAT: PermissionCache can only handle system
permissions safely for now, because the cache is
not purged upon global permission changes.

Change-Id: I8b8a5e71e191e3c01e8f792f253c379190eee62e
This commit is contained in:
Mathias Agopian 2011-06-27 16:05:52 -07:00
parent eaf2d0bfe3
commit 1cb13461a8
2 changed files with 5 additions and 5 deletions

View File

@ -31,6 +31,7 @@
#include <binder/BinderService.h>
#include <binder/IServiceManager.h>
#include <binder/PermissionCache.h>
#include <gui/ISensorServer.h>
#include <gui/ISensorEventConnection.h>
@ -58,8 +59,7 @@ namespace android {
*/
SensorService::SensorService()
: mDump("android.permission.DUMP"),
mInitCheck(NO_INIT)
: mInitCheck(NO_INIT)
{
}
@ -166,12 +166,14 @@ SensorService::~SensorService()
delete mSensorMap.valueAt(i);
}
static const String16 sDump("android.permission.DUMP");
status_t SensorService::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 1024;
char buffer[SIZE];
String8 result;
if (!mDump.checkCalling()) {
if (!PermissionCache::checkCallingPermission(sDump)) {
snprintf(buffer, SIZE, "Permission Denial: "
"can't dump SurfaceFlinger from pid=%d, uid=%d\n",
IPCThreadState::self()->getCallingPid(),

View File

@ -27,7 +27,6 @@
#include <utils/RefBase.h>
#include <binder/BinderService.h>
#include <binder/Permission.h>
#include <gui/Sensor.h>
#include <gui/SensorChannel.h>
@ -117,7 +116,6 @@ class SensorService :
Vector<Sensor> mUserSensorList;
DefaultKeyedVector<int, SensorInterface*> mSensorMap;
Vector<SensorInterface *> mVirtualSensorList;
Permission mDump;
status_t mInitCheck;
// protected by mLock