Skip to content

Commit

Permalink
chore: supress warning about StandardCharsets.UTF_8
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Jul 22, 2024
1 parent 2f6b108 commit 705087e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sdk/src/main/java/com/hcaptcha/sdk/HCaptchaDebugInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
final class HCaptchaDebugInfo implements Serializable {
public static final String JS_INTERFACE_TAG = "JSDI";
private static final String GET_PROP_BIN = "/system/bin/getprop";
@SuppressWarnings("java:S4719") // minSdkVersion is 16 and StandardCharsets.UTF_8 is available from 19
private static final String CHARSET_NAME = "UTF-8";

private static final int MAX_ENTRIES = 512;

private static String sDebugInfo = "[]";
private static String sSysDebug;

@NonNull
private final Context context;
private final transient Context context;

@JavascriptInterface
public String getDebugInfo() {
Expand Down Expand Up @@ -87,12 +90,13 @@ public String getSysDebug() {

List<String> debugInfo(String packageName, String packageCode)
throws IOException, NoSuchAlgorithmException {
final List<String> result = new ArrayList<>(512);
final List<String> result = new ArrayList<>(8);
final MessageDigest androidMd5 = MessageDigest.getInstance("MD5");
final MessageDigest appMd5 = MessageDigest.getInstance("MD5");
final MessageDigest depsMd5 = MessageDigest.getInstance("MD5");
final DexFile dexFile = new DexFile(packageCode);
try {
int entryCount = 0;
final Enumeration<String> classes = dexFile.entries();
while (classes.hasMoreElements()) {
final String cls = classes.nextElement();
Expand All @@ -103,6 +107,10 @@ List<String> debugInfo(String packageName, String packageCode)
} else {
depsMd5.update(cls.getBytes(CHARSET_NAME));
}

if (++entryCount > MAX_ENTRIES) {
break;
}
}
} finally {
dexFile.close();
Expand Down

0 comments on commit 705087e

Please sign in to comment.