From fbd4efe5eb23672ae839b4929a4a750d89e59f49 Mon Sep 17 00:00:00 2001 From: benjholla Date: Tue, 9 Dec 2014 22:25:13 -0600 Subject: [PATCH] Tested/udpated examples, updated shell imports to add CommonQueroies, Fixed a bug in API mapping xml for all versions exception API19, need to rebuild plugin still --- .../src/toolbox/analysis/Example0.java | 24 ++++++++++++------- .../essentials/permissions/mappings/API10.xml | 2 +- .../essentials/permissions/mappings/API13.xml | 2 +- .../essentials/permissions/mappings/API14.xml | 2 +- .../essentials/permissions/mappings/API16.xml | 2 +- .../essentials/permissions/mappings/API8.xml | 2 +- toolbox.shell/shellInit.scala | 4 ++++ 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/toolbox.analysis/src/toolbox/analysis/Example0.java b/toolbox.analysis/src/toolbox/analysis/Example0.java index ba9a016..4870dc2 100644 --- a/toolbox.analysis/src/toolbox/analysis/Example0.java +++ b/toolbox.analysis/src/toolbox/analysis/Example0.java @@ -14,24 +14,20 @@ public class Example0 { /** - * Given an Android project in the workspace, this method applies the nearest permission mapping (rounding up if need be) - * to the target SDK version of the specified Android Eclipse project. + * This method applies the nearest permission mapping (rounding up if need be) to the requested SDK version. * Note: If the permission mapping is unsuccessful, Atlas Jar indexing may be disable. Enabling Jar indexing is required. * @param projectName An Eclipse project name of an Android application in the workspace to analyze * @return True if the permission mapping was successfully applied, false otherwise * @throws Exception Exception in the event that AndroidManifest.xml files is missing or corrupt */ - public static boolean applyApplicationTargetSDKPermissionMapping(String projectName) throws Exception { - // parse the manifest for the target sdk version - Manifest manifest = new Manifest(Manifest.getManifestFile(projectName)); - int targetSDKVersion = manifest.getTargetSDKVersion(); + public static boolean applySDKPermissionMapping(int sdkVersion) throws Exception { // check if the permission mapping has already been applied - String tagPrefix = PermissionMapping.getTagPrefix(targetSDKVersion); + String tagPrefix = PermissionMapping.getTagPrefix(sdkVersion); if(!CommonQueries.nodesStartingWith(tagPrefix).eval().nodes().isEmpty()){ return true; // permission mapping has already been applied } // need to apply permission mapping - HashMap> permissionMapping = PermissionMapping.applyTags(targetSDKVersion); + HashMap> permissionMapping = PermissionMapping.applyTags(sdkVersion); // permission mapping is successful if for at least one permission, a tag was applied to the graph boolean success = false; for(Entry> mapping : permissionMapping.entrySet()){ @@ -43,4 +39,16 @@ public static boolean applyApplicationTargetSDKPermissionMapping(String projectN return success; } + /** + * + * @param projectName An Eclipse project name of an Android application in the workspace to analyze + * @return The applications target sdk version + * @throws Exception Exception in the event that AndroidManifest.xml files is missing or corrupt + */ + public static int getApplicationTargetSDKVersion(String projectName) throws Exception { + // parse the manifest for the target sdk version + Manifest manifest = new Manifest(Manifest.getManifestFile(projectName)); + return manifest.getTargetSDKVersion(); + } + } diff --git a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API10.xml b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API10.xml index cde8a57..c571701 100644 --- a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API10.xml +++ b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API10.xml @@ -1,5 +1,5 @@ -< + diff --git a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API13.xml b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API13.xml index 0981f15..2b68bb6 100644 --- a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API13.xml +++ b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API13.xml @@ -1,5 +1,5 @@ -< + diff --git a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API14.xml b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API14.xml index 9054608..f6ada33 100644 --- a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API14.xml +++ b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API14.xml @@ -1,5 +1,5 @@ -< + diff --git a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API16.xml b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API16.xml index 9da651c..b22cb90 100644 --- a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API16.xml +++ b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API16.xml @@ -1,5 +1,5 @@ -< + diff --git a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API8.xml b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API8.xml index 63f5ff2..2f46152 100644 --- a/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API8.xml +++ b/toolbox.android.essentials/src/toolbox/android/essentials/permissions/mappings/API8.xml @@ -1,5 +1,5 @@ -< + diff --git a/toolbox.shell/shellInit.scala b/toolbox.shell/shellInit.scala index 56cc321..7c668d0 100644 --- a/toolbox.shell/shellInit.scala +++ b/toolbox.shell/shellInit.scala @@ -11,8 +11,12 @@ import com.ensoftcorp.atlas.core.query.Q import com.ensoftcorp.atlas.core.query.Attr import com.ensoftcorp.atlas.core.query.Attr.Edge import com.ensoftcorp.atlas.core.query.Attr.Node +import com.ensoftcorp.atlas.core.script.Common import com.ensoftcorp.atlas.core.script.Common._ +import com.ensoftcorp.atlas.ui.shell.lib.Common import com.ensoftcorp.atlas.ui.shell.lib.Common._ +import com.ensoftcorp.atlas.core.script.CommonQueries +import com.ensoftcorp.atlas.core.script.CommonQueries._ import com.ensoftcorp.atlas.core.db.Accuracy._ import com.ensoftcorp.atlas.core.db.graph.Graph