Search in sources :

Example 6 with TransferPipe

use of com.android.internal.os.TransferPipe in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method dumpDbInfo.

final void dumpDbInfo(FileDescriptor fd, PrintWriter pw, String[] args) {
    ArrayList<ProcessRecord> procs = collectProcesses(pw, 0, false, args);
    if (procs == null) {
        pw.println("No process found for: " + args[0]);
        return;
    }
    pw.println("Applications Database Info:");
    for (int i = procs.size() - 1; i >= 0; i--) {
        ProcessRecord r = procs.get(i);
        if (r.thread != null) {
            pw.println("\n** Database info for pid " + r.pid + " [" + r.processName + "] **");
            pw.flush();
            try {
                TransferPipe tp = new TransferPipe();
                try {
                    r.thread.dumpDbInfo(tp.getWriteFd().getFileDescriptor(), args);
                    tp.go(fd);
                } finally {
                    tp.kill();
                }
            } catch (IOException e) {
                pw.println("Failure while dumping the app: " + r);
                pw.flush();
            } catch (RemoteException e) {
                pw.println("Got a RemoteException while dumping the app " + r);
                pw.flush();
            }
        }
    }
}
Also used : IOException(java.io.IOException) RemoteException(android.os.RemoteException) Point(android.graphics.Point) TransferPipe(com.android.internal.os.TransferPipe)

Example 7 with TransferPipe

use of com.android.internal.os.TransferPipe in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method dumpActivity.

/**
     * Invokes IApplicationThread.dumpActivity() on the thread of the specified activity if
     * there is a thread associated with the activity.
     */
private void dumpActivity(String prefix, FileDescriptor fd, PrintWriter pw, final ActivityRecord r, String[] args, boolean dumpAll) {
    String innerPrefix = prefix + "  ";
    synchronized (this) {
        pw.print(prefix);
        pw.print("ACTIVITY ");
        pw.print(r.shortComponentName);
        pw.print(" ");
        pw.print(Integer.toHexString(System.identityHashCode(r)));
        pw.print(" pid=");
        if (r.app != null)
            pw.println(r.app.pid);
        else
            pw.println("(not running)");
        if (dumpAll) {
            r.dump(pw, innerPrefix);
        }
    }
    if (r.app != null && r.app.thread != null) {
        // flush anything that is already in the PrintWriter since the thread is going
        // to write to the file descriptor directly
        pw.flush();
        try {
            TransferPipe tp = new TransferPipe();
            try {
                r.app.thread.dumpActivity(tp.getWriteFd().getFileDescriptor(), r.appToken, innerPrefix, args);
                tp.go(fd);
            } finally {
                tp.kill();
            }
        } catch (IOException e) {
            pw.println(innerPrefix + "Failure while dumping the activity: " + e);
        } catch (RemoteException e) {
            pw.println(innerPrefix + "Got a RemoteException while dumping the activity");
        }
    }
}
Also used : IOException(java.io.IOException) RemoteException(android.os.RemoteException) TransferPipe(com.android.internal.os.TransferPipe)

Example 8 with TransferPipe

use of com.android.internal.os.TransferPipe in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method dumpGraphicsHardwareUsage.

final void dumpGraphicsHardwareUsage(FileDescriptor fd, PrintWriter pw, String[] args) {
    ArrayList<ProcessRecord> procs = collectProcesses(pw, 0, false, args);
    if (procs == null) {
        pw.println("No process found for: " + args[0]);
        return;
    }
    long uptime = SystemClock.uptimeMillis();
    long realtime = SystemClock.elapsedRealtime();
    pw.println("Applications Graphics Acceleration Info:");
    pw.println("Uptime: " + uptime + " Realtime: " + realtime);
    for (int i = procs.size() - 1; i >= 0; i--) {
        ProcessRecord r = procs.get(i);
        if (r.thread != null) {
            pw.println("\n** Graphics info for pid " + r.pid + " [" + r.processName + "] **");
            pw.flush();
            try {
                TransferPipe tp = new TransferPipe();
                try {
                    r.thread.dumpGfxInfo(tp.getWriteFd().getFileDescriptor(), args);
                    tp.go(fd);
                } finally {
                    tp.kill();
                }
            } catch (IOException e) {
                pw.println("Failure while dumping the app: " + r);
                pw.flush();
            } catch (RemoteException e) {
                pw.println("Got a RemoteException while dumping the app " + r);
                pw.flush();
            }
        }
    }
}
Also used : IOException(java.io.IOException) RemoteException(android.os.RemoteException) Point(android.graphics.Point) TransferPipe(com.android.internal.os.TransferPipe)

Example 9 with TransferPipe

use of com.android.internal.os.TransferPipe in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method stopBinderTrackingAndDump.

