FileDocCategorySizeDatePackage
InstallStateImpl.javaAPI DocphoneME MR2 API (J2ME)17859Wed May 02 18:00:04 BST 2007com.sun.midp.jump.installer

InstallStateImpl

public class InstallStateImpl extends Object implements com.sun.midp.midlet.MIDletSuite, com.sun.midp.installer.InstallState
Holds the state of an installation, so it can restarted after it has been stopped.

Fields Summary
public String
localJadUrl
Location for the downloaded JAD, could be null
public String
localJarUrl
Location for the downloaded JAR
public com.sun.midp.midletsuite.InstallInfo
installInfo
Contains the data obtained during the installation process
public com.sun.midp.midletsuite.SuiteSettings
suiteSettings
Contains the data obtained during the installation process
public int
storageId
ID of the storage where the new midlet suite will be installed.
public com.sun.midp.installer.InstallListener
listener
Receives warnings and status.
public long
startTime
When the install started, in milliseconds.
public int
nextStep
What to do next.
public boolean
stopInstallation
Signals the installation to stop.
public boolean
ignoreCancel
Signals that installation is at a point where cancel requests are ignored
public com.sun.midp.installer.InvalidJadException
exception
exception that stopped the installation.
public boolean
force
Option to force an overwrite of existing components without any version comparison.
public boolean
removeRMS
Option to force the RMS data of the suite to be overwritten to be removed without comparison to the new suite.
public byte[]
jad
Raw JAD.
public String
jadEncoding
character encoding of the JAD.
public com.sun.midp.installer.JadProperties
jadProps
Parsed JAD.
public com.sun.midp.installer.ManifestProperties
jarProps
Parsed manifest.
public com.sun.midp.io.j2me.storage.File
file
Cached File object.
protected String
username
User name for authentication.
protected String
password
Password for authentication.
public String
proxyUsername
User name for proxyAuthentication.
public String
proxyPassword
Password for proxy authentication.
public int
beginTransferDataStatus
Status to signal the beginning of the data transfer.
public int
transferStatus
Status for the data transfer method to give to the listener.
public com.sun.midp.security.SecurityHandler
securityHandler
Security Handler.
public byte[]
manifest
Holds the unzipped JAR manifest to be saved.
public com.sun.midp.io.j2me.storage.RandomAccessStream
storage
Cache of storage object.
public com.sun.midp.midletsuite.MIDletSuiteStorage
midletSuiteStorage
Cache of MIDlet suite storage object.
public String
storageRoot
The root of all MIDP persistent system data.
public boolean
isPreviousVersion
Signals that previous version exists.
public com.sun.midp.midletsuite.MIDletSuiteImpl
previousSuite
Previous MIDlet suite info.
public com.sun.midp.midletsuite.InstallInfo
previousInstallInfo
Previous MIDlet suite install info.
Constructors Summary
public InstallStateImpl()
Constructor.

        installInfo   = new InstallInfo(UNUSED_SUITE_ID);
        suiteSettings = new SuiteSettings(UNUSED_SUITE_ID);
    
Methods Summary
public voidcheckForPermission(int permission, java.lang.String resource)
Checks for permission and throw an exception if not allowed. May block to ask the user a question.

param
permission ID of the permission to check for, the ID must be from {@link com.sun.midp.security.Permissions}
param
resource string to insert into the question, can be null if no %2 in the question
exception
SecurityException if the permission is not allowed by this token
exception
InterruptedException if another thread interrupts the calling thread while this method is waiting to preempt the display.

        checkForPermission(permission, resource, null);
    
public voidcheckForPermission(int permission, java.lang.String resource, java.lang.String extraValue)
Checks for permission and throw an exception if not allowed. May block to ask the user a question.

