summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/hidden_api.cc4
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc8
-rw-r--r--runtime/runtime.h19
3 files changed, 29 insertions, 2 deletions
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index e41d1d3eb9..5729800bb0 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -174,6 +174,10 @@ void MemberSignature::LogAccessToEventLog(AccessMethod access_method, Action act
if (action_taken == kDeny) {
log_maker.AddTaggedData(FIELD_HIDDEN_API_ACCESS_DENIED, 1);
}
+ const std::string& package_name = Runtime::Current()->GetProcessPackageName();
+ if (!package_name.empty()) {
+ log_maker.SetPackageName(package_name);
+ }
std::ostringstream signature_str;
Dump(signature_str);
log_maker.AddTaggedData(FIELD_HIDDEN_API_SIGNATURE, signature_str.str());
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 3227c69305..9b3fd16ac0 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -675,6 +675,13 @@ static void VMRuntime_setDedupeHiddenApiWarnings(JNIEnv* env ATTRIBUTE_UNUSED,
Runtime::Current()->SetDedupeHiddenApiWarnings(dedupe);
}
+static void VMRuntime_setProcessPackageName(JNIEnv* env,
+ jclass klass ATTRIBUTE_UNUSED,
+ jstring java_package_name) {
+ ScopedUtfChars package_name(env, java_package_name);
+ Runtime::Current()->SetProcessPackageName(package_name.c_str());
+}
+
static JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"),
NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"),
@@ -718,6 +725,7 @@ static JNINativeMethod gMethods[] = {
NATIVE_METHOD(VMRuntime, didPruneDalvikCache, "()Z"),
NATIVE_METHOD(VMRuntime, setSystemDaemonThreadPriority, "()V"),
NATIVE_METHOD(VMRuntime, setDedupeHiddenApiWarnings, "(Z)V"),
+ NATIVE_METHOD(VMRuntime, setProcessPackageName, "(Ljava/lang/String;)V"),
};
void register_dalvik_system_VMRuntime(JNIEnv* env) {
diff --git a/runtime/runtime.h b/runtime/runtime.h
index ca93e2421f..a98e8a81ed 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -579,6 +579,18 @@ class Runtime {
return hidden_api_access_event_log_rate_;
}
+ const std::string& GetProcessPackageName() const {
+ return process_package_name_;
+ }
+
+ void SetProcessPackageName(const char* package_name) {
+ if (package_name == nullptr) {
+ process_package_name_.clear();
+ } else {
+ process_package_name_ = package_name;
+ }
+ }
+
bool IsDexFileFallbackEnabled() const {
return allow_dex_file_fallback_;
}
@@ -1031,10 +1043,13 @@ class Runtime {
// when there is a warning. This is only used for testing.
bool always_set_hidden_api_warning_flag_;
- // How often to log hidden API access to the event log. An integer between 0 (never)
- // and 0x10000 (always).
+ // How often to log hidden API access to the event log. An integer between 0
+ // (never) and 0x10000 (always).
uint32_t hidden_api_access_event_log_rate_;
+ // The package of the app running in this process.
+ std::string process_package_name_;
+
// Whether threads should dump their native stack on SIGQUIT.
bool dump_native_stack_on_sig_quit_;