aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdklib
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-03-27 13:54:59 -0700
committerXavier Ducrohet <xav@android.com>2012-03-27 15:16:24 -0700
commit1cb06d5bc82268dc5c684aa2ee7415175ce14c7e (patch)
treedf7ed53748bb272a0eed93dfcc0661bbb1dc9d61 /sdkmanager/libs/sdklib
parent9b20bc00147114cba4746ce63bee529f5ca6c69e (diff)
downloadsdk-1cb06d5bc82268dc5c684aa2ee7415175ce14c7e.zip
sdk-1cb06d5bc82268dc5c684aa2ee7415175ce14c7e.tar.gz
sdk-1cb06d5bc82268dc5c684aa2ee7415175ce14c7e.tar.bz2
Use our own signing code in Ant and don't rely on Jarsigner.
JDK7 changes the default signing algorithm and breaks release builds where the ant script does the signing after building the apk. This changes the Ant script to use a custom task that uses the same code that is already used to sign debug apps. Change-Id: I0df7378a7a59b54ef6a17db363a2127736f4434e
Diffstat (limited to 'sdkmanager/libs/sdklib')
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java12
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/DebugKeyProvider.java12
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java15
3 files changed, 37 insertions, 2 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java
index 3c749c4..765ec3c 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/build/ApkBuilder.java
@@ -456,8 +456,10 @@ public final class ApkBuilder implements IArchiveBuilder {
}
} catch (ApkCreationException e) {
+ mBuilder.cleanUp();
throw e;
} catch (Exception e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e);
}
}
@@ -498,8 +500,10 @@ public final class ApkBuilder implements IArchiveBuilder {
try {
doAddFile(file, archivePath);
} catch (DuplicateFileException e) {
+ mBuilder.cleanUp();
throw e;
} catch (Exception e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", file);
}
}
@@ -529,8 +533,10 @@ public final class ApkBuilder implements IArchiveBuilder {
FileInputStream fis = new FileInputStream(zipFile);
mBuilder.writeZip(fis, mNullFilter);
} catch (DuplicateFileException e) {
+ mBuilder.cleanUp();
throw e;
} catch (Exception e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", zipFile);
}
}
@@ -566,8 +572,10 @@ public final class ApkBuilder implements IArchiveBuilder {
// constitutes an error or warning depending on if they are in lib/
return new JarStatusImpl(mFilter.getNativeLibs(), mFilter.getNativeLibsConflict());
} catch (DuplicateFileException e) {
+ mBuilder.cleanUp();
throw e;
} catch (Exception e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", jarFile);
}
}
@@ -676,6 +684,7 @@ public final class ApkBuilder implements IArchiveBuilder {
try {
doAddFile(lib, path);
} catch (IOException e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", lib);
}
}
@@ -696,6 +705,7 @@ public final class ApkBuilder implements IArchiveBuilder {
try {
doAddFile(entry.mFile, entry.mPath);
} catch (IOException e) {
+ mBuilder.cleanUp();
throw new ApkCreationException(e, "Failed to add %s", entry.mFile);
}
}
@@ -775,6 +785,8 @@ public final class ApkBuilder implements IArchiveBuilder {
mIsSealed = true;
} catch (Exception e) {
throw new ApkCreationException(e, "Failed to seal APK");
+ } finally {
+ mBuilder.cleanUp();
}
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/DebugKeyProvider.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/DebugKeyProvider.java
index 1b090b9..4f4af36 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/DebugKeyProvider.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/DebugKeyProvider.java
@@ -163,16 +163,24 @@ public class DebugKeyProvider {
private boolean loadKeyEntry(String osKeyStorePath, String storeType) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException,
UnrecoverableEntryException {
+ FileInputStream fis = null;
try {
KeyStore keyStore = KeyStore.getInstance(
storeType != null ? storeType : KeyStore.getDefaultType());
- FileInputStream fis = new FileInputStream(osKeyStorePath);
+ fis = new FileInputStream(osKeyStorePath);
keyStore.load(fis, PASSWORD_CHAR);
- fis.close();
mEntry = (KeyStore.PrivateKeyEntry)keyStore.getEntry(
DEBUG_ALIAS, new KeyStore.PasswordProtection(PASSWORD_CHAR));
} catch (FileNotFoundException e) {
return false;
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // pass
+ }
+ }
}
return true;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java
index d7a5897..48f1b91 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/build/SignedJarBuilder.java
@@ -268,6 +268,21 @@ public class SignedJarBuilder {
}
mOutputJar.close();
+ mOutputJar = null;
+ }
+
+ /**
+ * Clean up of the builder for interrupted workflow.
+ * This does nothing if {@link #close()} was called successfully.
+ */
+ public void cleanUp() {
+ if (mOutputJar != null) {
+ try {
+ mOutputJar.close();
+ } catch (IOException e) {
+ // pass
+ }
+ }
}
/**