Methods Summary |
---|
public void | addListener(DisplayControllerListener listener)Add a listener.
listeners.addElement(listener);
|
MIDletProxy | backgroundRequest(MIDletProxy midlet)Handles MIDlet background requests.
If the MIDlet is requesting to be put in the background is the
foreground MIDlet, then find a MIDlet to bring to the foreground
(see the findNextForeground method).
MIDletProxy foreground = midletProxyList.getForegroundMIDlet();
if (midlet != foreground) {
// not in the foreground, so don't change the foreground
return foreground;
}
return findNextForegroundMIDlet();
|
private void | clearLastMidletCreated(MIDletProxy midlet)Clear the last MIDlet created, if it is one given.
if (lastMidletCreated == midlet) {
lastMidletCreated = null;
}
|
MIDletProxy | endPreempting(int isolateId, int displayId)End the preempt an Isolate's displays.
Enumeration midlets;
MIDletProxy foreground;
MIDletProxy preempted;
MIDletProxy preempting = null;
/*
* Stop preempting all of the MIDlets that were preempted.
*/
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
MIDletProxy temp;
temp = current.getPreemptingDisplay();
if (temp == null) {
continue;
}
if (temp.getIsolateId() != isolateId) {
continue;
}
if (temp.getDisplayId() != displayId) {
continue;
}
preempting = temp;
current.setPreemptingDisplay(null);
midletProxyList.notifyListenersOfProxyUpdate(current,
MIDletProxyListListener.PREEMPTING_DISPLAY);
}
foreground = midletProxyList.getForegroundMIDlet();
if (foreground == null) {
return null;
}
if (preempting == null) {
return foreground;
}
preempted = preempting.getPreemptedMidlet();
// if the preempting display is not in the foreground then do nothing
if (foreground != preempting) {
return foreground;
}
preempted = preempting.getPreemptedMidlet();
if (preempted != null) {
return preempted;
}
return foreground;
|
private MIDletProxy | findNextForegroundMIDlet()Find a MIDlet that wants the foreground. If none wants the foreground
then find one that is not paused, if no find one that is paused
and wants the foreground, then find one that is paused.
Enumeration midlets;
// find the first task that is active and wants foreground
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_ACTIVE) {
continue;
}
if (current.wantsForeground()) {
return current;
}
}
// find the first task that is active
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_ACTIVE) {
return current;
}
}
// find the first task that is paused and wants the foreground
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_PAUSED) {
continue;
}
if (current.wantsForeground()) {
return current;
}
}
// find the first task that is paused
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_PAUSED) {
return current;
}
}
return null;
|
MIDletProxy | foregroundMidletChanging(MIDletProxy midlet)Call to notify that foreground MIDlet is changing and give the
display controller a chance to preempt the change.
Also the last MIDlet created state will be reset.
If the MIDlet to get the foreground is paused, then activate it.
MIDletProxy preempting;
if (midlet == null) {
return null;
}
preempting = midlet.getPreemptingDisplay();
if (preempting != null) {
return preempting;
}
clearLastMidletCreated(midlet);
if (midlet.getMidletState() == MIDletProxy.MIDLET_PAUSED) {
midlet.activateMidlet();
}
return midlet;
|
MIDletProxy | foregroundRequest(MIDletProxy midlet)Handles MIDlet foreground requests.
If proxy being updated belongs last MIDlet created in the proxy list,
then put the MIDlet in the foreground.
If there is no foreground MIDlet or the foreground MIDlet does not
want the foreground or the foreground MIDlet is paused, then put the
MIDlet in the foreground.
MIDletProxy foreground;
/*
* When the last MIDlet started wants the foreground automatically
* put in the foreground this time only.
*/
if (midlet == lastMidletCreated) {
return midlet;
}
foreground = midletProxyList.getForegroundMIDlet();
if (foreground == null || !foreground.wantsForeground() ||
foreground.getMidletState() == MIDletProxy.MIDLET_PAUSED) {
return midlet;
}
// don't change the foreground
return foreground;
|
MIDletProxy | midletActive(MIDletProxy midlet)Called when a MIDlet is move to active state.
return midletProxyList.getForegroundMIDlet();
|
void | midletCreated(MIDletProxy midlet)Update the last MIDlet created field so when the wantsForeground
field of the MIDletProxy is updated to be true, the MIDlet can
be automatically put into the foreground.
Called when a MIDlet is created to the proxy list.
lastMidletCreated = midlet;
|
MIDletProxy | midletDestroyed(MIDletProxy midlet)If the removed MIDlet is the foreground MIDlet find a new
foreground MIDlet. After clearing the last midlet created, treat this
state change as background request.
Called when a MIDlet is removed from the proxy list.
clearLastMidletCreated(midlet);
return backgroundRequest(midlet);
|
MIDletProxy | midletPaused(MIDletProxy midlet)Handles any possible foreground changes due the state of a MIDlet
changing to paused.
Treat this state change as a background request.
Called when the state of a MIDlet in the MIDlet proxy list is paused.
return backgroundRequest(midlet);
|
void | notifyListenersOfSelectForeground(boolean onlyFromLaunchedList)Notify the listeners of the display controller that foreground
selection ui should be launched.
for (int i = listeners.size() - 1; i >= 0; i--) {
DisplayControllerListener listener =
(DisplayControllerListener)listeners.elementAt(i);
listener.selectForeground(onlyFromLaunchedList);
}
|
public void | removeListener(DisplayControllerListener listener)Remove a listener for DisplayController.
listeners.removeElement(listener);
|
MIDletProxy | selectForeground(boolean onlyFromLaunchedList)Called to process a select foreground event. Processing this event
only needs to be done when application MIDlets are allowed to run
concurrently. In SVM mode the display controller returns
foreground MIDlet.
notifyListenersOfSelectForeground(onlyFromLaunchedList);
return midletProxyList.getForegroundMIDlet();
|
MIDletProxy | startPreempting(MIDletProxy preempting)Called to process a preempt event. The default is to preempt the
foreground.
MIDletProxy foreground;
foreground = midletProxyList.getForegroundMIDlet();
if (foreground != null) {
preempting.setPreemptedMidlet(foreground);
foreground.setPreemptingDisplay(preempting);
}
return preempting;
|
MIDletProxy | transferRequest(MIDletProxy origin, MIDletProxy target)Request a transfer of the foreground from one MIDlet to another.
The transfer only succeeds if the current foreground is the "from"
MIDlet.
MIDletProxy foreground = midletProxyList.getForegroundMIDlet();
if (origin == foreground) {
// Foreground is the requesting MIDlet, change to target
return target;
}
// The foreground is not the requesting origin; don't change
return foreground;
|