Merge "Fix side effects of trace-ipc and dumpheap commands" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-15 16:40:20 +00:00
committed by Android (Google) Code Review

View File

@@ -102,7 +102,6 @@ import com.android.server.am.LowMemDetector.MemFactor;
import com.android.server.compat.PlatformCompat; import com.android.server.compat.PlatformCompat;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@@ -806,8 +805,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
return -1; return -1;
} }
File file = new File(filename); // Writes an error message to stderr on failure
file.delete();
ParcelFileDescriptor fd = openFileForSystem(filename, "w"); ParcelFileDescriptor fd = openFileForSystem(filename, "w");
if (fd == null) { if (fd == null) {
return -1; return -1;
@@ -961,16 +959,16 @@ final class ActivityManagerShellCommand extends ShellCommand {
String logNameTimeString = LOG_NAME_TIME_FORMATTER.format(localDateTime); String logNameTimeString = LOG_NAME_TIME_FORMATTER.format(localDateTime);
heapFile = "/data/local/tmp/heapdump-" + logNameTimeString + ".prof"; heapFile = "/data/local/tmp/heapdump-" + logNameTimeString + ".prof";
} }
pw.println("File: " + heapFile);
pw.flush();
File file = new File(heapFile); // Writes an error message to stderr on failure
file.delete();
ParcelFileDescriptor fd = openFileForSystem(heapFile, "w"); ParcelFileDescriptor fd = openFileForSystem(heapFile, "w");
if (fd == null) { if (fd == null) {
return -1; return -1;
} }
pw.println("File: " + heapFile);
pw.flush();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() { final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() {