OperationResult implements Parcelable interface am: 9ec9270dbb am: 62e4fa28a9 am: 20f94c8919
am: 24db93b202

Change-Id: Iabeaa0e39c7c4c51fc1cc7a26dca2f5721b67507
diff --git a/keystore/IKeystoreService.cpp b/keystore/IKeystoreService.cpp
index fc2280e..5bc6a1e 100644
--- a/keystore/IKeystoreService.cpp
+++ b/keystore/IKeystoreService.cpp
@@ -55,7 +55,8 @@
 OperationResult::~OperationResult() {
 }
 
-void OperationResult::readFromParcel(const Parcel& in) {
+status_t OperationResult::readFromParcel(const Parcel* inn) {
+    const Parcel& in = *inn;
     resultCode = in.readInt32();
     token = in.readStrongBinder();
     handle = static_cast<keymaster_operation_handle_t>(in.readInt64());
@@ -77,9 +78,10 @@
         }
     }
     outParams.readFromParcel(in);
+    return OK;
 }
 
-void OperationResult::writeToParcel(Parcel* out) const {
+status_t OperationResult::writeToParcel(Parcel* out) const {
     out->writeInt32(resultCode);
     out->writeStrongBinder(token);
     out->writeInt64(handle);
@@ -94,6 +96,7 @@
         }
     }
     outParams.writeToParcel(out);
+    return OK;
 }
 
 ExportResult::ExportResult() : resultCode(0), exportData(NULL), dataLength(0) {
@@ -1161,9 +1164,8 @@
             result->resultCode = KM_ERROR_UNKNOWN_ERROR;
             return;
         }
-        if (reply.readInt32() != 0) {
-            result->readFromParcel(reply);
-        }
+
+        reply.readParcelable(result);
     }
 
     virtual void update(const sp<IBinder>& token, const KeymasterArguments& params,
@@ -1190,9 +1192,8 @@
             result->resultCode = KM_ERROR_UNKNOWN_ERROR;
             return;
         }
-        if (reply.readInt32() != 0) {
-            result->readFromParcel(reply);
-        }
+
+        reply.readParcelable(result);
     }
 
     virtual void finish(const sp<IBinder>& token, const KeymasterArguments& params,
@@ -1222,9 +1223,8 @@
             result->resultCode = KM_ERROR_UNKNOWN_ERROR;
             return;
         }
-        if (reply.readInt32() != 0) {
-            result->readFromParcel(reply);
-        }
+
+        reply.readParcelable(result);
     }
 
     virtual int32_t abort(const sp<IBinder>& token)
@@ -1754,8 +1754,7 @@
             OperationResult result;
             begin(token, name, purpose, pruneable, args, entropy, entropyLength, uid, &result);
             reply->writeNoException();
-            reply->writeInt32(1);
-            result.writeToParcel(reply);
+            reply->writeParcelable(result);
 
             return NO_ERROR;
         }
@@ -1772,8 +1771,7 @@
             OperationResult result;
             update(token, args, buf, bufLength, &result);
             reply->writeNoException();
-            reply->writeInt32(1);
-            result.writeToParcel(reply);
+            reply->writeParcelable(result);
 
             return NO_ERROR;
         }
@@ -1793,8 +1791,7 @@
             OperationResult result;
             finish(token, args, signature, signatureLength, entropy, entropyLength,  &result);
             reply->writeNoException();
-            reply->writeInt32(1);
-            result.writeToParcel(reply);
+            reply->writeParcelable(result);
 
             return NO_ERROR;
         }
diff --git a/keystore/include/keystore/IKeystoreService.h b/keystore/include/keystore/IKeystoreService.h
index f5d812a..dbd6e25 100644
--- a/keystore/include/keystore/IKeystoreService.h
+++ b/keystore/include/keystore/IKeystoreService.h
@@ -53,11 +53,11 @@
 };
 
 // struct for serializing the results of begin/update/finish
-struct OperationResult {
+struct OperationResult : public ::android::Parcelable {
     OperationResult();
     ~OperationResult();
-    void readFromParcel(const Parcel& in);
-    void writeToParcel(Parcel* out) const;
+    status_t readFromParcel(const Parcel* in) override;
+    status_t writeToParcel(Parcel* out) const override;
 
     int resultCode;
     sp<IBinder> token;