param
permission ID of the permission to check for, the ID must be from {@link com.sun.midp.security.Permissions}
param
resource string to insert into the question, can be null if no %2 in the question
param
extraValue string to insert into the question, can be null if no %3 in the question
exception
SecurityException if the permission is not allowed by this token
exception
InterruptedException if another thread interrupts the calling thread while this method is waiting to preempt the display.


        securityHandler.checkForPermission(permission,
            Permissions.getTitle(permission),
            Permissions.getQuestion(permission),
            Permissions.getOneshotQuestion(permission),
            installInfo.suiteName, resource, extraValue,
            Permissions.getName(permission));
    
public voidcheckIfPermissionAllowed(int permission)
Checks to see the suite has the ALLOW level for specific permission. This is used for by internal APIs that only provide access to trusted system applications.

Only trust this method if the object has been obtained from the MIDletStateHandler of the suite.

param
permission permission ID from {@link com.sun.midp.security.Permissions}
exception
SecurityException if the suite is not allowed to perform the specified action

        throw new RuntimeException("Not Implemented");
    
public intcheckPermission(java.lang.String permission)
Gets the status of the specified permission. If no API on the device defines the specific permission requested then it must be reported as denied. If the status of the permission is not known because it might require a user interaction then it should be reported as unknown.

param
permission to check if denied, allowed, or unknown
return
0 if the permission is denied; 1 if the permission is allowed; -1 if the status is unknown

        throw new RuntimeException("Not Implemented");
    
public voidclose()
Close the opened MIDletSuite

    
public java.lang.StringgetAppProperty(java.lang.String key)
Gets a property of the application to be installed. First from the jaD, then if not found, the JAR manifeSt.

param
key key of the property
return
value of the property or null if not found

        String value;

        if (jadProps != null) {
            value = jadProps.getProperty(key);
            if (value != null) {
                return value;
            }
        }

        if (jarProps != null) {
            value = jarProps.getProperty(key);
            if (value != null) {
                return value;
            }
        }

        return null;
    
public java.lang.String[]getAuthPath()
Gets the authorization path of this suite. The path starts with the most trusted CA that authorized this suite.

return
array of CA names or null if the suite was not signed

        /*
         * The auth path returned is no a copy because this object is
         * only available to callers with the AMS permission, which
         * have permission to build auth paths for new suites.
         */
        return installInfo.getAuthPath();
    
public java.lang.StringgetDisplayName()
Returns the suite's name to display to the user.

return
suite's name that will be displayed to the user

        String displayName = getAppProperty(MIDletSuite.SUITE_NAME_PROP);

        if (displayName == null) {
            displayName = String.valueOf(installInfo.id);
        }

        return displayName;
    
public intgetID()
Gets the unique ID that the installed suite was stored with.

return
storage name that can be used to load the suite

        return installInfo.id;
    
public intgetJarSize()
Gets the expected size of the JAR.

return
size of the JAR in K bytes rounded up

        return (installInfo.expectedJarSize + 1023) / 1024;
    
public java.lang.StringgetJarUrl()
Gets the URL of the JAR.

return
URL of the JAR

        return installInfo.jarUrl;
    
public com.sun.midp.installer.InvalidJadExceptiongetLastException()
Gets the last recoverable exception that stopped the install. Non-recoverable exceptions are thrown and not saved in the state.

return
last exception that stopped the install

        return exception;
    
public java.lang.StringgetMIDletName(java.lang.String classname)
Get the name of a MIDlet.

param
classname classname of a MIDlet in the suite
return
name of a MIDlet to show the user

        throw new RuntimeException("Not Implemented");
    
public com.sun.midp.midletsuite.MIDletInfogetMidletInfo()
Returns the information about the first midlet in the suite.

return
MIDletInfo structure describing the first midlet or null if it is not available

        String midlet;

        midlet = getAppProperty("MIDlet-1");
        if (midlet == null) {
            return null;
        }

        return new MIDletInfo(midlet);
    
public intgetNumberOfMIDlets()
Counts the number of MIDlets from its properties. IMPL_NOTE: refactor to avoid duplication with MIDletSuiteImpl.

return
number of midlet in the suite

        int i;

        for (i = 1; getProperty("MIDlet-" + i) != null; i++);

        return (i-1);
    
