Methods Summary |
---|
static synchronized com.sun.midp.automation.AutoMIDletStateController | getMIDletStateController()Gets AutoMIDletStateController instance.
if (stateController == null) {
stateController = new AutoMIDletStateController();
}
return stateController;
|
void | isolateExited(MIDletProxy midletProxy)Called when a MIDlet Isolate has exited.
synchronized (midletsInfo) {
AutoMIDletInfo info = midletsInfo.findMIDletInfo(midletProxy);
if (info != null) {
AutoMIDletImpl midlet = info.midlet;
if (midlet != null) {
midlet.stateChanged(AutoMIDletLifeCycleState.DESTROYED);
}
// remove MIDlet info from our list as well
midletsInfo.removeFromList(info);
}
}
|
public void | midletAdded(MIDletProxy midletProxy)Called when a MIDlet is added to the list.
synchronized (midletsInfo) {
AutoMIDletInfo info = midletsInfo.findMIDletInfo(midletProxy);
if (info != null) {
info.midletProxy = midletProxy;
// notify waiter that MIDlet has been created
midletsInfo.notify();
}
}
|
public void | midletRemoved(MIDletProxy midletProxy)Called when a MIDlet is removed from the list.
synchronized (midletsInfo) {
AutoMIDletInfo info = midletsInfo.findMIDletInfo(midletProxy);
if (info != null) {
startNotificationThread(info);
}
}
|
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.
synchronized (midletsInfo) {
AutoMIDletInfo info =
midletsInfo.findMIDletInfo(suiteID, className);
if (info != null) {
// set error flag and notify waiter
info.startError = true;
info.startErrorCode = errorCode;
info.startErrorDetails = errorDetails;
midletsInfo.notify();
}
}
|
public void | midletUpdated(MIDletProxy midletProxy, int fieldID)Called when the state of a MIDlet in the list is updated.
AutoMIDletImpl midlet = midletsInfo.findMIDlet(midletProxy);
// notify AutoMIDletImpl about state change
if (midlet != null &&
fieldID == MIDletProxyListListener.MIDLET_STATE) {
switch (midletProxy.getMidletState()) {
case MIDletProxy.MIDLET_ACTIVE:
midlet.stateChanged(AutoMIDletLifeCycleState.ACTIVE);
break;
case MIDletProxy.MIDLET_PAUSED:
midlet.stateChanged(AutoMIDletLifeCycleState.PAUSED);
break;
default:
break;
}
}
|
AutoMIDletImpl | startMIDlet(AutoMIDletDescriptorImpl midletDescriptor, java.lang.String[] args)Starts MIDlet.
AutoMIDletImpl midlet = null;
synchronized (midletsInfo) {
AutoSuiteDescriptorImpl suite;
suite = (AutoSuiteDescriptorImpl)
midletDescriptor.getSuiteDescriptor();
// what is needed to start MIDlet
int suiteID = suite.getSuiteID();
String midletClassName = midletDescriptor.getMIDletClassName();
String midletName = midletDescriptor.getMIDletName();
// MIDlet's arguments: only 3 are supported by now
String arg1 = null;
String arg2 = null;
String arg3 = null;
if (args != null) {
if (args.length > 0) {
arg1 = args[0];
}
if (args.length > 1) {
arg2 = args[1];
}
if (args.length > 2) {
arg3 = args[2];
}
}
// create info for MIDlet to be started
AutoMIDletInfo info = midletsInfo.addToList(
suiteID, midletClassName);
// initiate MIDlet starting
// IMPL_NOTE: add passing of memory quotas and VM profile name
Isolate isolate = AmsUtil.startMidletInNewIsolate(
suiteID, midletClassName, midletName,
arg1, arg2, arg3);
// wait for MIDlet to start
while (info.midletProxy == null &&
info.startError == false) {
try {
midletsInfo.wait();
} catch (InterruptedException e) {
// just ignore
}
}
// By now, either MIDlet is running,
// either there was a problem starting it
if (info.startError) {
midletsInfo.removeFromList(info);
String errorMsg = "";
switch (info.startErrorCode) {
case Constants.MIDLET_ISOLATE_CONSTRUCTOR_FAILED:
errorMsg = "MIDlet Isolate constructor failed";
break;
case Constants.MIDLET_RESOURCE_LIMIT:
errorMsg = "Not enough resources to start the MIDlet";
break;
case Constants.MIDLET_ISOLATE_RESOURCE_LIMIT:
errorMsg = "Maximum Isolate count is exceeded";
break;
case Constants.MIDLET_OUT_OF_MEM_ERROR:
errorMsg = "Not enough memory to start the MIDlet";
break;
case Constants.MIDLET_SUITE_NOT_FOUND:
errorMsg = "MIDlet suite is not found";
break;
case Constants.MIDLET_SUITE_DISABLED:
errorMsg = "MIDlet suite is disabled";
break;
case Constants.MIDLET_CLASS_NOT_FOUND:
errorMsg = "MIDlet class is not found";
break;
case Constants.MIDLET_INSTANTIATION_EXCEPTION:
errorMsg = "MIDlet instantiation exception";
break;
case Constants.MIDLET_ILLEGAL_ACCESS_EXCEPTION:
errorMsg = "MIDlet illegal access exception";
break;
case Constants.MIDLET_CONSTRUCTOR_FAILED:
errorMsg = "MIDlet constructor failed";
break;
default:
errorMsg = "Error starting MIDlet: " +
info.startErrorCode;
break;
}
String details = info.startErrorDetails;
if (details != null) {
errorMsg += " (" + details + ")";
}
throw new RuntimeException(errorMsg);
} else {
midlet = new AutoMIDletImpl(midletDescriptor);
info.midlet = midlet;
info.midletIsolate = isolate;
}
}
return midlet;
|
private void | startNotificationThread(AutoMIDletInfo info)Start notifier thread that will wait for the MIDlet's isolate to exit.
IsolateExitNotifier notifier = new IsolateExitNotifier();
notifier.midletProxy = info.midletProxy;
notifier.midletIsolate = info.midletIsolate;
notifier.parent = this;
new Thread(notifier).start();
|
void | switchTo(AutoMIDletImpl midlet, AutoMIDletLifeCycleState state)Initiates switching MIDlet to specified state.
MIDletProxy midletProxy = midletsInfo.findMIDletProxy(midlet);
if (midletProxy != null) {
if (state == AutoMIDletLifeCycleState.ACTIVE) {
midletProxy.activateMidlet();
} else if (state == AutoMIDletLifeCycleState.PAUSED) {
midletProxy.pauseMidlet();
} else if (state == AutoMIDletLifeCycleState.DESTROYED) {
midletProxy.destroyMidlet();
}
}
|