public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException {
    try {
        synchronized (this) {
            mBinderTransactionTrackingEnabled = false;
            // permission (same as profileControl).
            if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) != PackageManager.PERMISSION_GRANTED) {
                throw new SecurityException("Requires permission " + android.Manifest.permission.SET_ACTIVITY_WATCHER);
            }
            if (fd == null) {
                throw new IllegalArgumentException("null fd");
            }
            PrintWriter pw = new FastPrintWriter(new FileOutputStream(fd.getFileDescriptor()));
            pw.println("Binder transaction traces for all processes.\n");
            for (ProcessRecord process : mLruProcesses) {
                if (!processSanityChecksLocked(process)) {
                    continue;
                }
                pw.println("Traces for process: " + process.processName);
                pw.flush();
                try {
                    TransferPipe tp = new TransferPipe();
                    try {
                        process.thread.stopBinderTrackingAndDump(tp.getWriteFd().getFileDescriptor());
                        tp.go(fd.getFileDescriptor());
                    } finally {
                        tp.kill();
                    }
                } catch (IOException e) {
                    pw.println("Failure while dumping IPC traces from " + process + ".  Exception: " + e);
                    pw.flush();
                } catch (RemoteException e) {
                    pw.println("Got a RemoteException while dumping IPC traces from " + process + ".  Exception: " + e);
                    pw.flush();
                }
            }
            fd = null;
            return true;
        }
    } finally {
        if (fd != null) {
            try {
                fd.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : FastPrintWriter(com.android.internal.util.FastPrintWriter) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) RemoteException(android.os.RemoteException) PrintWriter(java.io.PrintWriter) FastPrintWriter(com.android.internal.util.FastPrintWriter) TransferPipe(com.android.internal.os.TransferPipe)

Example 10 with TransferPipe

use of com.android.internal.os.TransferPipe in project android_frameworks_base by AOSPA.

the class ActivityStackSupervisor method dumpHistoryList.

static boolean dumpHistoryList(FileDescriptor fd, PrintWriter pw, List<ActivityRecord> list, String prefix, String label, boolean complete, boolean brief, boolean client, String dumpPackage, boolean needNL, String header1, String header2) {
    TaskRecord lastTask = null;
    String innerPrefix = null;
    String[] args = null;
    boolean printed = false;
    for (int i = list.size() - 1; i >= 0; i--) {
        final ActivityRecord r = list.get(i);
        if (dumpPackage != null && !dumpPackage.equals(r.packageName)) {
            continue;
        }
        if (innerPrefix == null) {
            innerPrefix = prefix + "      ";
            args = new String[0];
        }
        printed = true;
        final boolean full = !brief && (complete || !r.isInHistory());
        if (needNL) {
            pw.println("");
            needNL = false;
        }
        if (header1 != null) {
            pw.println(header1);
            header1 = null;
        }
        if (header2 != null) {
            pw.println(header2);
            header2 = null;
        }
        if (lastTask != r.task) {
            lastTask = r.task;
            pw.print(prefix);
            pw.print(full ? "* " : "  ");
            pw.println(lastTask);
            if (full) {
                lastTask.dump(pw, prefix + "  ");
            } else if (complete) {
                // Complete + brief == give a summary.  Isn't that obvious?!?
                if (lastTask.intent != null) {
                    pw.print(prefix);
                    pw.print("  ");
                    pw.println(lastTask.intent.toInsecureStringWithClip());
                }
            }
        }
        pw.print(prefix);
        pw.print(full ? "  * " : "    ");
        pw.print(label);
        pw.print(" #");
        pw.print(i);
        pw.print(": ");
        pw.println(r);
        if (full) {
            r.dump(pw, innerPrefix);
        } else if (complete) {
            // Complete + brief == give a summary.  Isn't that obvious?!?
            pw.print(innerPrefix);
            pw.println(r.intent.toInsecureString());
            if (r.app != null) {
                pw.print(innerPrefix);
                pw.println(r.app);
            }
        }
        if (client && r.app != null && r.app.thread != null) {
            // flush anything that is already in the PrintWriter since the thread is going
            // to write to the file descriptor directly
            pw.flush();
            try {
                TransferPipe tp = new TransferPipe();
                try {
                    r.app.thread.dumpActivity(tp.getWriteFd().getFileDescriptor(), r.appToken, innerPrefix, args);
                    // Short timeout, since blocking here can
                    // deadlock with the application.
                    tp.go(fd, 2000);
                } finally {
                    tp.kill();
                }
            } catch (IOException e) {
                pw.println(innerPrefix + "Failure while dumping the activity: " + e);
            } catch (RemoteException e) {
                pw.println(innerPrefix + "Got a RemoteException while dumping the activity");
            }
            needNL = true;
        }
    }
    return printed;
}
Also used : IOException(java.io.IOException) RemoteException(android.os.RemoteException) TransferPipe(com.android.internal.os.TransferPipe)

Aggregations

TransferPipe (com.android.internal.os.TransferPipe)28 RemoteException (android.os.RemoteException)23 IOException (java.io.IOException)23 IBinder (android.os.IBinder)5 Point (android.graphics.Point)4 FastPrintWriter (com.android.internal.util.FastPrintWriter)2 FileOutputStream (java.io.FileOutputStream)2 PrintWriter (java.io.PrintWriter)2