NamsManagerpublic class NamsManager extends javax.microedition.midlet.MIDlet implements javax.microedition.lcdui.CommandListenerWorks as a simple (display) manager to test NAMS. |
Fields Summary |
---|
private static com.sun.midp.events.EventCopyStorage | eventCopyStoragestores event copies for native events being tracked | private int[] | dummyIdarray if IDs for dummy midlets | private javax.microedition.lcdui.Command | cmdExit | private javax.microedition.lcdui.Command | cmdHide | private javax.microedition.lcdui.Command | cmdRefresh | private javax.microedition.lcdui.Command[] | cmdStart | private javax.microedition.lcdui.Command[] | cmdActivate | private javax.microedition.lcdui.Command[] | cmdPause | private javax.microedition.lcdui.Command[] | cmdDestroy | private javax.microedition.lcdui.Command | cmdI3Framework | private javax.microedition.lcdui.Form | formMIDlet's screen | private javax.microedition.lcdui.Display | displayreference to MIdlet's Display |
Constructors Summary |
---|
public NamsManager()public constructor
int i, j;
EventQueue eventQueue;
// appId = 0 is reserved for NamsManager itself
initNamsManager(MIDletSuiteUtils.getIsolateId());
dummyId = new int [3];
cmdExit = new Command("Destroy", Command.EXIT, 0);
cmdHide = new Command("Hide", Command.SCREEN, 0);
cmdRefresh = new Command("Refresh MIDlet status", Command.SCREEN, 0);
cmdStart = new Command[3];
cmdActivate = new Command[3];
cmdPause = new Command[3];
cmdDestroy = new Command[3];
for (i = 0; i < 3; ++i) {
dummyId[i] = 0;
cmdStart[i] = new Command("Start Dummy#" + (i+1),
Command.SCREEN, 0);
cmdActivate[i] = new Command("Activate Dummy#" + (i+1),
Command.SCREEN, 0);
cmdPause[i] = new Command("Pause Dummy#" + (i+1),
Command.SCREEN, 0);
cmdDestroy[i] = new Command("Destroy Dummy#" + (i+1),
Command.SCREEN, 0);
}
cmdI3Framework = new Command("Start I3 Nams Framework",
Command.SCREEN, 0);
form = new Form("NAMS Manager screen");
form.addCommand(cmdRefresh);
form.addCommand(cmdExit);
form.addCommand(cmdHide);
for (i = 0; i < 3; ++i) {
form.addCommand(cmdStart[i]);
form.addCommand(cmdActivate[i]);
form.addCommand(cmdPause[i]);
form.addCommand(cmdDestroy[i]);
}
form.addCommand(cmdI3Framework);
form.setCommandListener(this);
display = Display.getDisplay(this);
display.setCurrent(form);
|
Methods Summary |
---|
public void | commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable s)
if (c == cmdRefresh) {
refresh();
} else if (c == cmdExit) {
try {
destroyApp(true);
} catch (MIDletStateChangeException e) {};
} else if (c == cmdHide) {
midletSetForeground(findNextForegroundMIDlet(0));
} else if (c == cmdI3Framework) {
startInternalMidlet("com.sun.midp.i3test.NamsFramework",
/* null, null, null */
false, false);
} else {
int i;
for (i = 0; i < 3; ++i) {
if (c == cmdStart[i]) {
dummyId[i] =
startInternalMidlet(
"com.sun.midp.main.DummyNamsMIDlet" + (i+1),
/* null, null, null */
false, false);
} else if (c == cmdActivate[i]) {
if (dummyId[i] != 0) {
midletResume(dummyId[i]);
}
} else if (c == cmdPause[i]) {
if (dummyId[i] != 0) {
midletPause(dummyId[i]);
}
} else if (c == cmdDestroy[i]) {
if (dummyId[i] != 0) {
midletDestroy(dummyId[i]);
}
dummyId[i] = 0;
}
}
}
| protected void | destroyApp(boolean unconditional)
/* if (unconditional) */ {
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"NamsManager MIDlet: entered destroyed state ...");
notifyDestroyed();
MIDletProxyList list = MIDletProxyList.getMIDletProxyList();
if (list != null)
list.shutdown();
else {
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"NamsManager MIDlet: Proxy List is NULL !!!");
}
}
/* else {
throw new MIDletStateChangeException(
"NAMS Manager: I DO NOT want to be destroyed !");
} */
| static native int | findNextEmptyMIDlet(int appId)
| static native int | findNextForegroundMIDlet(int appId)
| static native int | getForegroundAppId()
| private java.lang.String | getMIDletStateString(int state)
switch (state) {
case NamsStorage.NAMS_STATE_NO:
return "NO";
case NamsStorage.NAMS_STATE_ACTIVE:
return "ACTIVE";
case NamsStorage.NAMS_STATE_PAUSED:
return "PAUSED";
case NamsStorage.NAMS_STATE_DESTROYED:
return "DESTROYED";
case NamsStorage.NAMS_STATE_ERROR:
return "ERROR";
case NamsStorage.NAMS_STATE_RESERVED:
return "RESERVED";
default:
return "INVALID";
}
| private native void | initNamsManager(int isolateId)
| public static void | midletCreateStart(int suiteId, java.lang.String className, int appId)
if (NamsStorage.getMIDletStateTrack(appId)) {
eventCopyStorage.putTail(
EventTypes.NATIVE_MIDLET_EXECUTE_REQUEST,
appId, suiteId, 0, 0,
className, null,
/* displayName, arg0, arg1, arg2 */
null, null, null, null);
}
NamsAPIWrapper.midletCreateStart(
suiteId, className,
/* displayName, arg0, arg1, arg2, */
appId);
| public static void | midletDestroy(int appId)
if (NamsStorage.getMIDletStateTrack(appId)) {
eventCopyStorage.putTail(
EventTypes.NATIVE_MIDLET_DESTROY_REQUEST,
appId, -1, 0, 0,
null, null, null, null, null, null);
}
NamsAPIWrapper.midletDestroy(appId);
| public static void | midletPause(int appId)
if (NamsStorage.getMIDletStateTrack(appId)) {
eventCopyStorage.putTail(
EventTypes.NATIVE_MIDLET_PAUSE_REQUEST,
appId, 0, 0, 0,
null, null, null, null, null, null);
}
NamsAPIWrapper.midletPause(appId);
| public static void | midletResume(int appId)
if (NamsStorage.getMIDletStateTrack(appId)) {
eventCopyStorage.putTail(
EventTypes.NATIVE_MIDLET_RESUME_REQUEST,
appId, 0, 0, 0,
null, null, null, null, null, null);
}
NamsAPIWrapper.midletResume(appId);
| public static void | midletSetBackground()
int appId = getForegroundAppId();
int nextFgAppId = findNextForegroundMIDlet(appId);
if (nextFgAppId == appId)
nextFgAppId = 0;
midletSetForeground(nextFgAppId);
| public static void | midletSetForeground(int appId)
if (NamsStorage.getDisplayStatusTrack(appId)) {
eventCopyStorage.putTail(
EventTypes.NATIVE_SET_FOREGROUND_REQUEST,
appId, 0, 0, 0,
null, null, null, null, null, null);
}
NamsAPIWrapper.midletSetForeground(appId);
| protected void | pauseApp()
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"NamsManager MIDlet: entered paused state ...");
resumeRequest();
| private void | refresh()
int i;
int midlet_state;
boolean display_status;
form.deleteAll();
for (i = 0; i < NamsStorage.NAMS_STORAGE_SIZE; ++i) {
midlet_state = NamsStorage.getMIDletState(i);
display_status = NamsStorage.getDisplayStatus(i);
if (midlet_state != NamsStorage.NAMS_STATE_NO || display_status) {
form.append("#" + i +
" state=" + getMIDletStateString(midlet_state) +
" display=" + ((display_status) ? "FG" : "BG"));
}
}
| protected void | startApp()
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"NamsManager MIDlet: entered active state ...");
display.setCurrent(form);
| static int | startInternalMidlet(java.lang.String className, boolean midlet_state_track, boolean display_status_track)
int appId = findNextEmptyMIDlet(getForegroundAppId());
if (appId == 0) {
Logging.report(Logging.ERROR, LogChannels.LC_CORE,
"NamsManager MIDlet: " +
"Failed to start MIDlet: no IDs available ...");
} else {
NamsStorage.setMIDletStateTrack(appId, midlet_state_track);
NamsStorage.setDisplayStatusTrack(appId, display_status_track);
midletCreateStart(MIDletSuite.INTERNAL_SUITE_ID, className,
/* "Display#" + appId, arg0, arg1, arg2, */
appId);
}
return appId;
|
|