Methods Summary |
---|
private static native int | add0(byte[] connection)Native connection registry add connection function.
|
private static native long | addAlarm0(byte[] midlet, long time)Native connection registry add alarm function.
|
private static native void | checkInByHandle0(int handle)Native connection registry check in connection function.
|
private static native void | checkInByMidlet0(int suiteId, byte[] className)Native connection registry method to check in connections that are in
launch pending state for a specific MIDlet.
|
private static native int | checkInByName0(byte[] connection)Native connection registry check in connection function.
|
static boolean | checkInConnectionInternal(java.lang.String connection)Check in a push connection into AMS so the owning MIDlet can get
launched next time data is pushed. This method is used when a MIDlet
will not be able to get the connection and close (check in) the
connection for some reason. (normally because the user denied a
permission)
For datagram connections this function will discard the cached message.
For server socket connections this function will close the
accepted connection.
/* Verify that the connection requested is valid. */
if (connection == null || connection.length() == 0) {
throw new IllegalArgumentException("Connection missing");
}
byte[] asciiRegistration = Util.toCString(connection);
return checkInByName0(asciiRegistration) != -1;
|
static void | checkRegistration(Connection connection, java.lang.String midlet, java.lang.String filter)Check the registration arguments.
final String c = connection.getConnection();
ProtocolPush.getInstance(c).checkRegistration(c, midlet, filter);
|
private static java.lang.String[] | connectionsToArray(java.lang.String connections)Converts connections as string into string array.
if (connections == null) {
return new String[0];
}
/* Count the commas in the returned string */
int count = 0;
int offset = 0;
do {
offset = connections.indexOf(',", offset + 1);
count ++;
} while (offset > 0);
/* Now parse out the connections for easier access by caller. */
String[] ret = new String[count];
int start = 0;
for (int i = 0; i < count; i++) {
offset = connections.indexOf(',", start);
if (offset > 0) {
/* Up to the next comma */
ret[i] = connections.substring(start, offset);
} else {
/* From the last comma to the end of the string. */
ret[i] = connections.substring(start);
}
start = offset + 1;
}
return ret;
|
private static native int | del0(byte[] connection, byte[] storage)Native connection registry del connection function.
|
static native void | delAllForSuite0(int id)Native connection registry delete a suite's connections function.
|
private void | destroyAppMidlets()Destroy every MIDlet except the application manager midlet.
This should only be used in MVM Signal MIDlet Mode.
Enumeration midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy midlet = (MIDletProxy)midlets.nextElement();
if (midlet.getSuiteId() == MIDletSuite.INTERNAL_SUITE_ID &&
midlet.getClassName().indexOf("Manager") != -1) {
continue;
}
midlet.destroyMidlet();
}
|
private static native int | getEntry0(byte[] connection, byte[] regentry, int entrysz)Native connection registry lookup registry entry from a
specific connection.
|
public static java.lang.String | getFilter(java.lang.String connection)Retrieve the registered filter for a requested connection.
String filter = null;
byte[] asciiConn = Util.toCString(connection);
byte[] registryEntry = new byte[512];
if (getEntry0(asciiConn, registryEntry, 512) == 0) {
String name = Util.toJavaString(registryEntry);
try {
int comma1 = name.indexOf(',", 0);
int comma2 = name.indexOf(',", comma1 + 1);
int comma3 = name.indexOf(',", comma2 + 1);
filter = name.substring(comma2+1, comma3).trim();
} catch (Exception e) {
if (Logging.TRACE_ENABLED) {
Logging.trace(e, null);
}
}
}
return filter;
|
public static java.lang.String | getMIDlet(java.lang.String connection)Retrieve the registered MIDlet for a requested connection.
String midlet = null;
byte[] asciiConn = Util.toCString(connection);
byte[] registryEntry = new byte[512];
if (getEntry0(asciiConn, registryEntry, 512) == 0) {
String name = Util.toJavaString(registryEntry);
try {
int comma1 = name.indexOf(',", 0);
int comma2 = name.indexOf(',", comma1 + 1);
midlet = name.substring(comma1+1, comma2).trim();
} catch (Exception e) {
if (Logging.TRACE_ENABLED) {
Logging.trace(e, null);
}
}
}
return midlet;
|
private static native int | getMIDlet0(int handle, byte[] regentry, int entrysz)Native connection registry lookup for MIDlet name from file
descriptor.
|
public static void | initSecurityToken(com.sun.midp.security.SecurityToken token)Initializes the security token for this class, so it can
perform actions that a normal MIDlet Suite cannot.
if (classSecurityToken == null) {
classSecurityToken = token;
}
|
private void | launchEntry(java.lang.String name)Parse the registration entry and launch the associated
MIDlet .
String conn;
String midlet;
String filter;
String strSuiteId;
int id;
MIDletSuite next = null;
/*
* Parse the comma separated values -
* " connection, midlet, filter, id"
* " midlet, wakeup, midlet suite ID"
*/
int comma1 = name.indexOf(',", 0);
int comma2 = name.indexOf(',", comma1 + 1);
int comma3 = name.indexOf(',", comma2 + 1);
if (comma3 == -1) {
/* Alarm was triggered */
conn = null;
midlet = name.substring(0, comma1).trim();
strSuiteId = name.substring(comma2+1).trim();
} else {
conn = name.substring(0, comma1).trim();
midlet = name.substring(comma1+1, comma2).trim();
filter = name.substring(comma2+1, comma3).trim();
strSuiteId = name.substring(comma3+1).trim();
}
try {
/*
* IMPL_NOTE: here it's assumed that when a suiteId is converted
* to string the padding zeroes are placed _before_ the value,
* for ex., suiteId 3 is converted into "00000003".
* MIDletSuiteStorage.stringToSuiteId() API should be added later.
*/
id = Integer.parseInt(strSuiteId);
} catch (NumberFormatException nfe) {
id = MIDletSuite.UNUSED_SUITE_ID;
}
try {
/*
* Check to see if the MIDlet is already started.
*/
if (midletProxyList.isMidletInList(id, midlet)) {
if (conn != null) {
checkInConnectionInternal(conn);
}
return;
}
next = storage.getMIDletSuite(id, false);
if (next == null) {
if (conn != null) {
checkInConnectionInternal(conn);
}
return;
}
if ((next.getPushOptions() & PUSH_OPT_WHEN_ONLY_APP) != 0 &&
!onlyAppManagerRunning()) {
if (conn != null) {
checkInConnectionInternal(conn);
}
return;
}
if (!next.permissionToInterrupt(conn)) {
// user does not want the interruption
if (conn != null) {
checkInConnectionInternal(conn);
}
return;
}
if (MIDletSuiteUtils.execute(classSecurityToken, id, midlet,
null)) {
/* We are in SVM mode, destroy all running MIDlets. */
MIDletStateHandler.getMidletStateHandler().destroySuite();
} else if (mvmSingleMidletMode) {
destroyAppMidlets();
}
} catch (Throwable e) {
// Could not launch requested push entry
if (conn != null) {
checkInConnectionInternal(conn);
}
if (Logging.TRACE_ENABLED) {
Logging.trace(e, null);
}
} finally {
if (next != null) {
next.close();
}
}
|
private static native int | list0(byte[] midlet, boolean available, byte[] connectionlist, int listsz)Native connection registry list connection function.
|
public static java.lang.String[] | listConnections(com.sun.midp.midlet.MIDletSuite midletSuite, boolean available)Return a list of registered connections for the current
MIDlet suite.
return connectionsToArray(listConnections(midletSuite.getID(),
available));
|
static java.lang.String | listConnections(int id, boolean available)Return a list of registered connections for given
MIDlet suite. AMS permission is required.
byte[] nativeID;
String connections = null;
byte[] connlist;
nativeID = Util.toCString(suiteIdToString(id));
connlist = new byte[512];
if (list0(nativeID, available, connlist, 512) == 0) {
connections = Util.toJavaString(connlist);
}
return connections;
|
public void | midletAdded(MIDletProxy midlet)Called when a MIDlet is added to the list, not used by this class.
|
public void | midletRemoved(MIDletProxy midlet)Called when a MIDlet is removed from the list, the connections
in "launch pending" state for this MIDlet will be checked in.
byte[] asciiClassName = Util.toCString(midlet.getClassName());
checkInByMidlet0(midlet.getSuiteId(), asciiClassName);
|
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. The
connections in "launch pending" state for this MIDlet will be checked
in.
byte[] asciiClassName = Util.toCString(className);
checkInByMidlet0(suiteId, asciiClassName);
|
public void | midletUpdated(MIDletProxy midlet, int fieldId)Called when the state of a MIDlet in the list is updated.
|
private boolean | onlyAppManagerRunning()Check to see if only the application manager MIDlet is running.
Enumeration midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy midlet = (MIDletProxy)midlets.nextElement();
if (midlet.getSuiteId() != MIDletSuite.INTERNAL_SUITE_ID ||
midlet.getClassName().indexOf("Manager") == -1) {
return false;
}
}
return true;
|
private native int | poll0(long time)Native function to test registered inbound connections
for new connection notification.
|
public static long | registerAlarm(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String midlet, long time)Register a time to launch the specified application. The
PushRegistry supports one outstanding wake up
time per MIDlet in the current suite. An application
is expected to use a TimerTask for notification
of time based events while the application is running.
If a wakeup time is already registered, the previous value will
be returned, otherwise a zero is returned the first time the
alarm is registered.
byte[] asciiName = Util.toCString(midlet + ","
+ time + ","
+ suiteIdToString(midletSuite));
return addAlarm0(asciiName, time);
|
public static void | registerConnection(com.sun.midp.midlet.MIDletSuite midletSuite, Connection connection, java.lang.String midlet, java.lang.String filter)Register a dynamic connection.
registerConnectionInternal(midletSuite,
connection.getConnection(), midlet, filter, true);
|
static void | registerConnectionInternal(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String connection, java.lang.String midlet, java.lang.String filter, boolean registerConnection)Register a dynamic connection with the
application management software. Once registered,
the dynamic connection acts just like a
connection preallocated from the descriptor file.
The internal implementation includes the storage name
that uniquely identifies the MIDlet .
This method bypasses the class loader specific checks
needed by the Installer .
if (registerConnection) {
/*
* No need to register connection when bypassChecks: restoring
* RFC: why add0 below?
*/
ProtocolPush.getInstance(connection)
.registerConnection(midletSuite, connection, midlet, filter);
}
byte[] asciiRegistration = Util.toCString(connection
+ "," + midlet
+ "," + filter
+ "," + suiteIdToString(midletSuite));
if (add0(asciiRegistration) == -1) {
// in case of Bluetooth URL, unregistration within Bluetooth
// PushRegistry was already performed by add0()
throw new IOException("Connection already registered");
}
|
public void | run()Run the polling loop to check for inbound connections.
int fd = -1;
int ret = 0;
while (true) {
try {
fd = poll0(System.currentTimeMillis());
if (fd != -1) {
if (pushEnabled) {
byte[] registryEntry = new byte[512];
if ((ret = getMIDlet0(fd, registryEntry, 512)) == 0) {
String name = Util.toJavaString(registryEntry);
launchEntry(name);
}
} else {
checkInByHandle0(fd);
}
}
} catch (Exception e) {
if (Logging.TRACE_ENABLED) {
Logging.trace(e, null);
}
}
}
|
static void | startListening()Start listening for push notifications. Will throw a security
exception if called by any thing other than the MIDletSuiteLoader.
(new Thread(new ConnectionRegistry())).start();
|
private static java.lang.String | suiteIdToString(int suiteId)Converts MIDlet suite ID into a string.
// assert storage != null; // Listener should be started before
return storage.suiteIdToString(suiteId);
|
private static java.lang.String | suiteIdToString(com.sun.midp.midlet.MIDletSuite midletSuite)Converts MIDlet suite ID into a string.
// assert midletSuite != null;
return suiteIdToString(midletSuite.getID());
|
public static boolean | unregisterConnection(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String connection)Remove a dynamic connection registration.
byte[] asciiRegistration = Util.toCString(connection);
byte[] asciiStorage = Util.toCString(suiteIdToString(midletSuite));
int ret = del0(asciiRegistration, asciiStorage);
if (ret == -2) {
throw new SecurityException("wrong suite");
}
return ret != -1;
|