summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author hg.choi <hg.choi@lge.com> 2020-01-15 17:12:48 +0900
committer Ryan Mitchell <rtmitchell@google.com> 2020-03-26 12:35:58 -0700
commita3a68132b5c5eed58813a631682dcbc79b9916e9 (patch)
treee135f9a96a2148dd32c5d80297499dc0d615e4ce
parent393c9121cea9e03762b3e5460d523b9d5393f6f7 (diff)
Consider target path when verifyIdmap.
Updating new version package with changing resource id, Overlay idmap still retain same resource id and target path of prebuilt package. Consequentially overlay can not apply to new update resource id. As is : VerifyIdmap only verify uptodate of idmap. To be : Verify change of target path. Bug: 147794117 Bug: 150877400 Test: idmap2_tests Change-Id: I2ed6b5ba49aeb1b24625866daefea56c9766baef
-rw-r--r--cmds/idmap2/idmap2/CreateMultiple.cpp2
-rw-r--r--cmds/idmap2/idmap2d/Idmap2Service.cpp12
-rw-r--r--cmds/idmap2/idmap2d/Idmap2Service.h3
-rw-r--r--cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl7
-rw-r--r--services/core/java/com/android/server/om/IdmapDaemon.java5
-rw-r--r--services/core/java/com/android/server/om/IdmapManager.java2
6 files changed, 21 insertions, 10 deletions
diff --git a/cmds/idmap2/idmap2/CreateMultiple.cpp b/cmds/idmap2/idmap2/CreateMultiple.cpp
index ba4ca62826b6..4b70acc2969c 100644
--- a/cmds/idmap2/idmap2/CreateMultiple.cpp
+++ b/cmds/idmap2/idmap2/CreateMultiple.cpp
@@ -22,6 +22,7 @@
#include <ostream>
#include <vector>
+#include "Commands.h"
#include "android-base/stringprintf.h"
#include "idmap2/BinaryStreamVisitor.h"
#include "idmap2/CommandLineOptions.h"
@@ -30,7 +31,6 @@
#include "idmap2/Policies.h"
#include "idmap2/PolicyUtils.h"
#include "idmap2/SysTrace.h"
-#include "Commands.h"
using android::ApkAssets;
using android::base::StringPrintf;
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp
index 8f5e49d5b428..e55ea6c00545 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.cpp
+++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp
@@ -93,7 +93,8 @@ Status Idmap2Service::removeIdmap(const std::string& overlay_apk_path,
return ok();
}
-Status Idmap2Service::verifyIdmap(const std::string& overlay_apk_path,
+Status Idmap2Service::verifyIdmap(const std::string& target_apk_path,
+ const std::string& overlay_apk_path,
int32_t fulfilled_policies ATTRIBUTE_UNUSED,
bool enforce_overlayable ATTRIBUTE_UNUSED,
int32_t user_id ATTRIBUTE_UNUSED, bool* _aidl_return) {
@@ -103,10 +104,15 @@ Status Idmap2Service::verifyIdmap(const std::string& overlay_apk_path,
std::ifstream fin(idmap_path);
const std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(fin);
fin.close();
- *_aidl_return = header && header->IsUpToDate();
+ if (!header) {
+ *_aidl_return = false;
+ return error("failed to parse idmap header");
+ }
- // TODO(b/119328308): Check that the set of fulfilled policies of the overlay has not changed
+ *_aidl_return =
+ strcmp(header->GetTargetPath().data(), target_apk_path.data()) == 0 && header->IsUpToDate();
+ // TODO(b/119328308): Check that the set of fulfilled policies of the overlay has not changed
return ok();
}
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h
index b6f5136fc801..0ed55a1bb6a4 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.h
+++ b/cmds/idmap2/idmap2d/Idmap2Service.h
@@ -37,7 +37,8 @@ class Idmap2Service : public BinderService<Idmap2Service>, public BnIdmap2 {
binder::Status removeIdmap(const std::string& overlay_apk_path, int32_t user_id,
bool* _aidl_return) override;
- binder::Status verifyIdmap(const std::string& overlay_apk_path, int32_t fulfilled_policies,
+ binder::Status verifyIdmap(const std::string& target_apk_path,
+ const std::string& overlay_apk_path, int32_t fulfilled_policies,
bool enforce_overlayable, int32_t user_id,
bool* _aidl_return) override;
diff --git a/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl b/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
index f4cf65134023..156f1d70e015 100644
--- a/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
+++ b/cmds/idmap2/idmap2d/aidl/android/os/IIdmap2.aidl
@@ -22,8 +22,11 @@ package android.os;
interface IIdmap2 {
@utf8InCpp String getIdmapPath(@utf8InCpp String overlayApkPath, int userId);
boolean removeIdmap(@utf8InCpp String overlayApkPath, int userId);
- boolean verifyIdmap(@utf8InCpp String overlayApkPath, int fulfilledPolicies,
- boolean enforceOverlayable, int userId);
+ boolean verifyIdmap(@utf8InCpp String targetApkPath,
+ @utf8InCpp String overlayApkPath,
+ int fulfilledPolicies,
+ boolean enforceOverlayable,
+ int userId);
@nullable @utf8InCpp String createIdmap(@utf8InCpp String targetApkPath,
@utf8InCpp String overlayApkPath,
int fulfilledPolicies,
diff --git a/services/core/java/com/android/server/om/IdmapDaemon.java b/services/core/java/com/android/server/om/IdmapDaemon.java
index 20a4c75a1ce6..e8e383404bd6 100644
--- a/services/core/java/com/android/server/om/IdmapDaemon.java
+++ b/services/core/java/com/android/server/om/IdmapDaemon.java
@@ -116,10 +116,11 @@ class IdmapDaemon {
}
}
- boolean verifyIdmap(String overlayPath, int policies, boolean enforce, int userId)
+ boolean verifyIdmap(String targetPath, String overlayPath, int policies, boolean enforce,
+ int userId)
throws Exception {
try (Connection connection = connect()) {
- return mService.verifyIdmap(overlayPath, policies, enforce, userId);
+ return mService.verifyIdmap(targetPath, overlayPath, policies, enforce, userId);
}
}
diff --git a/services/core/java/com/android/server/om/IdmapManager.java b/services/core/java/com/android/server/om/IdmapManager.java
index 7c9be2dfacd6..43fc7ed0e39d 100644
--- a/services/core/java/com/android/server/om/IdmapManager.java
+++ b/services/core/java/com/android/server/om/IdmapManager.java
@@ -75,7 +75,7 @@ class IdmapManager {
try {
int policies = calculateFulfilledPolicies(targetPackage, overlayPackage, userId);
boolean enforce = enforceOverlayable(overlayPackage);
- if (mIdmapDaemon.verifyIdmap(overlayPath, policies, enforce, userId)) {
+ if (mIdmapDaemon.verifyIdmap(targetPath, overlayPath, policies, enforce, userId)) {
return true;
}
return mIdmapDaemon.createIdmap(targetPath, overlayPath, policies,