Processes events.
Upon receiving a MIDlet created event a new MIDlet proxy will be
added to the list and the midletAdded method of all listeners will be
called with the new proxy.
Upon receiving a MIDlet destroyed event the MIDlet proxy corresponding
to the destroyed MIDlet will be removed from the list and the
midletRemoved method of all listeners
will be called with the removed proxy.
Upon receiving a MIDlet paused event the MIDlet proxy corresponding
to the paused MIDlet will have its midletState field set to
PAUSED and the midletUpdated method of all listeners
will be called with the updated proxy.
Upon receiving a foreground request event the MIDlet proxy corresponding
to the MIDlet requesting to be moved to the foreground will have its
wantsForeground field set to true and the midletUpdated method of all
listeners will be called with the updated proxy.
Upon receiving a background request event the MIDlet proxy corresponding
to the MIDlet requesting to be moved to the background will have its
wantsForeground field set to false and the midletUpdated method of all
listeners will be called with the updated proxy.
try {
NativeEvent nativeEvent = (NativeEvent)event;
switch (nativeEvent.getType()) {
case EventTypes.SHUTDOWN_EVENT:
midletControllerEventConsumer.handleDestroyAllEvent();
return;
case EventTypes.SELECT_FOREGROUND_EVENT:
if (Constants.MEASURE_STARTUP) {
// IMPL_NOTE: Usually MIDlet is explicitly switched to
// background on a native event, e.g. HOME key pressing.
// The native event handling is correct place to count
// the time of background switching from. However, native
// events handling is platform dependent, and in this way
// we have to instrument lot of platform code. That's why
// we selected this place as the the first shared place
// to start the measuring from. The measured time is
// less than the time experienced by user by the time to
// map native event to MIDP SELECT_FOREGROUND_EVENT
System.err.println("Switch To Background Time: Begin at " +
System.currentTimeMillis());
}
midletControllerEventConsumer.
handleMIDletForegroundSelectEvent(nativeEvent.intParam1);
return;
case EventTypes.FOREGROUND_TRANSFER_EVENT:
midletControllerEventConsumer.
handleMIDletForegroundTransferEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1,
nativeEvent.intParam2,
nativeEvent.stringParam2);
return;
case EventTypes.SET_FOREGROUND_BY_NAME_REQUEST:
midletControllerEventConsumer.
handleSetForegroundByNameRequestEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
return;
case EventTypes.PREEMPT_EVENT:
if (nativeEvent.intParam2 != 0) {
midletControllerEventConsumer.
handleDisplayPreemptStartEvent(
nativeEvent.intParam1,
nativeEvent.intParam4);
} else {
midletControllerEventConsumer.
handleDisplayPreemptStopEvent(
nativeEvent.intParam1,
nativeEvent.intParam4);
}
return;
case EventTypes.MIDLET_CREATED_NOTIFICATION:
midletControllerEventConsumer.handleMIDletCreateNotifyEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1,
nativeEvent.intParam2,
nativeEvent.intParam3,
nativeEvent.stringParam2);
return;
case EventTypes.MIDLET_ACTIVE_NOTIFICATION:
midletControllerEventConsumer.handleMIDletActiveNotifyEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
return;
case EventTypes.MIDLET_PAUSED_NOTIFICATION:
midletControllerEventConsumer.handleMIDletPauseNotifyEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
return;
case EventTypes.MIDLET_DESTROYED_NOTIFICATION:
midletControllerEventConsumer.handleMIDletDestroyNotifyEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
return;
case EventTypes.MIDLET_RESUME_REQUEST:
midletControllerEventConsumer.handleMIDletResumeRequestEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
case EventTypes.MIDLET_RS_PAUSED_NOTIFICATION:
midletControllerEventConsumer.handleMIDletRsPauseNotifyEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1);
return;
case EventTypes.DISPLAY_CREATED_NOTIFICATION:
midletControllerEventConsumer.handleDisplayCreateNotifyEvent(
nativeEvent.intParam1,
nativeEvent.intParam2,
nativeEvent.stringParam1);
return;
case EventTypes.FOREGROUND_REQUEST_EVENT:
midletControllerEventConsumer.
handleDisplayForegroundRequestEvent(
nativeEvent.intParam1,
nativeEvent.intParam4,
(nativeEvent.intParam2 != 0));
return;
case EventTypes.BACKGROUND_REQUEST_EVENT:
midletControllerEventConsumer.
handleDisplayBackgroundRequestEvent(
nativeEvent.intParam1,
nativeEvent.intParam4);
return;
case EventTypes.MIDLET_START_ERROR_EVENT:
midletControllerEventConsumer.handleMIDletStartErrorEvent(
nativeEvent.intParam1,
nativeEvent.stringParam1,
nativeEvent.intParam2,
nativeEvent.intParam3,
nativeEvent.stringParam2);
return;
case EventTypes.MIDLET_DESTROY_REQUEST_EVENT:
midletControllerEventConsumer.handleMIDletDestroyRequestEvent(
nativeEvent.intParam1,
nativeEvent.intParam4);
return;
case EventTypes.ACTIVATE_ALL_EVENT:
midletControllerEventConsumer.handleActivateAllEvent();
return;
case EventTypes.PAUSE_ALL_EVENT:
midletControllerEventConsumer.handlePauseAllEvent();
return;
case EventTypes.FATAL_ERROR_NOTIFICATION:
midletControllerEventConsumer.handleFatalErrorNotifyEvent(
nativeEvent.intParam1,
nativeEvent.intParam4);
return;
default:
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"unknown event (" +
event.getType() + ")");
}
return;
}
} catch (Throwable t) {
if (Logging.TRACE_ENABLED) {
Logging.trace(t, "Error occurred processing MIDlet event " +
event.getType());
}
}