Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0105770f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "replace VMDebug" into main

parents 643ae371 89e68fbe
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -22,8 +22,11 @@
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <application android:debuggable="true"
               >
    <!-- debuggable="true" is required to be able to generate a heap profile. -->
    <!-- testOnly="true" is required to be able to access "@hide" APIs such as VMDebug. -->
    <application
        android:debuggable="true"
        android:testOnly="true">
        <activity android:name=".EmptyActivity"
                  android:label="_EmptyActivity"
                  android:enabled="true"
+2 −5
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@ import android.os.Debug;
import android.os.SystemClock;
import android.util.Log;

import dalvik.system.VMDebug;

import org.apache.harmony.dalvik.ddmc.DdmVmInternal;

import java.io.File;
@@ -45,7 +43,6 @@ public class EmptyActivity extends Activity {
    // Configure for a heap dump

    private static void configureForHeap() {
        VMDebug.setAllocTrackerStackDepth(64);
        DdmVmInternal.setRecentAllocationsTrackingEnabled(true);
    }

@@ -96,7 +93,7 @@ public class EmptyActivity extends Activity {
            }
        }

        final String allocated = VMDebug.getRuntimeStat("art.gc.bytes-allocated");
        final long  allocated = android.os.Debug.getGlobalAllocSize();

        try {
            Debug.dumpHprofData(dumpPath + ".hprof");
@@ -114,7 +111,7 @@ public class EmptyActivity extends Activity {
            // report generators to sequence statistics files from multiple runs on the same
            // build.
            out.format("memory.testhelper.runtime %d\n", System.currentTimeMillis() / 1000);
            out.format("art.gc.bytes-allocated %s\n", allocated);
            out.format("art.gc.bytes-allocated %d\n", allocated);
            out.format("extra-size.length %d\n", (mExtraBytes != null) ? mExtraBytes.length : 0);
            out.format("sentinel.string %s\n", mSentinelString);
        } catch (FileNotFoundException e) {
+5 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ public class AppMemoryTest {
        try (var result = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) {
            byte[] response = new byte[100];
            int len = result.read(response);
            if (len <= 0) {
                return "";
            }
            return new String(response, 0, len);
        } catch (IOException e) {
            // Ignore the exception.
@@ -88,6 +91,7 @@ public class AppMemoryTest {

    @Before
    public void setUp() {
        runShellCommandWithResult("setprop debug.allocTracker.stackDepth 64");
        final String apk = mRootPath + HELPER_APK;
        File apkFile = new File(apk);
        assertTrue("apk not found", apkFile.exists());
@@ -99,6 +103,7 @@ public class AppMemoryTest {

    @After
    public void tearDown() {
        runShellCommandWithResult("setprop debug.allocTracker.stackDepth 16");
        uninstallHelper();
    }