Example #1
0
 /**
  * Checks for all the permissions that need to be present to open a list
  *
  * @param pimListType CONTACT_LIST, EVENT_LIST or TODO_LIST
  * @param mode READ_ONLY, WRITE_ONLY or READ_WRITE
  * @throws IllegalArgumentException if one of the parameters is out of bounds
  * @throws SecurityException if the application does not have the required permissions
  */
 private void checkPermissions(int pimListType, int mode) {
   int[] permissions = getPermissions(pimListType, mode);
   MIDletSuite suite = Scheduler.getScheduler().getMIDletSuite();
   /*
    * Do a first pass on the permissions to make sure that none is
    * automatically denied. This is for the case when both read permission
    * and write permission are required. It is possible that, for example,
    * read permission is granted only after asking the user, but write
    * permission is automatically denied. In this case, the user should
    * not be asked a question at all.
    */
   for (int i = 0; i < permissions.length; i++) {
     String name = Permissions.getName(permissions[i]);
     int status = suite.checkPermission(name);
     if (status == 0) {
       // throw an exception
       suite.checkIfPermissionAllowed(permissions[i]);
     } else if (status == 1) {
       // don't check this permission again
       permissions[i] = -1;
     }
   }
   for (int i = 0; i < permissions.length; i++) {
     if (permissions[i] != -1) {
       try {
         suite.checkForPermission(permissions[i], null);
       } catch (InterruptedException e) {
         throw new SecurityException("Security check interrupted: " + e.getMessage());
       }
     }
   }
 }
Example #2
0
  /**
   * Queues the last suite to run when there is not a next Suite to run. This value will be
   * persistent until it is used. Not used in MVM mode.
   *
   * @param id ID of an installed suite
   * @param midlet class name of MIDlet to invoke
   * @exception SecurityException if the caller does not have permission to manage midlets
   */
  public static void setLastSuiteToRun(int id, String midlet, String arg0, String arg1) {

    MIDletSuite midletSuite = MIDletStateHandler.getMidletStateHandler().getMIDletSuite();

    // if a MIDlet suite is not scheduled, assume the JAM is calling.
    if (midletSuite != null) {
      midletSuite.checkIfPermissionAllowed(Permissions.AMS);
    }

    lastMidletSuiteToRun = id;
    lastMidletToRun = midlet;
    arg0ForLastMidlet = arg0;
    arg1ForLastMidlet = arg1;
  }
  /**
   * Adds a property to the suite.
   *
   * @param key the name of the property
   * @param value the value of the property
   * @exception SecurityException if the calling suite does not have internal API permission
   */
  public void addProperty(String key, String value) {
    MIDletSuite current = Scheduler.getScheduler().getMIDletSuite();

    if (current != null) {
      current.checkIfPermissionAllowed(Permissions.MIDP);
    }

    if (bufferedJadProps != null) {
      bufferedJadProps.addProperty(key, value);
      return;
    }

    bufferedJarProps.addProperty(key, value);
  }