public byte[]getPermissions()
Gets list of permissions for this suite.

return
array of permissions from {@link Permissions}

        return suiteSettings.getPermissions();
    
public java.lang.StringgetProperty(java.lang.String key)
Gets a property of the suite. A property is an attribute from either the application descriptor or JAR Manifest.

param
key the name of the property
return
A string with the value of the property. null is returned if no value is available for the key.

        return getAppProperty(key);
    
public bytegetPushInterruptSetting()
Gets push setting for interrupting other MIDlets. Reuses the Permissions.

return
push setting for interrupting MIDlets the value will be permission level from {@link Permissions}

        return suiteSettings.getPushInterruptSetting();
    
public intgetPushOptions()
Gets push options for this suite.

return
push options are defined in {@link PushRegistryImpl}

        return suiteSettings.getPushOptions();
    
public java.lang.StringgetSuiteName()
Gets the label for the downloaded JAR.

return
suite name

        return installInfo.suiteName;
    
public booleanisEnabled()
Determine if the a MIDlet from this suite can be run. Note that disable suites can still have their settings changed and their install info displayed.

return
true if suite is enabled, false otherwise

        throw new RuntimeException("Not Implemented");
    
public booleanisRegistered(java.lang.String midletName)
Indicates if the named MIDlet is registered in the suite with MIDlet-<n> record in the manifest or application descriptor.

param
midletName class name of the MIDlet to be checked
return
true if the MIDlet is registered

        String midlet;
        MIDletInfo midletInfo;

        for (int i = 1; ; i++) {
            midlet = getAppProperty("MIDlet-" + i);
            if (midlet == null) {
                return false; // We went past the last MIDlet
            }

            /* Check if the names match. */
            midletInfo = new MIDletInfo(midlet);
            if (midletInfo.classname.equals(midletName)) {
                return true;
            }
        }
    
public booleanisTrusted()
Indicates if this suite is trusted. (not to be confused with a domain named "trusted", this is used to determine if a trusted symbol should be displayed to the user and not used for permissions)

return
true if the suite is trusted false if not

        return installInfo.trusted;
    
public booleanisVerified()
Check if the suite classes were successfully verified during the suite installation.

return
true if the suite classes are verified, false otherwise

        return installInfo.verifyHash != null;
    
public booleanpermissionToInterrupt(java.lang.String connection)
Asks the user want to interrupt the current MIDlet with a new MIDlet that has received network data.

param
connection connection to place in the permission question or null for alarm
return
true if the use wants interrupt the current MIDlet, else false

        throw new RuntimeException("Not Implemented");
    
public voidsaveSettings()
Saves any the settings (security or others) that the user may have changed. Normally called by the scheduler after the last running MIDlet in the suite is destroyed. However it could be call during a suspend of the VM so that persistent settings of the suite can be preserved.

        throw new RuntimeException("Not Implemented");
    
public voidsetPassword(java.lang.String thePassword)
Sets the password to be used for HTTP authentication.

param
thePassword 8 bit password

        password = thePassword;
    
public voidsetProxyPassword(java.lang.String thePassword)
Sets the password to be used for HTTP proxy authentication.

param
thePassword 8 bit password

        proxyPassword = thePassword;
    
public voidsetProxyUsername(java.lang.String theUsername)
Sets the username to be used for HTTP proxy authentication.

param
theUsername 8 bit username, cannot contain a ":"

        proxyUsername = theUsername;
    
public voidsetTempProperty(com.sun.midp.security.SecurityToken token, java.lang.String key, java.lang.String value)
Replace or add a property to the suite for this run only.

param
token token with the AMS permission set to allowed
param
key the name of the property
param
value the value of the property
exception
SecurityException if the caller's token does not have internal AMS permission

        throw new RuntimeException("Not Implemented");
    
public voidsetUsername(java.lang.String theUsername)
Sets the username to be used for HTTP authentication.

param
theUsername 8 bit username, cannot contain a ":"

        username = theUsername;