midletsuitestorage.java
来自「This is a resource based on j2me embedde」· Java 代码 · 共 774 行 · 第 1/2 页
JAVA
774 行
* jarFilename - name of the downloaded MIDlet suite jar file; * suiteName - name of the suite; * suiteVendor - vendor of the suite; * authPath - authPath if signed, the authorization path starting * with the most trusted authority; * domain - security domain of the suite; * trusted - true if suite is trusted; * verifyHash - may contain hash value of the suite with * preverified classes or may be NULL; * </pre> * * @param suiteSettings structure containing the following information:<br> * <pre> * permissions - permissions for the suite; * pushInterruptSetting - defines if this MIDlet suite interrupt * other suites; * pushOptions - user options for push interrupts; * suiteId - unique ID of the suite, must be equal to the one given * in installInfo; * boolean enabled - if true, MIDlet from this suite can be run; * </pre> * * @param msi structure containing the following information:<br> * <pre> * suiteId - unique ID of the suite, must be equal to the value given * in installInfo and suiteSettings parameters; * storageId - ID of the storage where the MIDlet should be installed; * numberOfMidlets - number of midlets in the suite; * displayName - the suite's name to display to the user; * midletToRunClassName - the midlet's class name if the suite contains * only one midlet, ignored otherwise; * iconName - name of the icon for this suite. * </pre> * * @param jadProps properties defined in the application descriptor * * @param jarProps properties of the manifest * * @exception IOException is thrown, if an I/O error occurs during * storing the suite * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked */ public synchronized void storeSuite(InstallInfo installInfo, SuiteSettings suiteSettings, MIDletSuiteInfo msi, Properties jadProps, Properties jarProps) throws IOException, MIDletSuiteLockedException { /* * Convert the property args to String arrays to save * creating the native KNI code to access the object. */ String[] strJadProperties = getPropertiesStrings(jadProps); String[] strJarProperties = getPropertiesStrings(jarProps); nativeStoreSuite(installInfo, suiteSettings, msi, null, strJadProperties, strJarProperties); } /** * Stores hash value of the suite with preverified classes * * @param id unique ID of the suite * @param verifyHash hash value of the suite with preverified classes */ public native void storeSuiteVerifyHash(int id, byte[] verifyHash); /** * Disables a suite given its suite ID. * <p> * The method does not stop the suite if is in use. However any future * attepts to run a MIDlet from this suite while disabled should fail. * * @param id suite ID for the installed package * * @exception IllegalArgumentException if the suite cannot be found * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked for updating */ public native void disable(int id) throws MIDletSuiteLockedException; /** * Enables a suite given its suite ID. * <p> * The method does update an suites that are currently loaded for * settings or of application management purposes. * * @param id suite ID for the installed package * * @exception IllegalArgumentException if the suite cannot be found * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked for updating */ public native void enable(int id) throws MIDletSuiteLockedException; /** * Removes a software package given its suite ID. * The content handler manager is called to remove any registrations, * if any. * <p> * If the component is in use it must continue to be available * to the other components that are using it. The resources it * consumes must not be released until it is not in use. * * @param id suite ID for the installed package * * @exception IllegalArgumentException if the suite cannot be found * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked */ public void remove(int id) throws MIDletSuiteLockedException { remove0(id); /* * If no exception occurs, * remove the content handler registrations, if any. */ CHManager.getManager(classSecurityToken).uninstall(id); } /** * Moves a software package with given suite ID to the specified storage. * * @param suiteId suite ID for the installed package * @param newStorageId new storage ID * * @exception IllegalArgumentException if the suite cannot be found or * invalid storage ID specified * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked * @exception IOException if an I/O error occurred * @exception OutOfMemoryError if out of memory */ public native void changeStorage(int suiteId, int newStorageId) throws IllegalArgumentException, MIDletSuiteLockedException, IOException, OutOfMemoryError; /** * Native method void moveSuiteToFolder(...) of * com.sun.midp.midletsuite.MIDletSuiteStorage. * <p> * Moves a software package with given suite ID to the specified folder. * * @param suiteId suite ID for the installed package * @param newFolderId folder ID * * @exception IllegalArgumentException if the suite cannot be found or * invalid folder ID specified * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked * @exception IOException if an I/O error occurred * @exception OutOfMemoryError if out of memory */ public native void moveSuiteToFolder(int suiteId, int newFolderId) throws IllegalArgumentException, MIDletSuiteLockedException, IOException, OutOfMemoryError; /** * Removes all suites with the temporary flag set to true. */ public synchronized void removeTemporarySuites() { final int[] suiteIds = getListOfSuites(); for (int i = 0; i < suiteIds.length; ++i) { try { final MIDletSuiteInfo suiteInfo = getMIDletSuiteInfo(suiteIds[i]); if (suiteInfo.temporary) { remove(suiteIds[i]); } } catch (final IOException e) { // skip this suite } catch (final MIDletSuiteLockedException e) { // skip this suite } } } /** * Implementation for storeSuite() and storeSuiteComponent(). * Stores or updates a midlet suite or a dynamic component. * * @param installInfo structure containing the following information:<br> * <pre> * id - unique ID of the suite; * jadUrl - where the JAD came from, can be null; * jarUrl - where the JAR came from; * jarFilename - name of the downloaded MIDlet suite jar file; * suiteName - name of the suite; * suiteVendor - vendor of the suite; * authPath - authPath if signed, the authorization path starting * with the most trusted authority; * domain - security domain of the suite; * trusted - true if suite is trusted; * verifyHash - may contain hash value of the suite with * preverified classes or may be NULL; * </pre> * * @param suiteSettings structure containing the following information:<br> * <pre> * permissions - permissions for the suite; * pushInterruptSetting - defines if this MIDlet suite interrupt * other suites; * pushOptions - user options for push interrupts; * suiteId - unique ID of the suite, must be equal to the one given * in installInfo; * boolean enabled - if true, MIDlet from this suite can be run; * </pre> * * @param msi structure containing the following information:<br> * <pre> * suiteId - unique ID of the suite, must be equal to the value given * in installInfo and suiteSettings parameters; * storageId - ID of the storage where the MIDlet should be installed; * numberOfMidlets - number of midlets in the suite; * displayName - the suite's name to display to the user; * midletToRunClassName - the midlet's class name if the suite contains * only one midlet, ignored otherwise; * iconName - name of the icon for this suite. * </pre> * msi is null if a dynamic component rather than a suite is being saved * * @param ci structure containing the following information:<br> * <pre> * componentId - unique ID of the component being saved * suiteId - unique ID of the suite that the component belongs to, * must be equal to the value given in installInfo and * suiteSettings parameters; * trusted - true if component is trusted, must be equal to the * value given in installInfo; * displayName - the suite's name to display to the user. * </pre> * ci is null if a suite rather than a dynamic component is being saved * * @param jadProps properties the JAD as an array of strings in * key/value pair order, can be null if jadUrl is null * * @param jarProps properties of the manifest as an array of strings * in key/value pair order * * @exception IOException is thrown, if an I/O error occurs during * storing the suite * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked */ native void nativeStoreSuite(InstallInfo installInfo, SuiteSettings suiteSettings, MIDletSuiteInfo msi, Object ci, String[] jadProps, String[] jarProps) throws IOException, MIDletSuiteLockedException; /** * Native remove of a software package given its suite ID. * <p> * If the component is in use it must continue to be available * to the other components that are using it. The resources it * consumes must not be released until it is not in use. * * @param id suite ID for the installed package * * @exception IllegalArgumentException if the suite cannot be found * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked */ private native void remove0(int id) throws MIDletSuiteLockedException; /** * Fill plain array with properties key/value String pairs. * It's needed to simplify properties using in a native code. * * @param props properties to get Strings from * * @return array of Strings filled with property key/value pairs */ static String[] getPropertiesStrings(Properties props) { if (props != null) { int size = props.size(); String[] res = new String[size * 2]; for (int i = 0, j = 0; i < size; i++) { res[j++] = props.getKeyAt(i); res[j++] = props.getValueAt(i); } return res; } else return null; } // ------------ Graphical App Manager ------------------ /** * Saves any of the settings (security or others) that the user may have * changed. * * @param id ID of the suite * @param pushInterruptSetting push interrupt setting * @param pushOptions push options * @param permissions security permissions for the suite * * @exception IOException if an error happens while writing */ public void saveSuiteSettings(int id, byte pushInterruptSetting, int pushOptions, byte[] permissions) throws IOException { SuiteSettings settings = new SuiteSettings(id); settings.setPushInterruptSetting(pushInterruptSetting); settings.setPushOptions(pushOptions); settings.setPermissions(permissions); settings.save(); } /** * Gets the amount of storage on the device that this suite is using. * This includes the JAD, JAR, management data, and RMS. * * @param id ID of a MIDlet suite * * @return number of bytes of storage the suite is using */ public native int getStorageUsed(int id); /** * List all installed software packages by storage name. * * @return an array of ints of the storage names for the * installed packages * @exception SecurityException if the caller does not have permission * to see what software is installed */ public synchronized int[] getListOfSuites() { int n = getNumberOfSuites(); if (n < 0) { if (Logging.REPORT_LEVEL <= Logging.ERROR) { Logging.report(Logging.ERROR, LogChannels.LC_AMS, "Error in getNumberOfSuites(): returned " + n); } n = 0; } int[] array = new int[n]; if (n > 0) { getSuiteList(array); } return array; } /** * Returns an array of the names of record stores owned by the * MIDlet suite. * * The order of RecordStore names returned is implementation * dependent. * * @param suiteId ID of the MIDlet suite that owns the record store * * @return array of the names of record stores owned by the * MIDlet suite or null if the MIDlet suite does not have * any record stores */ public String[] listRecordStores(int suiteId) { return RecordStoreImpl.listRecordStores(classSecurityToken, suiteId); } /** * Get the number of installed of MIDlet suites. * * @return the number of installed suites or -1 in case of error */ private native int getNumberOfSuites(); /** * Retrieves the list of MIDlet suites and store them into a Vector * object. Each element in the Vector is the storage name * of an installed application. * * @param suites an empty array of suite IDs to fill, call * getNumberOfSuites to know how big to make the array */ private native void getSuiteList(int[] suites); /* * Gets a secure filename base (including path separator if needed) * for the suite. File build with the base will be automatically deleted * when the suite is removed. */ public native String getSecureFilenameBase(int suiteId);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?