build
修订版 | af82f810a55ac830fa8608ceaa676269994999e7 (tree) |
---|---|
时间 | 2011-03-24 19:15:44 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
Merge remote-tracking branch 'korg/froyo' into HEAD
@@ -220,10 +220,12 @@ class SignApk { | ||
220 | 220 | /** Write to another stream and also feed it to the Signature object. */ |
221 | 221 | private static class SignatureOutputStream extends FilterOutputStream { |
222 | 222 | private Signature mSignature; |
223 | + private int mCount; | |
223 | 224 | |
224 | 225 | public SignatureOutputStream(OutputStream out, Signature sig) { |
225 | 226 | super(out); |
226 | 227 | mSignature = sig; |
228 | + mCount = 0; | |
227 | 229 | } |
228 | 230 | |
229 | 231 | @Override |
@@ -234,6 +236,7 @@ class SignApk { | ||
234 | 236 | throw new IOException("SignatureException: " + e); |
235 | 237 | } |
236 | 238 | super.write(b); |
239 | + mCount++; | |
237 | 240 | } |
238 | 241 | |
239 | 242 | @Override |
@@ -244,11 +247,16 @@ class SignApk { | ||
244 | 247 | throw new IOException("SignatureException: " + e); |
245 | 248 | } |
246 | 249 | super.write(b, off, len); |
250 | + mCount += len; | |
251 | + } | |
252 | + | |
253 | + public int size() { | |
254 | + return mCount; | |
247 | 255 | } |
248 | 256 | } |
249 | 257 | |
250 | 258 | /** Write a .SF file with a digest of the specified manifest. */ |
251 | - private static void writeSignatureFile(Manifest manifest, OutputStream out) | |
259 | + private static void writeSignatureFile(Manifest manifest, SignatureOutputStream out) | |
252 | 260 | throws IOException, GeneralSecurityException { |
253 | 261 | Manifest sf = new Manifest(); |
254 | 262 | Attributes main = sf.getMainAttributes(); |
@@ -282,6 +290,15 @@ class SignApk { | ||
282 | 290 | } |
283 | 291 | |
284 | 292 | sf.write(out); |
293 | + | |
294 | + // A bug in the java.util.jar implementation of Android platforms | |
295 | + // up to version 1.6 will cause a spurious IOException to be thrown | |
296 | + // if the length of the signature file is a multiple of 1024 bytes. | |
297 | + // As a workaround, add an extra CRLF in this case. | |
298 | + if ((out.size() % 1024) == 0) { | |
299 | + out.write('\r'); | |
300 | + out.write('\n'); | |
301 | + } | |
285 | 302 | } |
286 | 303 | |
287 | 304 | /** Write a .RSA file with a digital signature. */ |