summaryrefslogtreecommitdiff
path: root/runtime/base/file_utils.cc
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2018-03-28 10:26:07 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-03-28 10:26:07 +0000
commitb38988a227534ae17045dadedc24d2131d59b42d (patch)
tree4aa18d4de72ef2e614d9459234a979bff69bc7ba /runtime/base/file_utils.cc
parent981d6b58c81c20f7d5f7d5352c30c2d916c2e60b (diff)
parent8e1a7cb303d7c8f763dfb99ae311b820996b1ab4 (diff)
Merge "Revert "Revert "Allow hidden API access from system libraries"""
Diffstat (limited to 'runtime/base/file_utils.cc')
-rw-r--r--runtime/base/file_utils.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/base/file_utils.cc b/runtime/base/file_utils.cc
index 1cb3b9c380..2b3e360650 100644
--- a/runtime/base/file_utils.cc
+++ b/runtime/base/file_utils.cc
@@ -319,4 +319,21 @@ bool LocationIsOnSystem(const char* location) {
return path != nullptr && android::base::StartsWith(path.get(), GetAndroidRoot().c_str());
}
+bool LocationIsOnSystemFramework(const char* location) {
+ std::string error_msg;
+ std::string root_path = GetAndroidRootSafe(&error_msg);
+ if (root_path.empty()) {
+ // Could not find Android root.
+ // TODO(dbrazdil): change to stricter GetAndroidRoot() once b/76452688 is resolved.
+ return false;
+ }
+ std::string framework_path = root_path + "/framework/";
+
+ // Warning: Bionic implementation of realpath() allocates > 12KB on the stack.
+ // Do not run this code on a small stack, e.g. in signal handler.
+ UniqueCPtr<const char[]> path(realpath(location, nullptr));
+ return path != nullptr &&
+ android::base::StartsWith(path.get(), framework_path.c_str());
+}
+
} // namespace art