aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/android/launcher/LauncherUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/jogamp/android/launcher/LauncherUtil.java')
-rw-r--r--src/java/jogamp/android/launcher/LauncherUtil.java128
1 files changed, 94 insertions, 34 deletions
diff --git a/src/java/jogamp/android/launcher/LauncherUtil.java b/src/java/jogamp/android/launcher/LauncherUtil.java
index b68768b..1dfc218 100644
--- a/src/java/jogamp/android/launcher/LauncherUtil.java
+++ b/src/java/jogamp/android/launcher/LauncherUtil.java
@@ -65,7 +65,9 @@ public class LauncherUtil {
/** The host <code>jogamp.org</code> */
public static final String HOST = "jogamp.org";
- static final String PKG = "pkg";
+ static final String SYS_PKG = "sys";
+
+ static final String USR_PKG = "pkg";
static final String ARG = "arg";
@@ -105,8 +107,11 @@ public class LauncherUtil {
/** Must return the downstream Activity class name */
public abstract String getActivityName();
- /** Must return a list of required packages, at least one. */
- public abstract List<String> getPackages();
+ /** Must return a list of required user packages, at least one containing the activity. */
+ public abstract List<String> getUsrPackages();
+
+ /** Return a list of required system packages w/ native libraries, may return null or a zero sized list. */
+ public abstract List<String> getSysPackages();
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -116,7 +121,8 @@ public class LauncherUtil {
final DataSet data = new DataSet();
data.setActivityName(getActivityName());
- data.addAllPackages(getPackages());
+ data.addAllSysPackages(getSysPackages());
+ data.addAllUsrPackages(getUsrPackages());
data.addAllProperties(props);
data.addAllArguments(args);
@@ -135,8 +141,11 @@ public class LauncherUtil {
ArrayList<String> keyList = new ArrayList<String>();
public final void setProperty(String key, String value) {
- if(key.equals(PKG)) {
- throw new IllegalArgumentException("Illegal property key, '"+PKG+"' is reserved");
+ if(key.equals(SYS_PKG)) {
+ throw new IllegalArgumentException("Illegal property key, '"+SYS_PKG+"' is reserved");
+ }
+ if(key.equals(USR_PKG)) {
+ throw new IllegalArgumentException("Illegal property key, '"+USR_PKG+"' is reserved");
}
if(key.equals(ARG)) {
throw new IllegalArgumentException("Illegal property key, '"+ARG+"' is reserved");
@@ -178,6 +187,17 @@ public class LauncherUtil {
public final List<String> getPropertyKeys() { return keyList; }
}
+ /**
+ * Data set to transfer from and to launch URI consisting out of:
+ * <ul>
+ * <li>system packages w/ native libraries used on Android, which may use a cached ClassLoader, see {@link DataSet#getSysPackages()}.</li>
+ * <li>user packages w/o native libraries used on Android, which do not use a cached ClassLoader, see {@link DataSet#getUsrPackages()}.</li>
+ * <li>activity name, used to launch an Android activity, see {@link DataSet#getActivityName()}.</li>
+ * <li>properties, which will be added to the system properties, see {@link DataSet#getProperties()}.</li>
+ * <li>arguments, used to launch a class main-entry, see {@link DataSet#getArguments()}.</li>
+ * </ul>
+ * {@link DataSet#getUri()} returns a URI representation of all components.
+ */
public static class DataSet {
static final char SLASH = '/';
static final char QMARK = '?';
@@ -187,20 +207,29 @@ public class LauncherUtil {
static final String EMPTY = "";
String activityName = null;
- ArrayList<String> packages = new ArrayList<String>();
+ ArrayList<String> sysPackages = new ArrayList<String>();
+ ArrayList<String> usrPackages = new ArrayList<String>();
OrderedProperties properties = new OrderedProperties();
ArrayList<String> arguments = new ArrayList<String>();
public final void setActivityName(String name) { activityName = name; }
public final String getActivityName() { return activityName; }
+
+ public final void addSysPackage(String p) {
+ sysPackages.add(p);
+ }
+ public final void addAllSysPackages(List<String> plist) {
+ sysPackages.addAll(plist);
+ }
+ public final List<String> getSysPackages() { return sysPackages; }
- public final void addPackage(String p) {
- packages.add(p);
+ public final void addUsrPackage(String p) {
+ usrPackages.add(p);
}
- public final void addAllPackages(List<String> plist) {
- packages.addAll(plist);
+ public final void addAllUsrPackages(List<String> plist) {
+ usrPackages.addAll(plist);
}
- public final List<String> getPackages() { return packages; }
+ public final List<String> getUsrPackages() { return usrPackages; }
public final void setProperty(String key, String value) {
properties.setProperty(key, value);
@@ -227,33 +256,58 @@ public class LauncherUtil {
public final Uri getUri() {
StringBuilder sb = new StringBuilder();
sb.append(SCHEME).append(COLSLASH2).append(HOST).append(SLASH).append(getActivityName());
+ boolean needsQMark = true;
boolean needsSep = false;
- if(packages.size()>0) {
- sb.append(QMARK);
- for(int i=0; i<packages.size(); i++) {
+ if(sysPackages.size()>0) {
+ if( needsQMark ) {
+ sb.append(QMARK);
+ needsQMark = false;
+ }
+ for(int i=0; i<sysPackages.size(); i++) {
if(needsSep) {
sb.append(AMPER);
}
- sb.append(PKG).append(ASSIG).append(packages.get(i));
+ sb.append(SYS_PKG).append(ASSIG).append(sysPackages.get(i));
needsSep = true;
}
}
- Iterator<String> propKeys = properties.keyList.iterator();
- while(propKeys.hasNext()) {
+ if(usrPackages.size()>0) {
+ if( needsQMark ) {
+ sb.append(QMARK);
+ needsQMark = false;
+ }
+ for(int i=0; i<usrPackages.size(); i++) {
if(needsSep) {
sb.append(AMPER);
}
- final String key = propKeys.next();
- sb.append(key).append(ASSIG).append(properties.map.get(key));
+ sb.append(USR_PKG).append(ASSIG).append(usrPackages.get(i));
needsSep = true;
+ }
+ }
+ Iterator<String> propKeys = properties.keyList.iterator();
+ while(propKeys.hasNext()) {
+ if( needsQMark ) {
+ sb.append(QMARK);
+ needsQMark = false;
+ }
+ if(needsSep) {
+ sb.append(AMPER);
+ }
+ final String key = propKeys.next();
+ sb.append(key).append(ASSIG).append(properties.map.get(key));
+ needsSep = true;
}
Iterator<String> args = arguments.iterator();
while(args.hasNext()) {
- if(needsSep) {
- sb.append(AMPER);
- }
- sb.append(ARG).append(ASSIG).append(args.next());
- needsSep = true;
+ if( needsQMark ) {
+ sb.append(QMARK);
+ needsQMark = false;
+ }
+ if(needsSep) {
+ sb.append(AMPER);
+ }
+ sb.append(ARG).append(ASSIG).append(args.next());
+ needsSep = true;
}
return Uri.parse(sb.toString());
}
@@ -298,11 +352,16 @@ public class LauncherUtil {
// assignment
final String k = part.substring(0, assignment);
final String v = part.substring(assignment+1);
- if(k.equals(PKG)) {
+ if(k.equals(SYS_PKG)) {
+ if(v.length()==0) {
+ throw new IllegalArgumentException("Empty package name: part <"+part+">, query <"+q+"> of "+uri);
+ }
+ data.addSysPackage(v);
+ } else if(k.equals(USR_PKG)) {
if(v.length()==0) {
throw new IllegalArgumentException("Empty package name: part <"+part+">, query <"+q+"> of "+uri);
}
- data.addPackage(v);
+ data.addUsrPackage(v);
} else if(k.equals(ARG)) {
if(v.length()==0) {
throw new IllegalArgumentException("Empty argument name: part <"+part+">, query <"+q+"> of "+uri);
@@ -313,7 +372,7 @@ public class LauncherUtil {
}
} else {
// property key only
- if( part.equals(PKG) || part.equals(ARG) ) {
+ if( part.equals(USR_PKG) || part.equals(ARG) ) {
throw new IllegalArgumentException("Reserved key <"+part+"> in query <"+q+"> of "+uri);
}
data.setProperty(part, EMPTY);
@@ -338,12 +397,13 @@ public class LauncherUtil {
public static void main(String[] args) {
if(args.length==0) {
args = new String[] {
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1&"+PKG+"=javax.pack2&"+PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1&"+PKG+"=javax.pack2&"+PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
- SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3"
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&"+SYS_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&"+USR_PKG+"=com.jogamp.pack4&jogamp.common.debug=true&com.jogamp.test=false",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=com.jogamp.pack2",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3",
+ SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3"
};
}
int errors = 0;