summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eino-Ville Talvala <etalvala@google.com> 2013-02-19 12:54:57 -0800
committer Eino-Ville Talvala <etalvala@google.com> 2013-02-19 18:10:05 -0800
commite88a85e0d0a25c943e974114557770ba10b81847 (patch)
treed8872089aea8322195ac333e576a3c9407ac6c60
parentc4905eb49d20667381f3cda7c6f6894234404bd3 (diff)
Fixes to native app ops services
Bug: 8181262 Change-Id: I3d3f20453f6c6f2756c988363c5b5453ef309cb6
-rw-r--r--include/binder/AppOpsManager.h6
-rw-r--r--include/binder/IAppOpsService.h7
-rw-r--r--libs/binder/AppOpsManager.cpp30
-rw-r--r--libs/binder/IAppOpsService.cpp12
4 files changed, 29 insertions, 26 deletions
diff --git a/include/binder/AppOpsManager.h b/include/binder/AppOpsManager.h
index f64d5da17c..256cb949bb 100644
--- a/include/binder/AppOpsManager.h
+++ b/include/binder/AppOpsManager.h
@@ -28,9 +28,9 @@ class AppOpsManager
{
public:
enum {
- MODE_ALLOWED = 0,
- MODE_IGNORED = 1,
- MODE_ERRORED = 2
+ MODE_ALLOWED = IAppOpsService::MODE_ALLOWED,
+ MODE_IGNORED = IAppOpsService::MODE_IGNORED,
+ MODE_ERRORED = IAppOpsService::MODE_ERRORED
};
enum {
diff --git a/include/binder/IAppOpsService.h b/include/binder/IAppOpsService.h
index 2883e38421..7cb55e5dab 100644
--- a/include/binder/IAppOpsService.h
+++ b/include/binder/IAppOpsService.h
@@ -46,6 +46,12 @@ public:
START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5
};
+
+ enum {
+ MODE_ALLOWED = 0,
+ MODE_IGNORED = 1,
+ MODE_ERRORED = 2
+ };
};
// ----------------------------------------------------------------------
@@ -64,4 +70,3 @@ public:
}; // namespace android
#endif // ANDROID_IAPP_OPS_SERVICE_H
-
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index 5d36dd2e02..7ac1b11d56 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -32,23 +32,21 @@ sp<IAppOpsService> AppOpsManager::getService()
int64_t startTime = 0;
mLock.lock();
sp<IAppOpsService> service = mService;
- while (true) {
- if (service == NULL || !service->asBinder()->isBinderAlive()) {
- sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
- if (binder == NULL) {
- // Wait for the app ops service to come back...
- if (startTime == 0) {
- startTime = uptimeMillis();
- ALOGI("Waiting for app ops service");
- } else if ((uptimeMillis()-startTime) > 10000) {
- ALOGW("Waiting too long for app ops service, giving up");
- return NULL;
- }
- sleep(1);
- } else {
- service = interface_cast<IAppOpsService>(binder);
- mService = service;
+ while (service == NULL || !service->asBinder()->isBinderAlive()) {
+ sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
+ if (binder == NULL) {
+ // Wait for the app ops service to come back...
+ if (startTime == 0) {
+ startTime = uptimeMillis();
+ ALOGI("Waiting for app ops service");
+ } else if ((uptimeMillis()-startTime) > 10000) {
+ ALOGW("Waiting too long for app ops service, giving up");
+ return NULL;
}
+ sleep(1);
+ } else {
+ service = interface_cast<IAppOpsService>(binder);
+ mService = service;
}
}
mLock.unlock();
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index d8922c906e..282b30fedd 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -45,8 +45,8 @@ public:
data.writeString16(packageName);
remote()->transact(CHECK_OPERATION_TRANSACTION, data, &reply);
// fail on exception
- if (reply.readExceptionCode() != 0) return 0;
- return reply.readInt32() != 0;
+ if (reply.readExceptionCode() != 0) return MODE_ERRORED;
+ return reply.readInt32();
}
virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) {
@@ -57,8 +57,8 @@ public:
data.writeString16(packageName);
remote()->transact(NOTE_OPERATION_TRANSACTION, data, &reply);
// fail on exception
- if (reply.readExceptionCode() != 0) return 0;
- return reply.readInt32() != 0;
+ if (reply.readExceptionCode() != 0) return MODE_ERRORED;
+ return reply.readInt32();
}
virtual int32_t startOperation(int32_t code, int32_t uid, const String16& packageName) {
@@ -69,8 +69,8 @@ public:
data.writeString16(packageName);
remote()->transact(START_OPERATION_TRANSACTION, data, &reply);
// fail on exception
- if (reply.readExceptionCode() != 0) return 0;
- return reply.readInt32() != 0;
+ if (reply.readExceptionCode() != 0) return MODE_ERRORED;
+ return reply.readInt32();
}
virtual void finishOperation(int32_t code, int32_t uid, const String16& packageName) {