Revert "[DeviceAware] Use AttributionSourceState in native AppOp..."

Revert submission 24499968-appops-deviceid

Reason for revert: Causing perf regression b/308786093

Reverted changes: /q/submissionid:24499968-appops-deviceid

Change-Id: I7e0da4a493b85e1296b41db09e114dd0c8b9e244
diff --git a/libs/permission/IAppOpsService.cpp b/libs/permission/IAppOpsService.cpp
index 33dd24d..7f235a4 100644
--- a/libs/permission/IAppOpsService.cpp
+++ b/libs/permission/IAppOpsService.cpp
@@ -26,8 +26,6 @@
 
 namespace android {
 
-using android::content::AttributionSourceState;
-
 // ----------------------------------------------------------------------
 
 class BpAppOpsService : public BpInterface<IAppOpsService>
@@ -38,30 +36,31 @@
     {
     }
 
-    virtual int32_t checkOperationWithState(int32_t code,
-                const AttributionSourceState &attributionSourceState) {
+    virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) {
         Parcel data, reply;
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
         data.writeInt32(code);
-        data.writeParcelable(attributionSourceState);
-        remote()->transact(CHECK_OPERATION_WITH_STATE_TRANSACTION, data, &reply);
+        data.writeInt32(uid);
+        data.writeString16(packageName);
+        remote()->transact(CHECK_OPERATION_TRANSACTION, data, &reply);
         // fail on exception
         if (reply.readExceptionCode() != 0) return MODE_ERRORED;
         return reply.readInt32();
     }
 
-    virtual int32_t noteOperationWithState(int32_t code,
-                const AttributionSourceState& attributionSourceState,
-                bool shouldCollectAsyncNotedOp, const String16& message,
-                bool shouldCollectMessage) {
+    virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName,
+                const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp,
+                const String16& message, bool shouldCollectMessage) {
         Parcel data, reply;
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
         data.writeInt32(code);
-        data.writeParcelable(attributionSourceState);
+        data.writeInt32(uid);
+        data.writeString16(packageName);
+        data.writeString16(attributionTag);
         data.writeBool(shouldCollectAsyncNotedOp);
         data.writeString16(message);
         data.writeBool(shouldCollectMessage);
-        remote()->transact(NOTE_OPERATION_WITH_STATE_TRANSACTION, data, &reply);
+        remote()->transact(NOTE_OPERATION_TRANSACTION, data, &reply);
         // fail on exception
         if (reply.readExceptionCode() != 0) return MODE_ERRORED;
         // TODO b/184855056: extract to class
@@ -70,20 +69,22 @@
         return reply.readInt32();
     }
 
-    virtual int32_t startOperationWithState(const sp<IBinder>& token, int32_t code,
-                const AttributionSourceState& attributionSourceState, bool startIfModeDefault,
-                bool shouldCollectAsyncNotedOp, const String16& message,
+    virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
+                const String16& packageName, const std::optional<String16>& attributionTag,
+                bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message,
                 bool shouldCollectMessage) {
         Parcel data, reply;
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
         data.writeStrongBinder(token);
         data.writeInt32(code);
-        data.writeParcelable(attributionSourceState);
+        data.writeInt32(uid);
+        data.writeString16(packageName);
+        data.writeString16(attributionTag);
         data.writeBool(startIfModeDefault);
         data.writeBool(shouldCollectAsyncNotedOp);
         data.writeString16(message);
         data.writeBool(shouldCollectMessage);
-        remote()->transact(START_OPERATION_WITH_STATE_TRANSACTION, data, &reply);
+        remote()->transact(START_OPERATION_TRANSACTION, data, &reply);
         // fail on exception
         if (reply.readExceptionCode() != 0) return MODE_ERRORED;
         // TODO b/184855056: extract to class
@@ -92,14 +93,16 @@
         return reply.readInt32();
     }
 
-    virtual void finishOperationWithState(const sp<IBinder>& token, int32_t code,
-                const AttributionSourceState& attributionSourceState) {
+    virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
+            const String16& packageName, const std::optional<String16>& attributionTag) {
         Parcel data, reply;
         data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
         data.writeStrongBinder(token);
         data.writeInt32(code);
-        data.writeParcelable(attributionSourceState);
-        remote()->transact(FINISH_OPERATION_WITH_STATE_TRANSACTION, data, &reply);
+        data.writeInt32(uid);
+        data.writeString16(packageName);
+        data.writeString16(attributionTag);
+        remote()->transact(FINISH_OPERATION_TRANSACTION, data, &reply);
     }
 
     virtual void startWatchingMode(int32_t op, const String16& packageName,
@@ -186,65 +189,59 @@
 {
     //printf("AppOpsService received: "); data.print();
     switch(code) {
-        case CHECK_OPERATION_WITH_STATE_TRANSACTION: {
+        case CHECK_OPERATION_TRANSACTION: {
             CHECK_INTERFACE(IAppOpsService, data, reply);
             int32_t code = data.readInt32();
-            AttributionSourceState attributionSourceState;
-            status_t status = data.readParcelable(&attributionSourceState);
-            if (status != NO_ERROR) {
-                return status;
-            }
-            int32_t res = checkOperationWithState(code, attributionSourceState);
+            int32_t uid = data.readInt32();
+            String16 packageName = data.readString16();
+            int32_t res = checkOperation(code, uid, packageName);
             reply->writeNoException();
             reply->writeInt32(res);
             return NO_ERROR;
         } break;
-        case NOTE_OPERATION_WITH_STATE_TRANSACTION: {
+        case NOTE_OPERATION_TRANSACTION: {
             CHECK_INTERFACE(IAppOpsService, data, reply);
             int32_t code = data.readInt32();
-            AttributionSourceState attributionSourceState;
-            status_t status = data.readParcelable(&attributionSourceState);
-            if (status != NO_ERROR) {
-                return status;
-            }
+            int32_t uid = data.readInt32();
+            String16 packageName = data.readString16();
+            std::optional<String16> attributionTag;
+            data.readString16(&attributionTag);
             bool shouldCollectAsyncNotedOp = data.readBool();
             String16 message = data.readString16();
             bool shouldCollectMessage = data.readBool();
-            int32_t res = noteOperationWithState(code, attributionSourceState,
+            int32_t res = noteOperation(code, uid, packageName, attributionTag,
                     shouldCollectAsyncNotedOp, message, shouldCollectMessage);
             reply->writeNoException();
             reply->writeInt32(res);
             return NO_ERROR;
         } break;
-        case START_OPERATION_WITH_STATE_TRANSACTION: {
+        case START_OPERATION_TRANSACTION: {
             CHECK_INTERFACE(IAppOpsService, data, reply);
             sp<IBinder> token = data.readStrongBinder();
             int32_t code = data.readInt32();
-            AttributionSourceState attributionSourceState;
-            status_t status = data.readParcelable(&attributionSourceState);
-            if (status != NO_ERROR) {
-                return status;
-            }
+            int32_t uid = data.readInt32();
+            String16 packageName = data.readString16();
+            std::optional<String16> attributionTag;
+            data.readString16(&attributionTag);
             bool startIfModeDefault = data.readBool();
             bool shouldCollectAsyncNotedOp = data.readBool();
             String16 message = data.readString16();
             bool shouldCollectMessage = data.readBool();
-            int32_t res = startOperationWithState(token, code, attributionSourceState,
+            int32_t res = startOperation(token, code, uid, packageName, attributionTag,
                     startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage);
             reply->writeNoException();
             reply->writeInt32(res);
             return NO_ERROR;
         } break;
-        case FINISH_OPERATION_WITH_STATE_TRANSACTION: {
+        case FINISH_OPERATION_TRANSACTION: {
             CHECK_INTERFACE(IAppOpsService, data, reply);
             sp<IBinder> token = data.readStrongBinder();
             int32_t code = data.readInt32();
-            AttributionSourceState attributionSourceState;
-            status_t status = data.readParcelable(&attributionSourceState);
-            if (status != NO_ERROR) {
-                return status;
-            }
-            finishOperationWithState(token, code, attributionSourceState);
+            int32_t uid = data.readInt32();
+            String16 packageName = data.readString16();
+            std::optional<String16> attributionTag;
+            data.readString16(&attributionTag);
+            finishOperation(token, code, uid, packageName, attributionTag);
             reply->writeNoException();
             return NO_ERROR;
         } break;