diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-10 00:28:59 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-10 00:28:59 +0000 |
commit | cf707f029e1400eef15716df22389a582323f78d (patch) | |
tree | bdbf69cf21cd64d60215785023da955942ba3a74 | |
parent | 8643fba4b161fb76be157c85690f2f43a4be26c9 (diff) | |
parent | d2c816eb179071a39247c6fdcf3e4de278f9231b (diff) | |
download | apex-android13-d3-s1-release.tar.gz |
Snap for 9274385 from d2c816eb179071a39247c6fdcf3e4de278f9231b to tm-d3-releaseandroid-13.0.0_r57android13-d3-s1-release
Change-Id: I7295764085077442c1c74d19f69333cf42598ea1
-rw-r--r-- | apexd/apex_file_repository.cpp | 10 | ||||
-rw-r--r-- | apexd/apex_file_repository.h | 10 | ||||
-rw-r--r-- | apexd/apex_file_repository_test.cpp | 7 | ||||
-rw-r--r-- | apexd/apexd.cpp | 5 |
4 files changed, 16 insertions, 16 deletions
diff --git a/apexd/apex_file_repository.cpp b/apexd/apex_file_repository.cpp index 43b6f6e9..834eef53 100644 --- a/apexd/apex_file_repository.cpp +++ b/apexd/apex_file_repository.cpp @@ -279,7 +279,7 @@ Result<int> ApexFileRepository::AddBlockApex( if (overrides.last_update_seconds.has_value() || overrides.block_apex_root_digest.has_value()) { - block_apex_overrides_.emplace(name, std::move(overrides)); + block_apex_overrides_.emplace(apex_path, std::move(overrides)); } // Depending on whether the APEX was a factory version in the host or not, @@ -412,8 +412,8 @@ Result<const std::string> ApexFileRepository::GetDataPath( } std::optional<std::string> ApexFileRepository::GetBlockApexRootDigest( - const std::string& name) const { - auto it = block_apex_overrides_.find(name); + const std::string& path) const { + auto it = block_apex_overrides_.find(path); if (it == block_apex_overrides_.end()) { return std::nullopt; } @@ -421,8 +421,8 @@ std::optional<std::string> ApexFileRepository::GetBlockApexRootDigest( } std::optional<int64_t> ApexFileRepository::GetBlockApexLastUpdateSeconds( - const std::string& name) const { - auto it = block_apex_overrides_.find(name); + const std::string& path) const { + auto it = block_apex_overrides_.find(path); if (it == block_apex_overrides_.end()) { return std::nullopt; } diff --git a/apexd/apex_file_repository.h b/apexd/apex_file_repository.h index 1a1cf946..f90dcbc7 100644 --- a/apexd/apex_file_repository.h +++ b/apexd/apex_file_repository.h @@ -104,13 +104,13 @@ class ApexFileRepository final { android::base::Result<const std::string> GetDataPath( const std::string& name) const; - // Returns root digest of an apex with the given |name| for block apexes. + // Returns root digest of an apex with the given |path| for block apexes. std::optional<std::string> GetBlockApexRootDigest( - const std::string& name) const; + const std::string& path) const; - // Returns timestamp to be used for the block apex of the given |name|. + // Returns timestamp to be used for the block apex of the given |path|. std::optional<int64_t> GetBlockApexLastUpdateSeconds( - const std::string& name) const; + const std::string& path) const; // Checks whether there is a pre-installed version of an apex with the given // |name|. @@ -203,6 +203,8 @@ class ApexFileRepository final { std::optional<int64_t> last_update_seconds; }; + // Use "path" as key instead of APEX name because there can be multiple + // versions of sharedlibs APEXes. std::unordered_map<std::string, BlockApexOverride> block_apex_overrides_; }; diff --git a/apexd/apex_file_repository_test.cpp b/apexd/apex_file_repository_test.cpp index bf730923..272979f4 100644 --- a/apexd/apex_file_repository_test.cpp +++ b/apexd/apex_file_repository_test.cpp @@ -740,8 +740,7 @@ TEST_F(ApexFileRepositoryTestAddBlockApex, GetBlockApexRootDigest) { auto status = instance.AddBlockApex(metadata_partition_path); ASSERT_TRUE(IsOk(status)); - ASSERT_EQ(hex_root_digest, - instance.GetBlockApexRootDigest("com.android.apex.test_package")); + ASSERT_EQ(hex_root_digest, instance.GetBlockApexRootDigest(apex_foo_path)); } TEST_F(ApexFileRepositoryTestAddBlockApex, GetBlockApexLastUpdateSeconds) { @@ -767,8 +766,8 @@ TEST_F(ApexFileRepositoryTestAddBlockApex, GetBlockApexLastUpdateSeconds) { auto status = instance.AddBlockApex(metadata_partition_path); ASSERT_TRUE(IsOk(status)); - ASSERT_EQ(last_update_seconds, instance.GetBlockApexLastUpdateSeconds( - "com.android.apex.test_package")); + ASSERT_EQ(last_update_seconds, + instance.GetBlockApexLastUpdateSeconds(apex_foo_path)); } TEST_F(ApexFileRepositoryTestAddBlockApex, VerifyPublicKeyWhenAddingBlockApex) { diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp index b777f1f4..5cf19ad7 100644 --- a/apexd/apexd.cpp +++ b/apexd/apexd.cpp @@ -538,8 +538,7 @@ Result<MountedApexData> MountPackageImpl(const ApexFile& apex, << ": " << verity_data.error(); } if (instance.IsBlockApex(apex)) { - auto root_digest = - instance.GetBlockApexRootDigest(apex.GetManifest().name()); + auto root_digest = instance.GetBlockApexRootDigest(apex.GetPath()); if (root_digest.has_value() && root_digest.value() != verity_data->root_digest) { return Error() << "Failed to verify Apex Verity data for " << full_path @@ -3438,7 +3437,7 @@ void CollectApexInfoList(std::ostream& os, } std::optional<int64_t> mtime = - instance.GetBlockApexLastUpdateSeconds(apex.GetManifest().name()); + instance.GetBlockApexLastUpdateSeconds(apex.GetPath()); if (!mtime.has_value()) { struct stat stat_buf; if (stat(apex.GetPath().c_str(), &stat_buf) == 0) { |