diff options
Diffstat (limited to 'third_party/java')
-rw-r--r-- | third_party/java/apkbuilder/java/com/android/sdklib/build/ApkBuilder.java | 28 | ||||
-rw-r--r-- | third_party/java/apkbuilder/java/com/android/sdklib/internal/build/SignedJarBuilder.java | 23 |
2 files changed, 31 insertions, 20 deletions
diff --git a/third_party/java/apkbuilder/java/com/android/sdklib/build/ApkBuilder.java b/third_party/java/apkbuilder/java/com/android/sdklib/build/ApkBuilder.java index dd3d8f440b..0179b0bb55 100644 --- a/third_party/java/apkbuilder/java/com/android/sdklib/build/ApkBuilder.java +++ b/third_party/java/apkbuilder/java/com/android/sdklib/build/ApkBuilder.java @@ -22,7 +22,6 @@ import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput; import com.android.sdklib.internal.build.DebugKeyProvider.KeytoolException; import com.android.sdklib.internal.build.SignedJarBuilder; import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -68,6 +67,9 @@ public final class ApkBuilder implements IArchiveBuilder { @Override public boolean checkEntry(String archivePath) throws ZipAbortException { verbosePrintln("=> %s", archivePath); + if ("META-INF".equals(archivePath)) { + return false; + } File duplicate = checkFileForDuplicate(archivePath); if (duplicate != null) { @@ -106,7 +108,14 @@ public final class ApkBuilder implements IArchiveBuilder { // Folders like CVS, .svn, etc.. should already have been excluded from the // jar file, but we need to exclude some other folder (like /META-INF) so // we check anyway. - for (int i = 0 ; i < segments.length - 1; i++) { + for (int i = 0; i < segments.length - 1; i++) { + String nextSegment = i + 1 < segments.length ? segments[i + 1] : null; + // allow an exception only for contents of a leading META-INF/services + if (i == 0 + && "META-INF".equalsIgnoreCase(segments[i]) + && "services".equalsIgnoreCase(nextSegment)) { + continue; + } if (!checkFolderForPackaging(segments[i])) { return false; } @@ -832,7 +841,7 @@ public final class ApkBuilder implements IArchiveBuilder { * * @param file the {@link File} to process. * @param path the relative path of this file to the source folder. - * Can be <code>null</code> to identify a root file. + * Can be <code>null</code> to identify a root file. * @throws IOException * @throws DuplicateFileException if a file conflicts with another already added * to the APK at the same location inside the APK archive. @@ -840,8 +849,12 @@ public final class ApkBuilder implements IArchiveBuilder { * @throws ApkCreationException if an error occurred */ private static void processFileForResource(IArchiveBuilder builder, File file, String path) - throws IOException, DuplicateFileException, ApkCreationException, SealedApkException { + throws IOException, DuplicateFileException, ApkCreationException, SealedApkException { if (file.isDirectory()) { + if ("META-INF".equalsIgnoreCase(file.getName())) { + return; + } + // a directory? we check it if (checkFolderForPackaging(file.getName())) { // if it's valid, we append its name to the current path. @@ -949,8 +962,9 @@ public final class ApkBuilder implements IArchiveBuilder { } /** - * Checks whether a folder and its content is valid for packaging into the .apk as - * standard Java resource. + * Checks whether a folder and its content is valid for packaging into the .apk as standard Java + * resource. + * * @param folderName the name of the folder. */ public static boolean checkFolderForPackaging(String folderName) { @@ -984,7 +998,7 @@ public final class ApkBuilder implements IArchiveBuilder { */ public static boolean checkFileForPackaging(String fileName, String extension) { // ignore hidden files and backup files - if (fileName.charAt(0) == '.' || fileName.charAt(fileName.length()-1) == '~') { + if (fileName.charAt(0) == '.' || fileName.charAt(fileName.length() - 1) == '~') { return false; } diff --git a/third_party/java/apkbuilder/java/com/android/sdklib/internal/build/SignedJarBuilder.java b/third_party/java/apkbuilder/java/com/android/sdklib/internal/build/SignedJarBuilder.java index afb7e658fc..47edf08bcc 100644 --- a/third_party/java/apkbuilder/java/com/android/sdklib/internal/build/SignedJarBuilder.java +++ b/third_party/java/apkbuilder/java/com/android/sdklib/internal/build/SignedJarBuilder.java @@ -18,14 +18,6 @@ package com.android.sdklib.internal.build; import com.android.SdkConstants; import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter.ZipAbortException; - -import sun.misc.BASE64Encoder; -import sun.security.pkcs.ContentInfo; -import sun.security.pkcs.PKCS7; -import sun.security.pkcs.SignerInfo; -import sun.security.x509.AlgorithmId; -import sun.security.x509.X500Name; - import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -51,10 +43,16 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import sun.misc.BASE64Encoder; +import sun.security.pkcs.ContentInfo; +import sun.security.pkcs.PKCS7; +import sun.security.pkcs.SignerInfo; +import sun.security.x509.AlgorithmId; +import sun.security.x509.X500Name; /** * A Jar file builder with signature support. - * + * * @deprecated Use Android-Builder instead */ @Deprecated @@ -221,13 +219,12 @@ public class SignedJarBuilder { while ((entry = zis.getNextEntry()) != null) { String name = entry.getName(); - // do not take directories or anything inside a potential META-INF folder. - if (entry.isDirectory() || name.startsWith("META-INF/")) { + // do not take directories + if (entry.isDirectory()) { continue; } - // if we have a filter, we check the entry against it - if (filter != null && filter.checkEntry(name) == false) { + if (filter != null && !filter.checkEntry(name)) { continue; } |