Search in sources :

Example 1 with FsListToTreeRunnable

use of com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable in project otertool by wuntee.

the class PackageManagerController method loadPackageDetails.

public void loadPackageDetails(TableItem[] selection) {
    if (selection.length > 1) {
        return;
    }
    TableItem item = selection[0];
    final PackageBean bean = (PackageBean) item.getData(PackageBean.class.getName());
    logger.info("Loading package details for: " + bean.getApk());
    gui.setStatus("Loading package details for: " + bean.getApk());
    // Load file details
    Thread details = new Thread(new Runnable() {

        public void run() {
            // Pull file
            File apk = null;
            try {
                apk = AdbWorkshop.pullFile(bean.getApk());
            } catch (Exception e) {
                logger.error("Could not pull apk from device: ", e);
                GuiWorkshop.messageErrorThreaded(gui, "Could not pull apk from device: " + e.getMessage());
            }
            if (apk != null) {
                // Manifest
                try {
                    final AndroidManifestObject root = AndroidManifestWorkshop.getAndroidManifestObjectsForApk(apk);
                    gui.runRunnableAsync(new Runnable() {

                        public void run() {
                            // Load data in gui
                            gui.getPackageManagerAndroidManifestTab().loadAndroidManifestObjects(root);
                        }
                    });
                } catch (Exception e) {
                    logger.error("Could not parse the AndroidManifest.xml file: ", e);
                    GuiWorkshop.messageErrorThreaded(gui, "Could not parse the AndroidManifest.xml file: " + e.getMessage());
                }
                // AAPT
                List<String> details = null;
                try {
                    details = PackageManagerWorkshop.getDetailedPackageInfo(apk);
                } catch (Exception e) {
                    logger.error("Could not get detailed package information: ", e);
                    GuiWorkshop.messageErrorThreaded(gui, "Could not get detailed package information: " + e.getMessage());
                }
                final StringBuffer sb = new StringBuffer();
                if (details != null) {
                    for (String det : details) {
                        sb.append(det).append("\n");
                    }
                }
                gui.runRunnableAsync(new Runnable() {

                    public void run() {
                        // Load data in gui
                        gui.getPackageManagerStyledText().setText(sb.toString());
                    }
                });
            }
            // Files
            List<FsNode> files = null;
            try {
                files = FsWorkshop.getDirectoryRecursive("/data/data/" + bean.getClazz() + "/");
            } catch (Exception e) {
                logger.error("Could not get file listing: ", e);
                GuiWorkshop.messageErrorThreaded(gui, "Could not get file listing: " + e.getMessage());
            }
            if (files != null) {
                gui.runRunnableAsync(new FsListToTreeRunnable(files, gui.getPackageManagerFilesTree()));
            }
            gui.clearStatus();
        }
    });
    details.start();
}
Also used : FsListToTreeRunnable(com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable) TableItem(org.eclipse.swt.widgets.TableItem) FileToStyledTextRunnable(com.wuntee.oter.view.widgets.runnable.FileToStyledTextRunnable) FsListToTreeRunnable(com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable) List(java.util.List) AndroidManifestObject(com.wuntee.oter.aapt.androidmanifest.AndroidManifestObject) File(java.io.File) IOException(java.io.IOException) CommandFailedException(com.wuntee.oter.exception.CommandFailedException) SQLException(java.sql.SQLException)

Aggregations

AndroidManifestObject (com.wuntee.oter.aapt.androidmanifest.AndroidManifestObject)1 CommandFailedException (com.wuntee.oter.exception.CommandFailedException)1 FileToStyledTextRunnable (com.wuntee.oter.view.widgets.runnable.FileToStyledTextRunnable)1 FsListToTreeRunnable (com.wuntee.oter.view.widgets.runnable.FsListToTreeRunnable)1 File (java.io.File)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 TableItem (org.eclipse.swt.widgets.TableItem)1