Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cb13461 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

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
parent eaf2d0bf
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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(),
+0 −2
Original line number Diff line number Diff line
@@ -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