midletsuiteimpl.jpp
来自「This is a resource based on j2me embedde」· JPP 代码 · 共 741 行 · 第 1/2 页
JPP
741 行
case Permissions.BLANKET: if (interruptOk) { suiteSettings.setPushInterruptSetting( Permissions.BLANKET_GRANTED); settingsChanged = true; return true; } suiteSettings.setPushInterruptSetting( Permissions.BLANKET_DENIED); settingsChanged = true; return false; case Permissions.SESSION: if (interruptOk) { return true; } return false; } /* Default case permission is ONE_SHOT or DENY */ if (interruptOk) { return true; } return false; } catch (InterruptedException ie) { return false; } finally { if (settingsChanged) { suiteSettings.save(); } } } /** * Indicates if the named MIDlet is registered in the suite * with MIDlet-<n> record in the manifest or * application descriptor. * * @param midletClassName class name of the MIDlet to be checked * * @return true if the MIDlet is registered */ public boolean isRegistered(String midletClassName) { String midlet; MIDletInfo midletInfo; guaranteeMIDletSuiteLocked("isRegistered"); for (int i = 1; ; i++) { midlet = getProperty("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(midletClassName)) { return true; } } } /** * Get the name of a MIDlet to display to the user from suite's * MIDlet-<n> record in the manifest or * application descriptor. * * @param className class name of the MIDlet to be checked * * @return name to display to the user */ public String getMIDletName(String className) { String midlet; MIDletInfo midletInfo; guaranteeMIDletSuiteLocked("getMIDletName"); for (int i = 1; ; i++) { midlet = getProperty("MIDlet-" + i); if (midlet == null) { return getProperty(SUITE_NAME_PROP); } /* Check if the names match. */ midletInfo = new MIDletInfo(midlet); if (midletInfo.classname.equals(className)) { return midletInfo.name; } } } /** * Indicates if this suite is trusted. * (not to be confused with a domain named "trusted", * this is used for extra checks beyond permission checking) * * @return true if the suite is trusted false if not */ public boolean isTrusted() { guaranteeMIDletSuiteLocked("isTrusted"); return installInfo.isTrusted(); } /** * Provides the number of of MIDlets in this suite. * * @return number of MIDlet in the suite */ public int getNumberOfMIDlets() { guaranteeMIDletSuiteLocked("getNumberOfMIDlets"); if (numberOfMidlets <= 0) { numberOfMidlets = countMIDlets(); } return numberOfMidlets; } /** * Gets the Push interrupt question the should be used when * interrupting this suite. * <p> * The question will have %2 where this suite name should be and * a %1 where the current suite name should be. * * @return push interrupt question */ private int getPushInterruptQuestion() { return ResourceConstants.AMS_MIDLETSUITEIMPL_PUSH_INTERRUPT_QUESTION; } /** * Gets the installation information of this suite. * * @return installation information */ public InstallInfo getInstallInfo() { guaranteeMIDletSuiteLocked("getInstallInfo"); return installInfo; } /** * Gets the Alarm interrupt question the should be used when * interrupting this suite. * <p> * The question will have %2 where this suite name should be and * a %1 where the current suite name should be. * * @return alarm interrupt question */ private int getAlarmInterruptQuestion() { return ResourceConstants.AMS_MIDLETSUITEIMPL_PUSH_INTERRUPT_QUESTION; } /** * Gets the suite name for interruption purposes. * * @return name for interrupt question */ private String getSuiteNameForInterrupt() { return getProperty(SUITE_NAME_PROP); } /** * Counts the number of MIDlets from its properties. * * @return number of midlet in the suite */ private int countMIDlets() { String temp; MIDletInfo midletInfo; int i; temp = getProperty("MIDlet-1"); if (temp == null) { return 0; } /* To save time starting up, cache the first MIDlet entry. */ midletInfo = new MIDletInfo(temp); midlet_1_name = midletInfo.name; midlet_1_class = midletInfo.classname; for (i = 2; getProperty("MIDlet-" + i) != null; i++); return i - 1; } /** * 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} */ public byte getPushInterruptSetting() { guaranteeMIDletSuiteLocked("getPushInterruptSetting"); return suiteSettings.getPushInterruptSetting(); } /** * Gets push options for this suite. * * @return push options are defined in {@link PushRegistryImpl} */ public int getPushOptions() { guaranteeMIDletSuiteLocked("getPushOptions"); return suiteSettings.getPushOptions(); } /** * Gets list of permissions for this suite. * * @return array of permissions from {@link Permissions} */ public byte[] getPermissions() { guaranteeMIDletSuiteLocked("getPermissions"); return suiteSettings.getPermissions(); } /** * Returns a reference to the singleton MIDlet suite storage object. * * @return the storage reference * * @exception SecurityException if the caller does not have permission * to install software */ private MIDletSuiteStorage getMIDletSuiteStorage() throws SecurityException { if (midletSuiteStorage == null) { midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage(classSecurityToken); } return midletSuiteStorage; } /** * Gets the security handler. Creates one on the first call. * * @return handler for security */ private SecurityHandler getSecurityHandler() { if (securityHandler == null) { securityHandler = new SecurityHandler(classSecurityToken, suiteSettings.getPermissions(), getSecurityDomain()); } return securityHandler; } /** * Gets the security domain. Reads it if needed. * * @return name of security domain */ private String getSecurityDomain() { return installInfo.getSecurityDomain(); } /** * Unlocks the MIDletSuite. * */ public void close() { if (locked) { unlockMIDletSuite(id); locked = false; } } /** * Native finalizer * */// #ifdef ENABLE_CDC protected native void finalize();// #else private native void finalize();// #endif /** * Unlocks the MIDletSuite. * * @param suiteId the name of the MIDletSuite */ private static native void unlockMIDletSuite(int suiteId); /** * Locks the MIDletSuite. * * @param suiteId the name of the MIDletSuite * @param isUpdate true if the suite is being updated * * @exception MIDletSuiteLockedException is thrown, if the MIDletSuite is * locked */ static native void lockMIDletSuite(int suiteId, boolean isUpdate) throws MIDletSuiteLockedException; /** * Guarantees the the MIDletSuite is locked. * * @param s the error message to print out. * * @exception IllegalStateException is thrown if the MIDletSuite * is not locked. */ private void guaranteeMIDletSuiteLocked(String s) { if (!locked) { throw new IllegalStateException(s); } } /** * Check that suite classes were verified during installation, and * hash value of the suite hasn't changed since installation * * @return true if suite has verified classes, false otherwise */ public boolean isVerified() { boolean res = false; final byte[] verifyHash = installInfo.getVerifyHash(); if (verifyHash != null) { if (!Constants.VERIFY_SUITE_HASH) { res = true; } else { try { String jarPath = getMIDletSuiteStorage(). getMidletSuiteJarPath(id); if (MIDletSuiteVerifier.checkJarHash( jarPath, verifyHash)) { res = true; } } catch (Exception e) { /** * Any exception caught here means that we can't * guarantee the suite classes are verified, so do * nothing and just return false value by default. */ } } } return res; } /** * 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 */ public boolean isEnabled() { return suiteSettings.isEnabled(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?