use of com.wuntee.oter.aapt.androidmanifest.AndroidManifestObject 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();
}
use of com.wuntee.oter.aapt.androidmanifest.AndroidManifestObject in project otertool by wuntee.
the class CTabItemWithTreeForAndroidManifest method loadRecur.
private void loadRecur(AndroidManifestObject o, TreeItem parent) {
TreeItem ti = null;
if (parent == null) {
ti = new TreeItem(this.getTree(), SWT.NONE);
} else {
ti = new TreeItem(parent, SWT.NONE);
}
if (o instanceof AndroidManifestElement) {
AndroidManifestElement e = (AndroidManifestElement) o;
ti.setText(e.getName());
if (e.getName().equalsIgnoreCase("uses-permission")) {
ti.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN));
} else if (e.getName().equalsIgnoreCase("activity")) {
ti.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
} else if (e.getName().equalsIgnoreCase("receiver") || e.getName().equalsIgnoreCase("provider")) {
ti.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
}
} else if (o instanceof AndroidManifestNamespace) {
AndroidManifestNamespace n = (AndroidManifestNamespace) o;
ti.setText(n.getName() + "=" + n.getValue());
} else if (o instanceof AndroidManifestAttribute) {
AndroidManifestAttribute a = (AndroidManifestAttribute) o;
if (a.getRaw().equals("") && a.getType().equals("")) {
ti.setText(a.getName() + "=" + a.getValue());
} else if (a.getRaw().equals("") && !a.getType().equals("")) {
ti.setText(a.getName() + "[" + a.getType() + "]=" + a.getValue());
} else if (!a.getRaw().equals("") && a.getType().equals("")) {
ti.setText(a.getName() + "[" + a.getRaw() + "]=" + a.getValue());
} else {
ti.setText(a.getName() + "[" + a.getType() + ":" + a.getRaw() + "]=" + a.getValue());
}
}
String attributes = " [";
for (AndroidManifestObject child : o.getChildren()) {
if (child instanceof AndroidManifestAttribute) {
AndroidManifestAttribute a = (AndroidManifestAttribute) child;
attributes = attributes + a.getName() + "=" + a.getValue() + ", ";
} else {
loadRecur(child, ti);
}
}
if (!attributes.equals(" [")) {
ti.setText(ti.getText() + attributes.substring(0, attributes.length() - 2) + "]");
}
ti.setExpanded(true);
}
Aggregations