예제 #1
0
 /**
  * Selects application uid from Nokia-MIDlet-UID attribute.
  *
  * @return uid if attribute specifies it, null otherwise.
  * @throws InstallerException if attribute exists and is not valid or specified uid is already in
  *     use.
  */
 private Uid selectAppUidFromAttribute(InstallBall aBall, int aIndex) {
   Uid uid = null;
   String appUidAttrName = MIDLET_UID_ATTR_NAME + aIndex;
   String appUidAttrValue = aBall.getAttributeValue(appUidAttrName);
   if (appUidAttrValue != null) {
     uid = PlatformUid.createUid(appUidAttrValue);
     if (uid == null) {
       Log.logError("Invalid " + appUidAttrName + " attribute value: " + appUidAttrValue);
       throw new InvalidAttributeException(
           InstallerErrorMessage.INST_CORRUPT_PKG,
           null,
           InstallerDetailedErrorMessage.ATTR_BAD_SYNTAX,
           new String[] {appUidAttrName},
           (aBall.attributeExistsInJad(appUidAttrName)
               ? OtaStatusCode.INVALID_DESCRIPTOR
               : OtaStatusCode.INVALID_JAR));
     }
     boolean uidInJad = aBall.attributeExistsInJad(appUidAttrName);
     // If jar file is not yet present, assume that uid
     // will be present in jar.
     boolean uidInJar = true;
     if (aBall.iJarFilename != null) {
       uidInJar = aBall.attributeExistsInJar(appUidAttrName);
     }
     if (uidInJar && !uidInJad && aBall.iJadAttributes != null) {
       // If Uid is specified in jar but not in jad
       // it must be ignored. Getting applications
       // through Java Verified process requires
       // that applications using protected Uids
       // can be installed as untrusted (without jad).
       Log.logWarning(appUidAttrName + " attribute present in jar but not in jad, ignoring it");
       uid = null;
     }
     if (uid != null) {
       // Check that uid is valid.
       PlatformUid.checkValidity(
           appUidAttrName, uid, aBall.iSuite.isTrusted(), uidInJad, uidInJar);
       // Check that uid is not already in use.
       if (appUidInUse(uid, aBall) || appUidInUse(uid, aBall.iSuite)) {
         Log.logError("Uid " + uid + " is already in use");
         throw new InvalidAttributeException(
             InstallerErrorMessage.INST_CORRUPT_PKG,
             null,
             InstallerDetailedErrorMessage.ATTR_HANDLING_FAILED,
             new String[] {appUidAttrName},
             (aBall.attributeExistsInJad(appUidAttrName)
                 ? OtaStatusCode.INVALID_DESCRIPTOR
                 : OtaStatusCode.INVALID_JAR));
       }
     }
     aBall.log("Selected app uid from " + appUidAttrName + " attribute: " + uid);
   }
   return uid;
 }
예제 #2
0
 /** Reads a Uid from specified InputStream. */
 private static Uid readUid(InputStream aInputStream) throws IOException {
   int uid = 0;
   for (int i = 0; i < 4; i++) {
     uid |= (aInputStream.read() << i * 8);
   }
   return PlatformUid.createUid(uid);
 }