Methods Summary |
---|
private static native void | exitInternal(int status)Exit the VM with an error code. Our private version of Runtime.exit.
This is needed because the MIDP version of Runtime.exit cannot tell
if it is being called from a MIDlet or not, so it always throws an
exception.
|
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.
// Since this is public method, guard against multiple calls
if (alreadyCalled) {
throw new SecurityException();
}
alreadyCalled = true;
try {
try {
singleton = new NativeAppManagerPeer();
} catch (Throwable exception) {
notifySystemStartError();
throw exception;
}
notifySystemStart();
singleton.processNativeAppManagerRequests();
} catch (Throwable exception) {
if (Logging.TRACE_ENABLED) {
Logging.trace(exception,
"Exception caught in NativeManagerPeer");
}
} finally {
exitInternal(MAIN_EXIT);
}
|
public void | midletAdded(MIDletProxy midlet)Called when a MIDlet is added to the list.
notifyMidletCreated(midlet.getExternalAppId());
|
public void | midletRemoved(MIDletProxy midlet)Called when a MIDlet is removed from the list.
notifyMidletDestroyed(midlet.getExternalAppId());
|
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.
notifyMidletStartError(externalAppId, errorCode);
|
public void | midletUpdated(MIDletProxy midlet, int fieldId)Called when the state of a MIDlet in the list is updated.
if (fieldId == MIDLET_STATE) {
if (midlet.getMidletState() == MIDletProxy.MIDLET_ACTIVE) {
notifyMidletActive(midlet.getExternalAppId());
return;
}
if (midlet.getMidletState() == MIDletProxy.MIDLET_PAUSED) {
notifyMidletPaused(midlet.getExternalAppId());
return;
}
}
|
public void | midpResumed()Called if MIDP system has been resumed.
notifySystemStart();
|
public void | midpSuspended()Called if MIDP system has been suspended.
notifySystemSuspended();
|
private static native void | notifyMidletActive(int externalAppId)Notify the native application manager that the MIDlet is active.
|
private static native void | notifyMidletCreated(int externalAppId)Notify the native application manager of the MIDlet creation.
|
private static native void | notifyMidletDestroyed(int externalAppId)Notify the native application manager that the MIDlet is destroyed.
|
private static native void | notifyMidletPaused(int externalAppId)Notify the native application manager that the MIDlet is paused.
|
private static native void | notifyMidletStartError(int externalAppId, int error)Notify the native application manager of the MIDlet creation.
|
private static native void | notifyOperationCompleted(int operation, int externalAppId, int retCode)Notify the native application manager that the system has completed
the requested operation and the result (if any) is available.
|
private static native void | notifySuiteTerminated(int suiteId)Notify the native application manager that the suite is terminated.
|
private static native void | notifySystemStart()Notify the native application manager of the system start up.
|
private static native void | notifySystemStartError()Notify the native application manager that the system had an error
starting.
|
private static native void | notifySystemSuspended()Notifies native application manager on MIDP suspension.
|
public boolean | preprocess(Event event, Event waitingEvent)Preprocess an event that is being posted to the event queue.
This method will get called in the thread that posted the event.
return true;
|
public void | process(Event event)Process an event.
This method will get called in the event queue processing thread.
String errorMsg = null;
NativeEvent nativeEvent = (NativeEvent)event;
MIDletProxy midlet = midletProxyList.findMIDletProxy(
nativeEvent.intParam1);
switch (nativeEvent.getType()) {
case EventTypes.NATIVE_MIDLET_EXECUTE_REQUEST:
if (midlet == null) {
if (nativeEvent.intParam2 == MIDletSuite.UNUSED_SUITE_ID) {
notifyMidletStartError(nativeEvent.intParam1,
Constants.MIDLET_ID_NOT_GIVEN);
} else if (nativeEvent.stringParam1 == null) {
notifyMidletStartError(nativeEvent.intParam1,
Constants.MIDLET_CLASS_NOT_GIVEN);
} else {
MIDletSuiteUtils.executeWithArgs(internalSecurityToken,
nativeEvent.intParam1, nativeEvent.intParam2,
nativeEvent.stringParam1, nativeEvent.stringParam2,
nativeEvent.stringParam3, nativeEvent.stringParam4,
nativeEvent.stringParam5, nativeEvent.intParam3,
nativeEvent.intParam4, nativeEvent.intParam5,
nativeEvent.stringParam6);
}
} else {
errorMsg = "Only one instance of a MIDlet can be launched";
}
break;
case EventTypes.NATIVE_MIDLET_RESUME_REQUEST:
if (midlet != null) {
midlet.activateMidlet();
} else {
errorMsg = "Invalid App Id";
}
break;
case EventTypes.NATIVE_MIDLET_PAUSE_REQUEST:
if (midlet != null) {
midlet.pauseMidlet();
} else {
errorMsg = "Invalid App Id";
}
break;
case EventTypes.NATIVE_MIDLET_DESTROY_REQUEST:
/*
* IMPL_NOTE: nativeEvent.intParam2 is a timeout value which
* should be passed to MIDletProxy.destroyMidlet().
*
*/
if (midlet != null) {
midlet.destroyMidlet();
} else {
errorMsg = "Invalid App Id";
}
break;
case EventTypes.NATIVE_MIDLET_GETINFO_REQUEST:
int isolateId = midlet.getIsolateId();
Isolate task = null;
Isolate[] allTasks = Isolate.getIsolates();
for (int i = 0; i < allTasks.length; i++) {
if (allTasks[i].id() == isolateId) {
task = allTasks[i];
break;
}
}
if (task != null) {
/* Structure to hold run time information about a midlet. */
RuntimeInfo runtimeInfo = new RuntimeInfo();
runtimeInfo.memoryTotal = task.totalMemory();
runtimeInfo.memoryReserved = task.reservedMemory();
runtimeInfo.usedMemory = task.usedMemory();
runtimeInfo.priority = task.getPriority();
// there is no Isolate API now
runtimeInfo.profileName = null;
saveRuntimeInfoInNative(runtimeInfo);
}
notifyOperationCompleted(EventTypes.NATIVE_MIDLET_GETINFO_REQUEST,
nativeEvent.intParam1, (task == null) ? 1 : 0);
break;
case EventTypes.NATIVE_SET_FOREGROUND_REQUEST:
// Allow Nams to explicitly set nothing to be in the foreground
// with special AppId 0
if (midlet != null ||
nativeEvent.intParam1 == Constants.MIDLET_APPID_NO_FOREGROUND) {
if (midletProxyList.getForegroundMIDlet() == midlet &&
midlet != null) {
// send the notification even if the midlet already has
// the foreground
NativeDisplayControllerPeer.notifyMidletHasForeground(
midlet.getExternalAppId());
} else {
midletProxyList.setForegroundMIDlet(midlet);
}
} else {
errorMsg = "Invalid App Id";
}
break;
default:
errorMsg = "Unknown event type "+event.getType();
break;
}
if (Logging.REPORT_LEVEL <= Logging.ERROR && errorMsg != null) {
Logging.report(Logging.ERROR, LogChannels.LC_AMS, errorMsg);
}
|
private void | processNativeAppManagerRequests()Called in the main VM thread to keep the thread alive to until
shutdown completes.
midletProxyList.waitForShutdownToComplete();
/*
* Shutdown the event queue gracefully to process any events
* that may be in the queue currently.
*/
eventQueue.shutdown();
|
private static native void | registerAmsIsolateId()Register the Isolate ID of the AMS Isolate by making a native
method call that will call JVM_CurrentIsolateId and set
it in the proper native variable.
|
private static native void | saveRuntimeInfoInNative(RuntimeInfo runtimeInfo)Saves runtime information from the given structure
into the native buffer.
|
public void | suiteTerminated(int suiteId)Called when a suite isolate is terminated.
notifySuiteTerminated(suiteId);
|