Merge "idmap2: Set aidl_return to true on success" into rvc-dev am: 6700d5e48c am: 8f8122eed5 am: b0f11fa2cc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11795074 Change-Id: I873e5f0e0ac793251d402dc6a7703659f442bf23
This commit is contained in:
@@ -29,7 +29,7 @@ using android::idmap2::Result;
|
||||
using android::idmap2::Unit;
|
||||
|
||||
Result<Unit> Verify(const std::string& idmap_path, const std::string& target_path,
|
||||
const std::string& overlay_path, uint32_t fulfilled_policies,
|
||||
const std::string& overlay_path, PolicyBitmask fulfilled_policies,
|
||||
bool enforce_overlayable) {
|
||||
SYSTRACE << "Verify " << idmap_path;
|
||||
std::ifstream fin(idmap_path);
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
#ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_
|
||||
#define IDMAP2_IDMAP2_COMMAND_UTILS_H_
|
||||
|
||||
#include "idmap2/PolicyUtils.h"
|
||||
#include "idmap2/Result.h"
|
||||
|
||||
android::idmap2::Result<android::idmap2::Unit> Verify(const std::string& idmap_path,
|
||||
const std::string& target_path,
|
||||
const std::string& overlay_path,
|
||||
uint32_t fulfilled_policies,
|
||||
PolicyBitmask fulfilled_policies,
|
||||
bool enforce_overlayable);
|
||||
|
||||
#endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_
|
||||
|
||||
@@ -70,12 +70,12 @@ PolicyBitmask ConvertAidlArgToPolicyBitmask(int32_t arg) {
|
||||
}
|
||||
|
||||
Status GetCrc(const std::string& apk_path, uint32_t* out_crc) {
|
||||
const auto overlay_zip = ZipFile::Open(apk_path);
|
||||
if (!overlay_zip) {
|
||||
const auto zip = ZipFile::Open(apk_path);
|
||||
if (!zip) {
|
||||
return error(StringPrintf("failed to open apk %s", apk_path.c_str()));
|
||||
}
|
||||
|
||||
const auto crc = GetPackageCrc(*overlay_zip);
|
||||
const auto crc = GetPackageCrc(*zip);
|
||||
if (!crc) {
|
||||
return error(crc.GetErrorMessage());
|
||||
}
|
||||
@@ -121,6 +121,7 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path,
|
||||
bool* _aidl_return) {
|
||||
SYSTRACE << "Idmap2Service::verifyIdmap " << overlay_apk_path;
|
||||
assert(_aidl_return);
|
||||
|
||||
const std::string idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_apk_path);
|
||||
std::ifstream fin(idmap_path);
|
||||
const std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(fin);
|
||||
@@ -156,13 +157,10 @@ Status Idmap2Service::verifyIdmap(const std::string& target_apk_path,
|
||||
|
||||
auto up_to_date =
|
||||
header->IsUpToDate(target_apk_path.c_str(), overlay_apk_path.c_str(), target_crc, overlay_crc,
|
||||
fulfilled_policies, enforce_overlayable);
|
||||
if (!up_to_date) {
|
||||
*_aidl_return = false;
|
||||
return error(up_to_date.GetErrorMessage());
|
||||
}
|
||||
ConvertAidlArgToPolicyBitmask(fulfilled_policies), enforce_overlayable);
|
||||
|
||||
return ok();
|
||||
*_aidl_return = static_cast<bool>(up_to_date);
|
||||
return *_aidl_return ? ok() : error(up_to_date.GetErrorMessage());
|
||||
}
|
||||
|
||||
Status Idmap2Service::createIdmap(const std::string& target_apk_path,
|
||||
|
||||
@@ -141,9 +141,9 @@ class IdmapHeader {
|
||||
// field *must* be incremented. Because of this, we know that if the idmap
|
||||
// header is up-to-date the entire file is up-to-date.
|
||||
Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path,
|
||||
uint32_t fulfilled_policies, bool enforce_overlayable) const;
|
||||
PolicyBitmask fulfilled_policies, bool enforce_overlayable) const;
|
||||
Result<Unit> IsUpToDate(const char* target_path, const char* overlay_path, uint32_t target_crc,
|
||||
uint32_t overlay_crc, uint32_t fulfilled_policies,
|
||||
uint32_t overlay_crc, PolicyBitmask fulfilled_policies,
|
||||
bool enforce_overlayable) const;
|
||||
|
||||
void accept(Visitor* v) const;
|
||||
|
||||
@@ -115,8 +115,7 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s
|
||||
uint8_t enforce_overlayable;
|
||||
if (!Read32(stream, &idmap_header->magic_) || !Read32(stream, &idmap_header->version_) ||
|
||||
!Read32(stream, &idmap_header->target_crc_) || !Read32(stream, &idmap_header->overlay_crc_) ||
|
||||
!Read32(stream, &idmap_header->fulfilled_policies_) ||
|
||||
!Read8(stream, &enforce_overlayable) ||
|
||||
!Read32(stream, &idmap_header->fulfilled_policies_) || !Read8(stream, &enforce_overlayable) ||
|
||||
!ReadString256(stream, idmap_header->target_path_) ||
|
||||
!ReadString256(stream, idmap_header->overlay_path_)) {
|
||||
return nullptr;
|
||||
@@ -134,7 +133,8 @@ std::unique_ptr<const IdmapHeader> IdmapHeader::FromBinaryStream(std::istream& s
|
||||
}
|
||||
|
||||
Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path,
|
||||
uint32_t fulfilled_policies, bool enforce_overlayable) const {
|
||||
PolicyBitmask fulfilled_policies,
|
||||
bool enforce_overlayable) const {
|
||||
const std::unique_ptr<const ZipFile> target_zip = ZipFile::Open(target_path);
|
||||
if (!target_zip) {
|
||||
return Error("failed to open target %s", target_path);
|
||||
@@ -161,7 +161,8 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla
|
||||
|
||||
Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overlay_path,
|
||||
uint32_t target_crc, uint32_t overlay_crc,
|
||||
uint32_t fulfilled_policies, bool enforce_overlayable) const {
|
||||
PolicyBitmask fulfilled_policies,
|
||||
bool enforce_overlayable) const {
|
||||
if (magic_ != kIdmapMagic) {
|
||||
return Error("bad magic: actual 0x%08x, expected 0x%08x", magic_, kIdmapMagic);
|
||||
}
|
||||
@@ -187,8 +188,7 @@ Result<Unit> IdmapHeader::IsUpToDate(const char* target_path, const char* overla
|
||||
|
||||
if (enforce_overlayable != enforce_overlayable_) {
|
||||
return Error("bad enforce overlayable: idmap version %s, file system version %s",
|
||||
enforce_overlayable ? "true" : "false",
|
||||
enforce_overlayable_ ? "true" : "false");
|
||||
enforce_overlayable ? "true" : "false", enforce_overlayable_ ? "true" : "false");
|
||||
}
|
||||
|
||||
if (strcmp(target_path, target_path_) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user