Managerpublic class Manager extends MIDlet implements ApplicationManagerThis is an implementation of the ApplicationManager interface
for the single VM mode of the VM.
In this mode the VM is shut down each time a MIDlet exits.
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 DisplayError | displayErrorUI to display error alerts. | private AppManagerUI | managerUIApplication Selector Screen. |
Constructors Summary |
---|
public Manager()Create and initialize a new Manager MIDlet.
midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage();
GraphicalInstaller.initSettings();
first = (getAppProperty("logo-displayed") == null);
Display display = Display.getDisplay(this);
displayError = new DisplayError(display);
// Get arguments to create AppManagerUI
String suiteIdStr = getAppProperty("arg-0");
int suiteId = MIDletSuite.UNUSED_SUITE_ID;
try {
suiteId = Integer.parseInt(suiteIdStr);
} catch (NumberFormatException e) {
suiteId = MIDletSuite.UNUSED_SUITE_ID;
}
if (suiteId != MIDletSuite.UNUSED_SUITE_ID) {
MIDletSuiteInfo sui = new MIDletSuiteInfo(suiteId);
if (suiteId == MIDletSuite.INTERNAL_SUITE_ID) {
// For internal suites midlet class name should be specified
sui.midletToRun = getAppProperty("arg-1");
}
// AppManagerUI will be set to be current at the end of its constructor
managerUI = new AppManagerUI(this, display, displayError, first, sui);
} else {
// AppManagerUI will be set to be current at the end of its constructor
managerUI = new AppManagerUI(this, display, displayError, first, null);
}
if (first) {
first = false;
}
|
Methods Summary |
---|
public void | destroyApp(boolean unconditional)Destroy cleans up.
GraphicalInstaller.saveSettings(null, MIDletSuite.UNUSED_SUITE_ID);
if (MIDletSuiteUtils.getNextMIDletSuiteToRun() !=
MIDletSuite.UNUSED_SUITE_ID) {
/*
* A MIDlet was pushed.
* So make sure this MIDlet is run after the pushed one.
*
* Note this call only is
* needed now because suites are not run concurrently and must
* be queued to be run after this MIDlet is destroyed.
*/
updateLastSuiteToRun();
}
| public void | exitMidlet(RunningMIDletSuiteInfo suiteInfo)Exit the midlet with the passed in midlet suite info.
| public void | installSuite()Discover and install a suite.
try {
MIDletStateHandler.getMidletStateHandler().startMIDlet(
DISCOVERY_APP,
Resource.getString(ResourceConstants.INSTALL_APPLICATION));
yieldForNextMidlet();
} catch (Exception ex) {
displayError.showErrorAlert(Resource.getString
(ResourceConstants.INSTALL_APPLICATION),
ex, null, null);
}
| public void | launchCaManager()Launch the CA manager.
try {
MIDletStateHandler.getMidletStateHandler().startMIDlet(
CA_MANAGER,
Resource.getString(ResourceConstants.CA_MANAGER_APP));
yieldForNextMidlet();
} 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
MIDletSuiteUtils.execute(suiteInfo.suiteId, midletToRun,
suiteInfo.displayName);
/*
* Give the new MIDlet the screen by destroy our self,
* because we are running in a limited VM and must
* restart the VM let the select suite run.
*/
yieldForNextMidlet();
} catch (Exception ex) {
displayError.showErrorAlert(suiteInfo.displayName, ex, null, null);
}
| 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 | shutDown()Shut down the system
MIDletProxyList.getMIDletProxyList().shutdown();
| public void | startApp()Start puts up a List of the MIDlets found in the descriptor file.
| private void | updateLastSuiteToRun()Set this MIDlet to run after the next MIDlet is run.
MIDletSuiteInfo msi = managerUI.getSelectedMIDletSuiteInfo();
if (msi == null) {
MIDletSuiteUtils.setLastSuiteToRun(MIDletStateHandler.
getMidletStateHandler().getMIDletSuite().getID(),
getClass().getName(), null, null);
} else {
String midletToRun = null;
if (msi.suiteId == MIDletSuite.INTERNAL_SUITE_ID) {
midletToRun = msi.midletToRun;
}
MIDletSuiteUtils.setLastSuiteToRun(MIDletStateHandler.
getMidletStateHandler().getMIDletSuite().getID(),
getClass().getName(), String.valueOf(msi.suiteId), midletToRun);
}
| public void | updateSuite(RunningMIDletSuiteInfo suiteInfo)Update a suite.
MIDletStateHandler midletStateHandler =
MIDletStateHandler.getMidletStateHandler();
MIDletSuite midletSuite = midletStateHandler.getMIDletSuite();
/*
* Setting arg 0 to "U" signals that arg 1 is a suite ID for updating.
*/
midletSuite.setTempProperty(null, "arg-0", "U");
midletSuite.setTempProperty(null, "arg-1",
String.valueOf(suiteInfo.suiteId));
try {
midletStateHandler.startMIDlet(INSTALLER, null);
yieldForNextMidlet();
} catch (Exception ex) {
displayError.showErrorAlert(suiteInfo.displayName, ex, null, null);
}
| private void | yieldForNextMidlet()Yield the VM so the next MIDlet can run. To yield set this MIDlet as
last MIDlet run after the next MIDlet suite is done and then destroy
this MIDlet. Note: if the system is changed to allow multiple suites
to run concurrently, this method will not be needed.
// We want this MIDlet to run after the next MIDlet is run.
updateLastSuiteToRun();
destroyApp(false);
notifyDestroyed();
|
|