diff options
| author | 2019-12-09 16:13:39 -0800 | |
|---|---|---|
| committer | 2019-12-09 16:13:39 -0800 | |
| commit | 7eb1d4251a7ab41d9c88c1737ecff5671a54f614 (patch) | |
| tree | a12030211ccc35f7333bf995be6764d2708314a2 | |
| parent | 3fd00d0154e6f8ac660cab1a5f69ae03ce5a9564 (diff) | |
| parent | a9cc5cf85a9c254ae54900c302dd7bffab9e9ca4 (diff) | |
Merge "Add hook for JVMTI agent in system server" am: 957ac164ef
am: a9cc5cf85a
Change-Id: I59491078b65f4df90d0066adcc825f2303ee32e2
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ddd842ec3f09..ae773ca6d506 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -40,12 +40,12 @@ import android.database.sqlite.SQLiteCompatibilityWalFlags; import android.database.sqlite.SQLiteGlobal; import android.hardware.display.DisplayManagerInternal; import android.net.ConnectivityModuleConnector; -import android.net.Network; import android.net.NetworkStackClient; import android.net.TetheringManager; import android.os.BaseBundle; import android.os.Binder; import android.os.Build; +import android.os.Debug; import android.os.Environment; import android.os.FactoryTest; import android.os.FileUtils; @@ -497,6 +497,24 @@ public final class SystemServer { LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); // Prepare the thread pool for init tasks that can be parallelized SystemServerInitThreadPool.get(); + // Attach JVMTI agent if this is a debuggable build and the system property is set. + if (Build.IS_DEBUGGABLE) { + // Property is of the form "library_path=parameters". + String jvmtiAgent = SystemProperties.get("persist.sys.dalvik.jvmtiagent"); + if (!jvmtiAgent.isEmpty()) { + int equalIndex = jvmtiAgent.indexOf('='); + String libraryPath = jvmtiAgent.substring(0, equalIndex); + String parameterList = + jvmtiAgent.substring(equalIndex + 1, jvmtiAgent.length()); + // Attach the agent. + try { + Debug.attachJvmtiAgent(libraryPath, parameterList, null); + } catch (Exception e) { + Slog.e("System", "*************************************************"); + Slog.e("System", "********** Failed to load jvmti plugin: " + jvmtiAgent); + } + } + } } finally { traceEnd(); // InitBeforeStartServices } |