Fields Summary |
---|
private static com.sun.midp.security.SecurityToken | classSecurityTokenThis class has a different security domain than the MIDlet suite |
private static AppProxy | currentAppThe current AppProxy. |
static final boolean | LOG_INFOThe log flag to enable informational messages. |
private static boolean | oneExecuteThis global state is true if an application
has been executed and this application should be exiting
to let it run. For SVM, this is set true by {@link #launch }
and stays that way.
For MVM, it is cleared if the VM allows the execute to occur.
At MIDlet exit, {@link InvocationImpl#invokeNext} checks to see
if another application Invoction is pending and invokes it.
If this application has NOT invoked anything then the
chosen app will be invoked. |
protected Hashtable | appmapThe known AppProxy instances. Key is classname. |
protected static final Object | mutexThe mutex used to avoid corruption between threads. |
protected final com.sun.midp.midlet.MIDletSuite | msuiteThe MIDlet suite for this app. |
protected final int | storageIdThe storageId (suiteId) for this application. |
protected String | classnameThe classname of the application. |
private String | applicationNameThe application name. |
private String | applicationIDThe ApplicationID, (same a suiteId). |
private boolean | isRegisteredThe application is registered. |
static final String | VERSION_PROPMIDlet property for the suite version. |
static final String | VENDOR_PROPMIDlet property for the suite vendor. |
Methods Summary |
---|
static final void | checkAPIPermission(java.lang.Object securityToken)Check if the internal API use is allowed.
if (securityToken != null) {
((SecurityToken)securityToken).
checkIfPermissionAllowed(Permissions.MIDP);
} else {
MIDletSuite msuite =
MIDletStateHandler.getMidletStateHandler().getMIDletSuite();
if (msuite != null) {
msuite.checkIfPermissionAllowed(Permissions.AMS);
}
}
|
final void | checkRegisterPermission(java.lang.String reason)Check the permission to register or unregister.
try {
msuite.checkForPermission(Permissions.CHAPI_REGISTER,
getApplicationName(), reason);
} catch (InterruptedException ie) {
throw new SecurityException("interrupted");
}
|
com.sun.midp.content.AppProxy | forApp(int storageId, java.lang.String classname)Gets the AppProxy for an storageID and classname.
// Check in the current suite
if (storageId == this.storageId) {
return forClass(classname);
}
// Create a new instance
AppProxy curr = new AppProxy(storageId, classname);
return curr;
|
com.sun.midp.content.AppProxy | forClass(java.lang.String classname)Gets the AppProxy for an application class in the current bundle.
AppProxy curr = null;
synchronized (mutex) {
// Check if class already has a AppProxy
curr = (AppProxy)appmap.get(classname);
if (curr == null) {
// Create a new instance
// throws ClassNotFoundException and IllegalArgumentException
curr = new AppProxy(msuite, classname, appmap);
}
}
return curr;
|
java.lang.String | getApplicationID()Gets the CHAPI application ID for this application.
return applicationID;
|
java.lang.String | getApplicationName()Gets the user friendly application name.
return applicationName;
|
java.lang.String | getAuthority()Gets the Trusted authority that authenticated this application.
For MIDP, this is the CA of the signer.
If exception is thrown during getting authorization
this methods ignores it and returns null.
String auth = null;
try {
auth = ((MIDletSuiteImpl)msuite).getInstallInfo().getCA();
} catch (RuntimeException e) {
}
return auth;
|
java.lang.String | getClassname()Gets the classname of this application.
return classname;
|
static com.sun.midp.content.AppProxy | getCurrent()Gets the AppProxy for the currently running application.
synchronized (mutex) {
if (currentApp == null) {
MIDletStateHandler mh =
MIDletStateHandler.getMidletStateHandler();
MIDletSuite msuite = mh.getMIDletSuite();
try {
currentApp = (msuite != null) ?
new AppProxy(msuite,
mh.getFirstRunningMidlet(),
null) :
new AppProxy(MIDletSuite.INTERNAL_SUITE_ID, "");
} catch (ClassNotFoundException cnfe) {
return null;
}
}
}
return currentApp;
|
java.lang.String | getDefaultID()Gets the content handler ID for the current application.
The ID uniquely identifies the application which contains the
content handler.
The application ID is assigned when the application is installed.
All installed applications have vendor and name;
StringBuffer sb = new StringBuffer(80);
String s = msuite.getProperty(VENDOR_PROP);
sb.append((s != null) ? s : "internal");
sb.append('-");
s = msuite.getProperty(MIDletSuiteImpl.SUITE_NAME_PROP);
sb.append((s != null) ? s : "system");
sb.append('-");
sb.append(classname);
return sb.toString().replace(' ", '_");
|
private static java.lang.String[] | getMIDletInfo(com.sun.midp.midlet.MIDletSuite suite, java.lang.String classname)Get the MIDletInfo for the named MIDlet.
for (int i = 1; ; i++) {
String midletn = "MIDlet-".concat(Integer.toString(i));
String attr = suite.getProperty(midletn);
if (attr == null) {
break; // break out of loop, not found
}
Vector args = Util.getCommaSeparatedValues(attr);
if (args.size() < 3) {
// Not enough args to be legit
continue;
}
if (!classname.equals(args.elementAt(2))) {
continue;
}
String[] values = new String[args.size()];
args.copyInto(values);
String ID = suite.getProperty(midletn.concat("-ID"));
values[2] = ID;
return values;
}
return null;
|
java.lang.String | getProperty(java.lang.String key)Gets a property from the manifest or application descriptor.
return msuite.getProperty(key);
|
int | getStorageId()Gets the storage ID of this application.
The ID uniquely identifies the package/application bundle.
return storageId;
|
java.lang.String | getVersion()Gets the version string for the application.
return msuite == null? null: msuite.getProperty(VERSION_PROP);
|
protected void | initAppInfo()Initialize application name and application ID
from the attributes.
// Check if it is an internal MIDlet
if (storageId == MIDletSuite.INTERNAL_SUITE_ID) {
applicationName = classname.substring(classname.lastIndexOf('.") + 1);
applicationID = "system";
isRegistered = true;
return;
}
// Check if a registered MIDlet
String[] minfo = getMIDletInfo(msuite, classname);
// if a MIDlet, set the application name and application ID
if (minfo != null) {
applicationName = minfo[0];
applicationID = minfo[2];
isRegistered = true;
}
// Fill in defaults for appName and applicationID
if (applicationName == null || applicationName.length() == 0) {
applicationName = msuite.getProperty(
MIDletSuiteImpl.SUITE_NAME_PROP);
}
if (applicationID == null || applicationID.length() == 0) {
applicationID = getDefaultID();
}
|
boolean | isRegistered()Gets true if the application is a registered application.
for MIDP, this means there was a MIDlet-n attribute.
return isRegistered;
|
boolean | launch(java.lang.String displayName)Launch this application.
Don't launch another application unless
the execute allows this application to continue after
the launch.
In SVM, (sequential applications) only the first
execute matters; later ones should not override the
first. All pending Invocations are queued in InvocationStore
so they will not be lost. When MIDlets exit, another
application will be selected from those pending.
/*
* If an execute has been queued already; don't queue another
*/
if (oneExecute) {
// launched something previously and app should exit.
if (LOG_INFO) {
logInfo("Launch skipped: " + classname +
", oneExecute: " + oneExecute);
}
return true;
} else {
/* Invoke the target application */
oneExecute =
MIDletSuiteUtils.execute(classSecurityToken,
storageId,
classname, displayName);
if (LOG_INFO) {
logInfo("Launch: " + classname +
", oneExecute: " + oneExecute);
}
return oneExecute;
}
|
void | logException(java.lang.String msg, java.lang.Throwable t)Log an information message to the system logger for this AppProxy.
if (LOG_INFO) {
System.out.println("** " + threadID() + ": " + msg);
t.printStackTrace();
}
|
void | logInfo(java.lang.String msg)Log an information message to the system logger for this AppProxy.
if (LOG_INFO) {
System.out.println(">> " + threadID() + ": " + msg);
}
|
static void | requestForeground(int invokingSuiteId, java.lang.String invokingClassname, int targetSuiteId, java.lang.String targetClassname)Request the transition of the foreground to this application
from the invoking application.
NativeEvent event =
new NativeEvent(EventTypes.FOREGROUND_TRANSFER_EVENT);
event.intParam1 = invokingSuiteId;
event.stringParam1 = invokingClassname;
event.intParam2 = targetSuiteId;
event.stringParam2 = targetClassname;
int amsIsolateId = MIDletSuiteUtils.getAmsIsolateId();
EventQueue eventQueue = EventQueue.getEventQueue(classSecurityToken);
eventQueue.sendNativeEventToIsolate(event, amsIsolateId);
|
static void | requestForeground(int targetSuiteId, java.lang.String targetClassname)The stronger variant for request the transition of
the foreground to this application.
NativeEvent event =
new NativeEvent(EventTypes.SET_FOREGROUND_BY_NAME_REQUEST);
event.intParam1 = targetSuiteId;
event.stringParam1 = targetClassname;
int amsIsolateId = MIDletSuiteUtils.getAmsIsolateId();
EventQueue eventQueue = EventQueue.getEventQueue(classSecurityToken);
eventQueue.sendNativeEventToIsolate(event, amsIsolateId);
|
static void | setSecurityToken(com.sun.midp.security.SecurityToken token)Sets the security token used for priveleged operations.
The token may only be set once.
if (classSecurityToken != null) {
throw new SecurityException();
}
classSecurityToken = token;
|
private java.lang.String | threadID()Map a thread to an printable string.
if (LOG_INFO) {
Thread thread = Thread.currentThread();
int i = thread.hashCode() & 0xff;
return "T" + i;
} else {
return "";
}
|
public java.lang.String | toString()Create a printable representation of this AppProxy.
if (LOG_INFO) {
return"class: " + classname +
", suite: " + storageId +
", registered: " + isRegistered +
", name: " + applicationName +
", ID: " + applicationID;
} else {
return super.toString();
}
|
protected void | verifyApplication(java.lang.String classname)Verify that the classname is a valid application.
It must extend MIDlet.
/* check the classname for null and get the class */
Class appClass = Class.forName(classname);
Class midletClass = Class.forName("javax.microedition.midlet.MIDlet");
if ((!midletClass.isAssignableFrom(appClass)) ||
appClass == midletClass) {
throw new IllegalArgumentException("not a MIDlet");
}
|