summaryrefslogtreecommitdiff
path: root/libs/binder/IAppOpsService.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2020-09-10 17:22:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-09-10 17:22:18 +0000
commitcdb6b16dec3a541b455be99d075004cb2f0a0cd7 (patch)
treef7110d50445c67a337105034b1f2db3946a88fef /libs/binder/IAppOpsService.cpp
parent171cac1b603e4bb83412eb596d05a500af5d7a76 (diff)
parentac07d0f5ab16bb9e8bbbabb589d1c7d36817baa9 (diff)
Merge "Merge Android R"
Diffstat (limited to 'libs/binder/IAppOpsService.cpp')
-rw-r--r--libs/binder/IAppOpsService.cpp87
1 files changed, 62 insertions, 25 deletions
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index e5f0a11aa0..cd78866624 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -48,12 +48,17 @@ public:
return reply.readInt32();
}
- virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) {
+ virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName,
+ const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp,
+ const String16& message) {
Parcel data, reply;
data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
data.writeInt32(code);
data.writeInt32(uid);
data.writeString16(packageName);
+ data.writeString16(attributionTag);
+ data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0);
+ data.writeString16(message);
remote()->transact(NOTE_OPERATION_TRANSACTION, data, &reply);
// fail on exception
if (reply.readExceptionCode() != 0) return MODE_ERRORED;
@@ -61,14 +66,18 @@ public:
}
virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
- const String16& packageName, bool startIfModeDefault) {
+ const String16& packageName, const std::optional<String16>& attributionTag,
+ bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message) {
Parcel data, reply;
data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
data.writeStrongBinder(token);
data.writeInt32(code);
data.writeInt32(uid);
data.writeString16(packageName);
+ data.writeString16(attributionTag);
data.writeInt32(startIfModeDefault ? 1 : 0);
+ data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0);
+ data.writeString16(message);
remote()->transact(START_OPERATION_TRANSACTION, data, &reply);
// fail on exception
if (reply.readExceptionCode() != 0) return MODE_ERRORED;
@@ -76,13 +85,14 @@ public:
}
virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
- const String16& packageName) {
+ const String16& packageName, const std::optional<String16>& attributionTag) {
Parcel data, reply;
data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
data.writeStrongBinder(token);
data.writeInt32(code);
data.writeInt32(uid);
data.writeString16(packageName);
+ data.writeString16(attributionTag);
remote()->transact(FINISH_OPERATION_TRANSACTION, data, &reply);
}
@@ -103,17 +113,6 @@ public:
remote()->transact(STOP_WATCHING_MODE_TRANSACTION, data, &reply);
}
- virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) {
- Parcel data, reply;
- data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
- data.writeStrongBinder(clientToken);
- remote()->transact(GET_TOKEN_TRANSACTION, data, &reply);
- // fail on exception
- if (reply.readExceptionCode() != 0) return nullptr;
- return reply.readStrongBinder();
- }
-
-
virtual int32_t permissionToOpCode(const String16& permission) {
Parcel data, reply;
data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
@@ -139,6 +138,25 @@ public:
}
return reply.readInt32();
}
+
+ virtual void setCameraAudioRestriction(int32_t mode) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
+ data.writeInt32(mode);
+ remote()->transact(SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION, data, &reply);
+ }
+
+ virtual bool shouldCollectNotes(int32_t opCode) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
+ data.writeInt32(opCode);
+ remote()->transact(SHOULD_COLLECT_NOTES_TRANSACTION, data, &reply);
+ // fail on exception
+ if (reply.readExceptionCode() != 0) {
+ return false;
+ }
+ return reply.readBool();
+ }
};
IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService");
@@ -166,7 +184,12 @@ status_t BnAppOpsService::onTransact(
int32_t code = data.readInt32();
int32_t uid = data.readInt32();
String16 packageName = data.readString16();
- int32_t res = noteOperation(code, uid, packageName);
+ std::optional<String16> attributionTag;
+ data.readString16(&attributionTag);
+ bool shouldCollectAsyncNotedOp = data.readInt32() == 1;
+ String16 message = data.readString16();
+ int32_t res = noteOperation(code, uid, packageName, attributionTag,
+ shouldCollectAsyncNotedOp, message);
reply->writeNoException();
reply->writeInt32(res);
return NO_ERROR;
@@ -177,8 +200,13 @@ status_t BnAppOpsService::onTransact(
int32_t code = data.readInt32();
int32_t uid = data.readInt32();
String16 packageName = data.readString16();
+ std::optional<String16> attributionTag;
+ data.readString16(&attributionTag);
bool startIfModeDefault = data.readInt32() == 1;
- int32_t res = startOperation(token, code, uid, packageName, startIfModeDefault);
+ bool shouldCollectAsyncNotedOp = data.readInt32() == 1;
+ String16 message = data.readString16();
+ int32_t res = startOperation(token, code, uid, packageName, attributionTag,
+ startIfModeDefault, shouldCollectAsyncNotedOp, message);
reply->writeNoException();
reply->writeInt32(res);
return NO_ERROR;
@@ -189,7 +217,9 @@ status_t BnAppOpsService::onTransact(
int32_t code = data.readInt32();
int32_t uid = data.readInt32();
String16 packageName = data.readString16();
- finishOperation(token, code, uid, packageName);
+ std::optional<String16> attributionTag;
+ data.readString16(&attributionTag);
+ finishOperation(token, code, uid, packageName, attributionTag);
reply->writeNoException();
return NO_ERROR;
} break;
@@ -209,14 +239,6 @@ status_t BnAppOpsService::onTransact(
reply->writeNoException();
return NO_ERROR;
} break;
- case GET_TOKEN_TRANSACTION: {
- CHECK_INTERFACE(IAppOpsService, data, reply);
- sp<IBinder> clientToken = data.readStrongBinder();
- sp<IBinder> token = getToken(clientToken);
- reply->writeNoException();
- reply->writeStrongBinder(token);
- return NO_ERROR;
- } break;
case PERMISSION_TO_OP_CODE_TRANSACTION: {
CHECK_INTERFACE(IAppOpsService, data, reply);
String16 permission = data.readString16();
@@ -236,6 +258,21 @@ status_t BnAppOpsService::onTransact(
reply->writeInt32(res);
return NO_ERROR;
} break;
+ case SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION: {
+ CHECK_INTERFACE(IAppOpsService, data, reply);
+ const int32_t mode = data.readInt32();
+ setCameraAudioRestriction(mode);
+ reply->writeNoException();
+ return NO_ERROR;
+ } break;
+ case SHOULD_COLLECT_NOTES_TRANSACTION: {
+ CHECK_INTERFACE(IAppOpsService, data, reply);
+ int32_t opCode = data.readInt32();
+ bool shouldCollect = shouldCollectNotes(opCode);
+ reply->writeNoException();
+ reply->writeBool(shouldCollect);
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}