Search in sources :

Example 26 with AndroidException

use of android.util.AndroidException in project android_frameworks_base by crdroidandroid.

the class Am method runTraceIpcStop.

private void runTraceIpcStop() throws Exception {
    String opt;
    String filename = null;
    while ((opt = nextOption()) != null) {
        if (opt.equals("--dump-file")) {
            filename = nextArgRequired();
        } else {
            System.err.println("Error: Unknown option: " + opt);
            return;
        }
    }
    if (filename == null) {
        System.err.println("Error: Specify filename to dump logs to.");
        return;
    }
    ParcelFileDescriptor fd = null;
    try {
        File file = new File(filename);
        file.delete();
        fd = openForSystemServer(file, ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE | ParcelFileDescriptor.MODE_WRITE_ONLY);
    } catch (FileNotFoundException e) {
        System.err.println("Error: Unable to open file: " + filename);
        System.err.println("Consider using a file under /data/local/tmp/");
        return;
    }
    ;
    if (!mAm.stopBinderTrackingAndDump(fd)) {
        throw new AndroidException("STOP TRACE FAILED.");
    }
    System.out.println("Stopped IPC tracing. Dumping logs to: " + filename);
}
Also used : AndroidException(android.util.AndroidException) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Example 27 with AndroidException

use of android.util.AndroidException in project android_frameworks_base by crdroidandroid.

the class Am method runDumpHeap.

private void runDumpHeap() throws Exception {
    boolean managed = true;
    int userId = UserHandle.USER_CURRENT;
    String opt;
    while ((opt = nextOption()) != null) {
        if (opt.equals("--user")) {
            userId = parseUserArg(nextArgRequired());
            if (userId == UserHandle.USER_ALL) {
                System.err.println("Error: Can't dump heap with user 'all'");
                return;
            }
        } else if (opt.equals("-n")) {
            managed = false;
        } else {
            System.err.println("Error: Unknown option: " + opt);
            return;
        }
    }
    String process = nextArgRequired();
    String heapFile = nextArgRequired();
    ParcelFileDescriptor fd = null;
    try {
        File file = new File(heapFile);
        file.delete();
        fd = openForSystemServer(file, ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE | ParcelFileDescriptor.MODE_WRITE_ONLY);
    } catch (FileNotFoundException e) {
        System.err.println("Error: Unable to open file: " + heapFile);
        System.err.println("Consider using a file under /data/local/tmp/");
        return;
    }
    if (!mAm.dumpHeap(process, userId, managed, heapFile, fd)) {
        throw new AndroidException("HEAP DUMP FAILED on process " + process);
    }
}
Also used : AndroidException(android.util.AndroidException) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Aggregations

AndroidException (android.util.AndroidException)27 ParcelFileDescriptor (android.os.ParcelFileDescriptor)17 File (java.io.File)17 FileNotFoundException (java.io.FileNotFoundException)17 IInstrumentationWatcher (android.app.IInstrumentationWatcher)6 UiAutomationConnection (android.app.UiAutomationConnection)6 ComponentName (android.content.ComponentName)6 Bundle (android.os.Bundle)6 IWindowManager (android.view.IWindowManager)6 ProfilerInfo (android.app.ProfilerInfo)5 InstrumentationInfo (android.content.pm.InstrumentationInfo)5 ArrayList (java.util.ArrayList)5 Configuration (android.content.res.Configuration)4 Resources (android.content.res.Resources)4 DisplayMetrics (android.util.DisplayMetrics)4