questions about some states when installing applet.
hi all, i'm wondering about some states when installing an applet(in the scope of Applet's install method, before register), the version of the java card is 2.2.1.
1: which is the currently selected applet , Installer or applet?
PrivAccess.getSelectedAppID(currentChannel) == InstallerID
or
PrivAccess.getSelectedAppID(currentChannel) == AppletID
2: which is the current contextID, installer or applet?
PrivAccess.getCurrentAppID() == InstallerID
or
PrivAccess.getCurrentAppID() = AppletID
3: what's the value of the inProcessMethod flag, true or false?
PrivAccess.getPrivAccess().inProcessMethod() == true
or
PrivAccess.getPrivAccess().inProcessMethod() == false
thanks in advance
[769 byte] By [
hiyar.cna] at [2007-10-3 7:18:14]

1: which is the currently selected applet , Installer or applet?
=> PrivAccess.getSelectedAppID(currentChannel) == InstallerID
The applet being installed does not exist at the moment. After register() it can be selected.
2: which is the current contextID, installer or applet?
=> PrivAccess.getCurrentAppID() = AppletID
Even though install() method is a static method, context change occurs when install() is called. Because applet constructor will create objects and the owner(context) of those must be the applet not installer.
3: what's the value of the inProcessMethod flag, true or false?
=> PrivAccess.getPrivAccess().inProcessMethod() == false
inProcessMethod flag is turned off temporarily during install() method being processed. Having done install(), turns on the flag again.
Thanks for your reply.
I agree with you on 2nd and 3rd, but not on the 1st.
The explanation you provided above is reasonable, but when I've traced the whole procedure of applet installing, I found the currently selected applet is the applet being installed at this special moment.
The key point is about the following code of the AppletMgr:
// By calling setChannelContext() twice, the space is deallocated and reallocated dynamically.
if (myContextId != PrivAccess.NULL_CONTEXTID) {
NativeMethods.setChannelContext(currentChannel,
PrivAccess.NULL_CONTEXTID,
false);
}
NativeMethods.setChannelContext(currentChannel, contextId, isMultiSelectable);
/**
* Call the install method within a transaction, so that if applet
* creation fails, everything can be brought back to the old state.
* According to the Java Card runtime environment specifications "If the installation is
* unsuccessful, the Java Card runtime environment shall perform all cleanup when it regains control.
* That is, all persistent objects shall be returned to the state they had
* prior to calling the install method."
*/
NativeMethods.callInstall(theAddress,
contextId,
bArray,
m_paramOffset,
m_paramLength,
PackageMgr.getPkgIdForContext(pkgContext));
}
The parameter "contextId" of the second setChannelContext(...) and the callInstall(...) belongs to the applet being installed.
setChannelContext(...) successfully sets the currently selected appletId, it's the applet being installed..
callInstall(...) successfully sets the current contextId, it's the applet being installed.