MIDletSuiteUtilspublic class MIDletSuiteUtils extends Object The class designed to provide utils for starting MIDlet suites,
and scheduling their start using VM cycling mechanism. |
Fields Summary |
---|
static int | lastMidletSuiteToRunThe unique ID of the last MIDlet suite to run. | static String | lastMidletToRunThe class name of the last MIDlet to run. | static String | arg0ForLastMidletIf not null, this will be available to the last MIDlet to run as
application property arg-0. | static String | arg1ForLastMidletIf not null, this will be available to the last MIDlet to run as
application property arg-1. | static int | nextMidletSuiteToRunThe unique ID of the next MIDlet suite to run. | static String | nextMidletToRunThe class of the next MIDlet to run. | static String | arg0ForNextMidletIf not null, this will be available to the MIDlet to run as
application property arg-0. | static String | arg1ForNextMidletIf not null, this will be available to the MIDlet to run as
application property arg-1. | static String | arg2ForNextMidletIf not null, this will be available to the MIDlet to run as
application property arg-2. | static int | memoryReservedThe minimum amount of memory guaranteed to be available
to the VM at any time; < 0 if not used. | static int | memoryTotalThe total amount of memory that the VM can reserve; < 0 if not used. | static int | priorityPriority to set after restarting the VM; <= 0 if not used. | static String | profileNameName of the profile to set after restarting the VM; null if not used. |
Methods Summary |
---|
static void | displayException(com.sun.midp.lcdui.DisplayEventHandler handler, java.lang.String exceptionMsg)Display an exception to the user.
SystemAlert alert = new SystemAlert(
handler, "Exception", exceptionMsg, null, AlertType.ERROR);
alert.run();
alert.waitForUser();
| public static boolean | execute(int id, java.lang.String midlet, java.lang.String displayName)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
return executeWithArgs(
id, midlet, displayName, null, null, null);
| public static boolean | execute(com.sun.midp.security.SecurityToken securityToken, int suiteId, java.lang.String midlet, java.lang.String displayName)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
return executeWithArgs(
securityToken, suiteId, midlet,
displayName, null, null, null);
| public static boolean | executeWithArgs(int suiteId, java.lang.String midlet, java.lang.String displayName, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
return executeWithArgs(
null, suiteId, midlet, displayName, arg0, arg1, arg2);
| public static boolean | executeWithArgs(com.sun.midp.security.SecurityToken securityToken, int suiteId, java.lang.String midlet, java.lang.String displayName, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
return executeWithArgs(
securityToken, 0, suiteId, midlet,
displayName, arg0, arg1, arg2);
| public static boolean | executeWithArgs(com.sun.midp.security.SecurityToken securityToken, int externalAppId, int suiteId, java.lang.String midlet, java.lang.String displayName, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
return executeWithArgs(
securityToken, externalAppId, suiteId, midlet, displayName,
arg0, arg1, arg2, -1, -1, -1, null);
| public static boolean | executeWithArgs(com.sun.midp.security.SecurityToken securityToken, int externalAppId, int suiteId, java.lang.String midlet, java.lang.String displayName, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, int memoryReserved, int memoryTotal, int priority, java.lang.String profileName)Starts a MIDlet in a new Isolate or
queues the execution of the named Application suite to run.
The current application suite should terminate itself normally
to make resources available to the new application suite. Only
one package and set of MIDlets can be queued in this manner.
If multiple calls to execute are made, the package and MIDlets
specified during the last invocation will be executed
when the current application is terminated.
MIDletSuiteStorage midletSuiteStorage;
// Note: getMIDletSuiteStorage performs an AMS permission check.
if (securityToken != null) {
midletSuiteStorage =
MIDletSuiteStorage.getMIDletSuiteStorage(securityToken);
} else {
midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage();
}
return AmsUtil.executeWithArgs(
midletSuiteStorage, externalAppId, suiteId,
midlet, displayName, arg0, arg1, arg2,
memoryReserved, memoryTotal, priority, profileName);
| public static native int | getAmsIsolateId()Get the Isolate ID of the AMS Isolate.
| public static native int | getIsolateId()Get the current Isolate ID.
| public static int | getNextMIDletSuiteToRun()Gets the unique storage name of the next MIDlet suite to run.
return nextMidletSuiteToRun;
| public static java.lang.String | getNextMIDletToRun()Gets the name of the next MIDlet to run.
return nextMidletToRun;
| static void | initAmsResources()The method is designed to init AMS task resources. The resources
can be shared between all working isolates, so it is important to
init them before other isolate tasks will require the resources.
The tasks other than AMS shouldn't call this method, it's guarded
by run-time exception.
IMPL_NOTE: The method is temporarily loacated here, since we need
to introduce new abstraction for AMS task logic and separate it
from the MIDlet suite loading and execution logic. Now the method
is needed to MIDletSuiteLoader & NativeAppManagerPeer classes
which represent an AMS task for Java AMS and Native AMS cases
correspondingly.
// Check whether caller task is an AMS task
if (!isAmsIsolate()) {
throw new RuntimeException(
"Resources initialization should be done from the AMS task");
}
// The static initializer of the Display class will forward on
// the Chameleon skin resources loading if Chameleon is being used.
// It is important to load Chameleon resources from the AMS isolate
// before other isolates will need them.
try {
Class.forName("javax.microedition.lcdui.Display");
} catch (Throwable ex) {
throw new RuntimeException(
"Display initialization has failed");
}
| public static native boolean | isAmsIsolate()Check whether current Isolate is an AMS Isolate
| static native void | registerAmsIsolateId()Register the Isolate ID of the AMS Isolate by making a native
method call that will call JVM_CurrentIsolateId and set
it in the proper native variable.
| public static void | setLastSuiteToRun(int id, java.lang.String midlet, java.lang.String arg0, java.lang.String arg1)Queues the last suite to run when there is not a next Suite
to run. This value will be persistent until it is used.
Not used in MVM mode.
MIDletSuite midletSuite =
MIDletStateHandler.getMidletStateHandler().getMIDletSuite();
// if a MIDlet suite is not scheduled, assume the JAM is calling.
if (midletSuite != null) {
midletSuite.checkIfPermissionAllowed(Permissions.AMS);
}
lastMidletSuiteToRun = id;
lastMidletToRun = midlet;
arg0ForLastMidlet = arg0;
arg1ForLastMidlet = arg1;
| static native void | vmBeginStartUp(int midletIsolateId)Send hint to VM about begin of a MIDlet startup phase within specified
isolate to allow the VM to fine tune its internal parameters to achieve
optimal perfomance
| public static void | vmBeginStartUp(com.sun.midp.security.SecurityToken token, int midletIsolateId)Secure method to send VM hint about begin of a MIDlet startup phase
within specified isolate
token.checkIfPermissionAllowed(Permissions.AMS);
vmBeginStartUp(midletIsolateId);
| static native void | vmEndStartUp(int midletIsolateId)Send hint to VM about end of a MIDlet startup phase within specified
isolate to allow the VM to restore its internal parameters changed on
startup time for better performance
| public static void | vmEndStartUp(com.sun.midp.security.SecurityToken token, int midletIsolateId)Secure method to send VM hint about end of a MIDlet startup phase
within specified isolate
token.checkIfPermissionAllowed(Permissions.AMS);
vmEndStartUp(midletIsolateId);
|
|