Fields Summary |
---|
protected CommandState | stateCommand state of the MIDlet suite loader |
protected int | disableAlertsDisable startup error alerts, uninitialized by default |
protected MIDletEventProducer | midletEventProducerMIDlet state event producer needed by AMS |
protected static com.sun.midp.lcdui.ForegroundEventProducer | foregroundEventProducerForeground event producer needed by AMS. |
protected MIDletProxyList | midletProxyListList of MIDlet proxies needed by AMS |
Methods Summary |
---|
protected void | checkForShutdown()The AMS MIDlet started in the suite loader could request for
shutdown, so we need to check it, wait for other MIDlets destroying
and update CommandState with appropriate status.
if (MIDletProxyList.shutdownInProgress()) {
// The MIDlet was shutdown by either the OS or the
// push system. Set the command state to signal this
// to the native AMS code.
state.status = CommandState.SHUTDOWN;
midletProxyList.waitForShutdownToComplete();
} else {
state.status = CommandState.OK;
}
|
protected void | closeSuite()Overrides suite close logic for the AMS task
/*
* The midletSuite is not closed because the other
* active threads may be depending on it.
* For example, Display uses isTrusted to update
* screen icons.
* A native finalizer will take care of unlocking
* the native locks.
*/
|
protected void | createSuiteEnvironment()Creates environment objects needed to AMS task
super.createSuiteEnvironment();
midletEventProducer = new MIDletEventProducer(eventQueue);
foregroundEventProducer = new ForegroundEventProducer(eventQueue);
midletProxyList = new MIDletProxyList(eventQueue);
|
protected void | displayException(java.lang.String exceptionMsg)Displays an exception message to user
MIDletSuiteUtils.displayException(
displayEventHandler, exceptionMsg);
|
protected void | done()Extends base class implementatiom with additional actions for main
task shutdown. Update and save CommandState instance
for VM cycling mechanism.
super.done();
state.suiteId = MIDletSuite.UNUSED_SUITE_ID;
state.midletClassName = null;
if (state.status != CommandState.SHUTDOWN) {
if (MIDletSuiteUtils.lastMidletSuiteToRun !=
MIDletSuite.UNUSED_SUITE_ID) {
state.lastSuiteId = MIDletSuiteUtils.lastMidletSuiteToRun;
state.lastMidletClassName = MIDletSuiteUtils.lastMidletToRun;
state.lastArg0 = MIDletSuiteUtils.arg0ForLastMidlet;
state.lastArg1 = MIDletSuiteUtils.arg1ForLastMidlet;
}
// Check to see if we need to run a selected suite next
if (MIDletSuiteUtils.nextMidletSuiteToRun !=
MIDletSuite.UNUSED_SUITE_ID) {
state.suiteId = MIDletSuiteUtils.nextMidletSuiteToRun;
state.midletClassName = MIDletSuiteUtils.nextMidletToRun;
state.arg0 = MIDletSuiteUtils.arg0ForNextMidlet;
state.arg1 = MIDletSuiteUtils.arg1ForNextMidlet;
state.arg2 = MIDletSuiteUtils.arg2ForNextMidlet;
state.runtimeInfo.memoryReserved =
MIDletSuiteUtils.memoryReserved;
state.runtimeInfo.memoryTotal = MIDletSuiteUtils.memoryTotal;
state.runtimeInfo.priority = MIDletSuiteUtils.priority;
state.runtimeInfo.profileName = MIDletSuiteUtils.profileName;
} else if (state.lastSuiteId !=
MIDletSuite.UNUSED_SUITE_ID) {
state.suiteId = state.lastSuiteId;
state.midletClassName = state.lastMidletClassName;
state.arg0 = state.lastArg0;
state.arg1 = state.lastArg1;
/* Avoid an endless loop. */
state.lastSuiteId = MIDletSuite.UNUSED_SUITE_ID;
state.lastMidletClassName = null;
state.lastArg0 = null;
state.lastArg1 = null;
/*
* This could an bad JAD from an auto test suite,
* so make sure the status to OK, the native
* code will run the last suite.
*/
state.status = CommandState.OK;
}
}
state.save();
|
protected void | exitLoader()Gracefully terminates VM with proper return code
/* Return specific non-zero number so the native AMS code can
* know that this is graceful exit and not VM abort. */
CommandState.exitInternal(CommandState.MAIN_EXIT);
|
protected void | init()Extends base class initialization with initializatons
specific for the AMS task
/*
* WARNING: Don't add any calls before this !
*
* Register AMS task ID native global variable.
* Since native functions rely on this value to distinguish
* whether Java AMS is running, this MUST be called before any
* other native functions from this Isolate. I.E. This call
* must be the first thing this main make.
*/
MIDletSuiteUtils.registerAmsIsolateId();
super.init();
|
protected void | initGlobalSystems()Inits global systems common for all started MIDlet suite tasks.
The systems should be initialized only once in the AMS task.
// Initialize AMS task resources needed for all tasks
MIDletSuiteUtils.initAmsResources();
// Initialize JSR subsystems
JSRInitializer.init();
// Initaialize automation API
AutomationInitializer.init(
eventQueue, midletControllerEventProducer);
// Start inbound connection watcher thread.
PushRegistryInternal.startListening();
// Initialize the Content Handler Monitor of MIDlet exits
CHManager.getManager(internalSecurityToken).initCleanupMonitor(
midletProxyList);
// Initialize WMA's cleanup monitor
WMACleanupMonitor.init(midletProxyList);
|
protected void | initSuiteEnvironment()Inits created MIDlet suite environment objects and global
subsystems needed for all suites.
The method also loads MIDlet suite paramaters and arguments
from the natively saved CommandState instance.
super.initSuiteEnvironment();
AmsUtil.initClass(
midletProxyList, midletControllerEventProducer);
MIDletProxy.initClass(foregroundEventProducer, midletEventProducer);
MIDletProxyList.initClass(midletProxyList);
// Listen for start MIDlet requests from the other isolates
ExecuteMIDletEventListener.startListening(
internalSecurityToken,
displayEventHandler,
eventQueue);
// Init gloabal systems common for all isolates
initGlobalSystems();
|
public static void | main(java.lang.String[] args)Called at the initial start of the VM.
Initializes internal security and any other AMS classes related
classes before starting the MIDlet.
try {
MIDletSuiteLoader loader = new MIDletSuiteLoader();
loader.runMIDletSuite();
} catch (Throwable t) {
t.printStackTrace();
}
|
protected void | reportError(int errorCode, java.lang.String details)Updates CommandState status and displays proper
exception message to user
state.status = errorCode;
// Initialize display alerts state on first error handling
if (disableAlerts < 0) {
disableAlerts = Configuration.getIntProperty(
"DisableStartupErrorAlert", 0);
}
int msgId = getErrorMessageId(errorCode);
String errorMsg = Resource.getString(msgId);
if (details != null) {
errorMsg += "\n\n" + details;
}
if (disableAlerts == 0) {
displayException(errorMsg);
}
// Error message is always obtained for logging
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_CORE, errorMsg);
}
|
protected void | setSuiteProperties()Sets suite arguments as temporary suite properties.
The implementation extends base class method with
additional properties specific for AMS MIDlet in
the internal suite.
super.setSuiteProperties();
// Handle logo displaying for Manager MIDlet
if (suiteId == MIDletSuite.INTERNAL_SUITE_ID) {
// Disable logo when startup performance is being
// measured or if the logo has been displayed already
if (Constants.MEASURE_STARTUP || state.logoDisplayed) {
midletSuite.setTempProperty(
internalSecurityToken, "logo-displayed", "");
} else {
state.logoDisplayed = true;
}
}
|