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
+ };
};
// ----------------------------------------------------------------------
}; // namespace android
#endif // ANDROID_IAPP_OPS_SERVICE_H
-
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();
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) {
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) {
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) {