Skip to content

Commit

Permalink
Tested/udpated examples, updated shell imports to add CommonQueroies,
Browse files Browse the repository at this point in the history
Fixed a bug in API mapping xml for all versions exception API19, need to
rebuild plugin still
  • Loading branch information
benjholla committed Dec 10, 2014
1 parent ae7e58a commit fbd4efe
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
24 changes: 16 additions & 8 deletions toolbox.analysis/src/toolbox/analysis/Example0.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Permission, AtlasHashSet<GraphElement>> permissionMapping = PermissionMapping.applyTags(targetSDKVersion);
HashMap<Permission, AtlasHashSet<GraphElement>> 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<Permission, AtlasHashSet<GraphElement>> mapping : permissionMapping.entrySet()){
Expand All @@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<!-- API level: 10, version: 2.3.3, code name: Gingerbread -->
<!-- API level: 10, version: 2.3.3, code name: Gingerbread -->
<permissions>
<permission name="android.permission.CHANGE_WIFI_STATE">
<call>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<!-- API level: 13, version: 3.2, code name: Honeycomb -->
<!-- API level: 13, version: 3.2, code name: Honeycomb -->
<permissions>
<permission name="android.permission.CHANGE_WIFI_STATE">
<call>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<!-- API level: 14, version: 4.0, code name: Ice Cream Sandwich-->
<!-- API level: 14, version: 4.0, code name: Ice Cream Sandwich-->
<permissions>
<permission name="android.permission.CHANGE_WIFI_STATE">
<call>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<!-- API level: 16, version: 4.1.2, code name: Jelly Bean -->
<!-- API level: 16, version: 4.1.2, code name: Jelly Bean -->
<permissions>
<permission name="android.permission.CHANGE_WIFI_STATE">
<call>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<<!-- API level: 8, version: 2.2, code name: Froyo -->
<!-- API level: 8, version: 2.2, code name: Froyo -->
<permissions>
<permission name="android.permission.CHANGE_WIFI_STATE">
<call>
Expand Down
4 changes: 4 additions & 0 deletions toolbox.shell/shellInit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fbd4efe

Please sign in to comment.