示例#1
0
  /**
   * Starts a MIDlet in a new Isolate or queues the execution of the named Application suite to run.
   * The current application suite should terminate itself normally to make resources available to
   * the new application suite. Only one package and set of MIDlets can be queued in this manner. If
   * multiple calls to execute are made, the package and MIDlets specified during the <em>last</em>
   * invocation will be executed when the current application is terminated.
   *
   * @param securityToken security token of the calling class
   * @param externalAppId ID of MIDlet to invoke, given by an external application manager
   * @param suiteId ID of an installed suite
   * @param midlet class name of MIDlet to invoke
   * @param displayName name to display to the user
   * @param arg0 if not null, this parameter will be available to the MIDlet as application property
   *     arg-0
   * @param arg1 if not null, this parameter will be available to the MIDlet as application property
   *     arg-1
   * @param arg2 if not null, this parameter will be available to the MIDlet as application property
   *     arg-2
   * @param memoryReserved the minimum amount of memory guaranteed to be available to the isolate at
   *     any time; &lt; 0 if not used
   * @param memoryTotal the total amount of memory that the isolate can reserve; &lt; 0 if not used
   * @param priority priority to set for the new isolate; &lt;= 0 if not used
   * @param profileName name of the profile to set for the new isolate; null if not used
   * @return true if the MIDlet suite MUST first exit before the MIDlet is run
   * @exception SecurityException if the caller does not have permission to manage midlets
   */
  public static boolean executeWithArgs(
      SecurityToken securityToken,
      int externalAppId,
      int suiteId,
      String midlet,
      String displayName,
      String arg0,
      String arg1,
      String arg2,
      int memoryReserved,
      int memoryTotal,
      int priority,
      String profileName) {

    MIDletSuiteStorage midletSuiteStorage;

    // Note: getMIDletSuiteStorage performs an AMS permission check.
    if (securityToken != null) {
      midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage(securityToken);
    } else {
      midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage();
    }

    return AmsUtil.executeWithArgs(
        midletSuiteStorage,
        externalAppId,
        suiteId,
        midlet,
        displayName,
        arg0,
        arg1,
        arg2,
        memoryReserved,
        memoryTotal,
        priority,
        profileName);
  }
  /**
   * Creates MIDlet suite instance by suite ID
   *
   * @return MIDlet suite to load
   * @throws Exception in the case MIDlet suite can not be created because of a security reasons or
   *     some problems related to suite storage
   */
  protected MIDletSuite createMIDletSuite() throws Exception {
    MIDletSuiteStorage storage;
    MIDletSuite suite = null;

    storage = MIDletSuiteStorage.getMIDletSuiteStorage(internalSecurityToken);

    if (suiteId == MIDletSuite.INTERNAL_SUITE_ID) {
      // assume a class name of a MIDlet in the classpath
      suite = InternalMIDletSuiteImpl.create(storage, midletDisplayName, suiteId);
    } else {
      suite = storage.getMIDletSuite(suiteId, false);
      Logging.initLogSettings(suiteId);
    }

    return suite;
  }
 /**
  * Starts a MIDlet in a new Isolate. Called from the AMS MIDlet suite.
  *
  * @param id ID of an installed suite
  * @param midlet class name of MIDlet to invoke
  * @param displayName name to display to the user
  * @param arg0 if not null, this parameter will be available to the MIDlet as application property
  *     arg-0
  * @param arg1 if not null, this parameter will be available to the MIDlet as application property
  *     arg-1
  * @param arg2 if not null, this parameter will be available to the MIDlet as application property
  *     arg-2
  * @return Isolate that the MIDlet suite was started in
  */
 public static Isolate startMidletInNewIsolate(
     int id, String midlet, String displayName, String arg0, String arg1, String arg2) {
   // Note: getMIDletSuiteStorage performs an AMS permission check
   return startMidletCommon(
       MIDletSuiteStorage.getMIDletSuiteStorage(),
       0,
       id,
       midlet,
       displayName,
       arg0,
       arg1,
       arg2,
       -1,
       -1,
       Isolate.MIN_PRIORITY - 1,
       null,
       Constants.MIDP_NO_DEBUG);
 }
  /** Creates environment objects needed to AMS task */
  protected void createSuiteEnvironment() {
    foregroundController = this;

    lcduiEnvironment =
        new LCDUIEnvironmentForCDC(
            internalSecurityToken, eventQueue, isolateId, foregroundController);
    foregroundEventProducer = new CdcForegroundEventProducer(eventQueue);

    // creates display container, needs foregroundController
    super.createSuiteEnvironment();

    midletStateHandler = MIDletStateHandler.getMidletStateHandler();

    MIDletSuiteStorage mss = MIDletSuiteStorage.getMIDletSuiteStorage(internalSecurityToken);

    midletStateHandler.initMIDletStateHandler(
        internalSecurityToken, this, new CdcMIDletLoader(mss), this);

    MidletSuiteContainer msc = new MidletSuiteContainer(mss);

    RmsEnvironment.init(internalSecurityToken, msc);
  }