Merge \"Faster and cleaner way to obtain UTF-8 encoded form.\"
am: 98b4f07dfc
Change-Id: Ic5e071d01ea0fd9a091097e3659f16c0b71f5ae6
This commit is contained in:
commit
5e8b2c9207
5 changed files with 10 additions and 15 deletions
|
@ -16,7 +16,7 @@
|
|||
|
||||
package com.android.apksigner.core.internal.jar;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -220,11 +220,7 @@ public class ManifestParser {
|
|||
if (lineLengthBytes == 0) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return new String(mManifest, startOffset, lineLengthBytes, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("UTF-8 character encoding not supported", e);
|
||||
}
|
||||
return new String(mManifest, startOffset, lineLengthBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.android.apksigner.core.internal.jar;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
@ -81,7 +82,7 @@ public abstract class ManifestWriter {
|
|||
}
|
||||
|
||||
private static void writeLine(OutputStream out, String line) throws IOException {
|
||||
byte[] lineBytes = line.getBytes("UTF-8");
|
||||
byte[] lineBytes = line.getBytes(StandardCharsets.UTF_8);
|
||||
int offset = 0;
|
||||
int remaining = lineBytes.length;
|
||||
boolean firstLine = true;
|
||||
|
|
|
@ -18,9 +18,9 @@ package com.android.apksigner.core.internal.zip;
|
|||
|
||||
import com.android.apksigner.core.zip.ZipFormatException;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
|
@ -168,11 +168,7 @@ public class CentralDirectoryRecord {
|
|||
record.position(originalPosition);
|
||||
}
|
||||
}
|
||||
try {
|
||||
return new String(nameBytes, nameBytesOffset, nameLengthBytes, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("UTF-8 character encoding not supported", e);
|
||||
}
|
||||
return new String(nameBytes, nameBytesOffset, nameLengthBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private static class ByLocalFileHeaderOffsetComparator
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
|
@ -93,7 +94,7 @@ public class LocalFileHeader {
|
|||
// exhibited when reading an APK for the purposes of verifying its signatures.
|
||||
|
||||
String entryName = cdRecord.getName();
|
||||
byte[] cdNameBytes = entryName.getBytes("UTF-8");
|
||||
byte[] cdNameBytes = entryName.getBytes(StandardCharsets.UTF_8);
|
||||
int headerSizeWithName = HEADER_SIZE_BYTES + cdNameBytes.length;
|
||||
long localFileHeaderOffsetInArchive = cdRecord.getLocalFileHeaderOffset();
|
||||
long headerEndInArchive = localFileHeaderOffsetInArchive + headerSizeWithName;
|
||||
|
|
|
@ -57,6 +57,7 @@ import java.io.OutputStream;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.Key;
|
||||
import java.security.KeyFactory;
|
||||
|
@ -717,7 +718,7 @@ class SignApk {
|
|||
// archive comment, so that tools that display the comment
|
||||
// (hopefully) show something sensible.
|
||||
// TODO: anything more useful we can put in this message?
|
||||
byte[] message = "signed by SignApk".getBytes("UTF-8");
|
||||
byte[] message = "signed by SignApk".getBytes(StandardCharsets.UTF_8);
|
||||
temp.write(message);
|
||||
temp.write(0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue