Messaging: Use StandardCharsets where possible
Change-Id: I45a19c47262116d34260e1957145580a7f97168e
This commit is contained in:
@@ -51,14 +51,14 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ImageUtils {
|
||||
private static final String TAG = LogUtil.BUGLE_TAG;
|
||||
private static final int MAX_OOM_COUNT = 1;
|
||||
private static final byte[] GIF87_HEADER = "GIF87a".getBytes(Charset.forName("US-ASCII"));
|
||||
private static final byte[] GIF89_HEADER = "GIF89a".getBytes(Charset.forName("US-ASCII"));
|
||||
private static final byte[] GIF87_HEADER = "GIF87a".getBytes(StandardCharsets.US_ASCII);
|
||||
private static final byte[] GIF89_HEADER = "GIF89a".getBytes(StandardCharsets.US_ASCII);
|
||||
|
||||
// Used for drawBitmapWithCircleOnCanvas.
|
||||
// Default color is transparent for both circle background and stroke.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +24,7 @@ import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
class CountedDataInputStream extends FilterInputStream {
|
||||
|
||||
@@ -129,7 +131,7 @@ class CountedDataInputStream extends FilterInputStream {
|
||||
public String readString(int n) throws IOException {
|
||||
byte buf[] = new byte[n];
|
||||
readOrThrow(buf);
|
||||
return new String(buf, "UTF8");
|
||||
return new String(buf, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public String readString(int n, Charset charset) throws IOException {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +22,7 @@ import com.android.messaging.util.LogUtil;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -235,11 +237,11 @@ class ExifData {
|
||||
|
||||
try {
|
||||
if (Arrays.equals(code, USER_COMMENT_ASCII)) {
|
||||
return new String(buf, 8, buf.length - 8, "US-ASCII");
|
||||
return new String(buf, 8, buf.length - 8, StandardCharsets.US_ASCII);
|
||||
} else if (Arrays.equals(code, USER_COMMENT_JIS)) {
|
||||
return new String(buf, 8, buf.length - 8, "EUC-JP");
|
||||
} else if (Arrays.equals(code, USER_COMMENT_UNICODE)) {
|
||||
return new String(buf, 8, buf.length - 8, "UTF-16");
|
||||
return new String(buf, 8, buf.length - 8, StandardCharsets.UTF_16);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -141,7 +142,7 @@ public class ExifParser {
|
||||
protected static final int TAG_SIZE = 12;
|
||||
protected static final int OFFSET_SIZE = 2;
|
||||
|
||||
private static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
private static final Charset US_ASCII = StandardCharsets.US_ASCII;
|
||||
|
||||
protected static final int DEFAULT_IFD0_OFFSET = 8;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.android.messaging.util.exif;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -70,7 +71,7 @@ public class ExifTag {
|
||||
*/
|
||||
public static final short TYPE_RATIONAL = 10;
|
||||
|
||||
private static final Charset US_ASCII = Charset.forName("US-ASCII");
|
||||
private static final Charset US_ASCII = StandardCharsets.US_ASCII;
|
||||
private static final int TYPE_TO_SIZE_MAP[] = new int[11];
|
||||
private static final int UNSIGNED_SHORT_MAX = 65535;
|
||||
private static final long UNSIGNED_LONG_MAX = 4294967295L;
|
||||
|
||||
Reference in New Issue
Block a user