SMMManagerpublic class SMMManager extends MIDlet implements ApplicationManager, MIDletProxyListListener, RunnableThis is an implementation of the ApplicationManager interface
for the MVM mode of the VM running with only one midlet at time.
Application manager controls midlet life cycle:
- installs, updates and removes midlets/midlet suites
- launches and terminates midlets
- displays info about a midlet/midlet suite
- shuts down the AMS system |
Fields Summary |
---|
private static final String | DISCOVERY_APPConstant for the discovery application class name. | private static final String | INSTALLERConstant for the graphical installer class name. | private static final String | CA_MANAGERConstant for the CA manager class name. | private static boolean | firstTrue until constructed for the first time. | private MIDletSuiteStorage | midletSuiteStorageMIDlet Suite storage object. | private AppManagerUI | appManagerUIScreen that displays all installed midlets and installer | private MIDletProxyList | midletProxyListMIDlet proxy list reference. | private boolean | allowMidletLaunchIf true, MIDlet can be launched. | int | suiteIdID of the suite to run. | String | classNameClass name of the MIDlet to run. | String | displayNameDisplay name of the MIDlet to run. | String | arg0If not null, this string will be available to the
MIDlet as application property arg-0 | String | arg1If not null, this string will be available to the
MIDlet as application property arg-1 | String | arg2If not null, this string will be available to the
MIDlet as application property arg-2 | DisplayError | displayErrorUI to display error alerts. |
Constructors Summary |
---|
public SMMManager()Create and initialize a new Manager MIDlet.
midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage();
/*
* Listen to the MIDlet proxy list.
* this allows us to notify the Application Selector
* of any changes whenever switch back to the AMS.
*/
midletProxyList = MIDletProxyList.getMIDletProxyList();
midletProxyList.addListener(this);
midletProxyList.setDisplayController(
new SMMDisplayController(midletProxyList,
MIDletSuite.INTERNAL_SUITE_ID, this.getClass().getName()));
PushRegistryInternal.setMvmSingleMidletMode();
GraphicalInstaller.initSettings();
first = (getAppProperty("logo-displayed") == null);
Display display = Display.getDisplay(this);
displayError = new DisplayError(display);
// AppSelector will be set to be current at the end of its constructor
appManagerUI = new AppManagerUI(this, display, displayError, first, null);
if (first) {
first = false;
}
|
Methods Summary |
---|
public void | destroyApp(boolean unconditional)Destroy cleans up.
// IMPL_NOTE: remove this:
GraphicalInstaller.saveSettings(null, MIDletSuite.UNUSED_SUITE_ID);
// Ending this MIDlet ends all others.
midletProxyList.shutdown();
| public void | exitMidlet(RunningMIDletSuiteInfo suiteInfo)Exit the midlet with the passed in midlet suite info.
| public void | installSuite()Discover and install a suite.
try {
runMidlet(MIDletSuite.INTERNAL_SUITE_ID, DISCOVERY_APP,
Resource.getString(ResourceConstants.INSTALL_APPLICATION));
} catch (Exception ex) {
displayError.showErrorAlert(Resource.getString(
ResourceConstants.INSTALL_APPLICATION),
ex, null, null);
}
| public void | launchCaManager()Launch the CA manager.
try {
MIDletSuiteUtils.execute(MIDletSuite.INTERNAL_SUITE_ID, CA_MANAGER,
Resource.getString(ResourceConstants.CA_MANAGER_APP));
} catch (Exception ex) {
displayError.showErrorAlert(Resource.getString(
ResourceConstants.CA_MANAGER_APP), ex, null, null);
}
| public void | launchSuite(RunningMIDletSuiteInfo suiteInfo, java.lang.String midletToRun)Launches a suite.
if (Constants.MEASURE_STARTUP) {
System.err.println("Application Startup Time: Begin at "
+System.currentTimeMillis());
}
try {
// Create an instance of the MIDlet class
// All other initialization happens in MIDlet constructor
runMidlet(suiteInfo.suiteId, midletToRun,
suiteInfo.displayName);
} catch (Exception ex) {
displayError.showErrorAlert(suiteInfo.displayName, ex, null, null);
}
| public void | midletAdded(MIDletProxy midlet)Called when a MIDlet is added to the list.
appManagerUI.notifyMidletStarted(midlet);
| public void | midletRemoved(MIDletProxy midlet)Called when a MIDlet is removed from the list.
appManagerUI.notifyMidletExited(midlet);
| public void | midletStartError(int externalAppId, int suiteId, java.lang.String className, int errorCode, java.lang.String errorDetails)Called when error occurred while starting a MIDlet object.
allowMidletLaunch = true;
appManagerUI.notifyMidletStartError(suiteId, className,
errorCode, errorDetails);
| public void | midletUpdated(MIDletProxy midlet, int fieldId)Called when the state of a MIDlet in the list is updated.
appManagerUI.notifyMidletStateChanged(midlet);
| public void | moveToForeground(RunningMIDletSuiteInfo suiteInfo)Bring the midlet with the passed in midlet suite info to the
foreground.
| public void | pauseApp()Pause; there are no resources that need to be released.
| public void | run()Launches an application Isolate and waits for it to end.
try {
Isolate appIsolate = AmsUtil.startMidletInNewIsolate(suiteId,
className, displayName,
arg0, arg1, arg2);
appIsolate.waitForExit();
} finally {
suiteId = MIDletSuite.UNUSED_SUITE_ID;
className = null;
displayName = null;
arg0 = null;
arg1 = null;
arg2 = null;
allowMidletLaunch = true;
}
| private void | runMidlet(int id, java.lang.String midlet, java.lang.String displayName)Starts a MIDlet in a new Isolate.
runMidlet(id, midlet, displayName, null, null, null);
| private void | runMidlet(int id, 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 with the given arguments.
if (!allowMidletLaunch) {
return;
}
this.suiteId = id;
this.className = midlet;
this.displayName = displayName;
this.arg0 = arg0;
this.arg1 = arg1;
this.arg2 = arg2;
new Thread(this).start();
allowMidletLaunch = false;
| public void | shutDown()Shut downt the system
midletProxyList.shutdown();
| public void | startApp()Start app; there is nothing that needs to be done at start up.
| public void | updateSuite(RunningMIDletSuiteInfo suiteInfo)Update a suite.
try {
runMidlet(MIDletSuite.INTERNAL_SUITE_ID, INSTALLER,
null, "U", String.valueOf(suiteInfo.suiteId), null);
} catch (Exception ex) {
displayError.showErrorAlert(suiteInfo.displayName, ex, null, null);
}
|
|