KeyAttestationPackageInfo.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. **
  3. ** Copyright 2016, The Android Open Source Project
  4. **
  5. ** Licensed under the Apache License, Version 2.0 (the "License");
  6. ** you may not use this file except in compliance with the License.
  7. ** You may obtain a copy of the License at
  8. **
  9. ** http://www.apache.org/licenses/LICENSE-2.0
  10. **
  11. ** Unless required by applicable law or agreed to in writing, software
  12. ** distributed under the License is distributed on an "AS IS" BASIS,
  13. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ** See the License for the specific language governing permissions and
  15. ** limitations under the License.
  16. */
  17. #include "include/keystore/KeyAttestationPackageInfo.h"
  18. #include <binder/Parcel.h>
  19. namespace android {
  20. namespace security {
  21. namespace keymaster {
  22. KeyAttestationPackageInfo::KeyAttestationPackageInfo() = default;
  23. KeyAttestationPackageInfo::KeyAttestationPackageInfo(const String16& packageName,
  24. int64_t versionCode,
  25. SharedSignaturesVector signatures)
  26. : packageName_(new String16(packageName)), versionCode_(versionCode), signatures_(signatures) {}
  27. status_t KeyAttestationPackageInfo::writeToParcel(Parcel* parcel) const {
  28. auto rc = parcel->writeString16(packageName_);
  29. if (rc != NO_ERROR) return rc;
  30. rc = parcel->writeInt64(versionCode_);
  31. if (rc != NO_ERROR) return rc;
  32. return parcel->writeParcelableVector(signatures_);
  33. }
  34. status_t KeyAttestationPackageInfo::readFromParcel(const Parcel* parcel) {
  35. auto rc = parcel->readString16(&packageName_);
  36. if (rc != NO_ERROR) return rc;
  37. rc = parcel->readInt64(&versionCode_);
  38. if (rc != NO_ERROR) return rc;
  39. std::unique_ptr<SignaturesVector> temp_vector;
  40. rc = parcel->readParcelableVector(&temp_vector);
  41. if (rc != NO_ERROR) return rc;
  42. signatures_.reset(temp_vector.release());
  43. return NO_ERROR;
  44. }
  45. } // namespace keymaster
  46. } // namespace security
  47. } // namespace android