diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-06-23 19:22:52 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-06-24 16:23:14 -0700 |
commit | 9c8dd55a9d829c29a3feee9469d8c2f27a9f5516 (patch) | |
tree | deb1f95fbdc6972bf1d50fffb79ef2c74731314b /cmds/am | |
parent | 0bc7b8490b1575bb8266a3b0c6652d4f460fcda1 (diff) | |
download | frameworks_base-9c8dd55a9d829c29a3feee9469d8c2f27a9f5516.zip frameworks_base-9c8dd55a9d829c29a3feee9469d8c2f27a9f5516.tar.gz frameworks_base-9c8dd55a9d829c29a3feee9469d8c2f27a9f5516.tar.bz2 |
Fix bug 1829561 ("am profile" with bad filename kills process).
The am command is now the one that takes care of opening the target file,
handling the opened file descriptor to the process that will be profiled.
This allows you to send profile data to anywhere the shell can access, and
avoids any problems coming up from the target process trying to open the
file.
Diffstat (limited to 'cmds/am')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 2a4a672..3782136 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -26,10 +26,13 @@ import android.content.ComponentName; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; import android.view.IWindowManager; +import java.io.File; +import java.io.FileNotFoundException; import java.util.Iterator; import java.util.Set; @@ -446,6 +449,8 @@ public class Am { return; } + ParcelFileDescriptor fd = null; + String cmd = nextArg(); if ("start".equals(cmd)) { start = true; @@ -455,6 +460,16 @@ public class Am { showUsage(); return; } + try { + fd = ParcelFileDescriptor.open( + new File(profileFile), + ParcelFileDescriptor.MODE_CREATE | + ParcelFileDescriptor.MODE_TRUNCATE | + ParcelFileDescriptor.MODE_READ_WRITE); + } catch (FileNotFoundException e) { + System.err.println("Error: Unable to open file: " + profileFile); + return; + } } else if (!"stop".equals(cmd)) { System.err.println("Error: Profile command " + cmd + " not valid"); showUsage(); @@ -462,8 +477,8 @@ public class Am { } try { - if (!mAm.profileControl(process, start, profileFile)) { - System.out.println("PROFILE FAILED on process " + process); + if (!mAm.profileControl(process, start, profileFile, fd)) { + System.err.println("PROFILE FAILED on process " + process); return; } } catch (IllegalArgumentException e) { |