fix: StandardCharsets.UTF_8 替换为 Charset.forName("UTF-8")
Android 4.2(API 17)不支持 java.nio.charset.StandardCharsets(API 19+), 5 个文件统一改用兼容 API 1 的 String 重载: - DeviceIdentityProvider / HMacShaUtils / Md5Utils: Charset.forName - UrlParamBuilder: URLEncoder.encode(str, "UTF-8") - ContentDetailUtils: 删除未使用的 import
This commit is contained in:
@@ -9,7 +9,7 @@ import com.pukka.jiecheng.config.AppConfiguration;
|
|||||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||||
import com.pukka.libcore.utils.LogUtils;
|
import com.pukka.libcore.utils.LogUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.Charset;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class DeviceIdentityProvider {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
byte[] hashBytes = digest.digest(source.getBytes(Charset.forName("UTF-8")));
|
||||||
int usedBytes = Math.min(MD5_TRUNCATED_BYTES, hashBytes.length);
|
int usedBytes = Math.min(MD5_TRUNCATED_BYTES, hashBytes.length);
|
||||||
if (usedBytes <= 0) {
|
if (usedBytes <= 0) {
|
||||||
return "";
|
return "";
|
||||||
@@ -112,7 +112,7 @@ public class DeviceIdentityProvider {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
byte[] hashBytes = digest.digest(source.getBytes(Charset.forName("UTF-8")));
|
||||||
StringBuilder hexBuilder = new StringBuilder(hashBytes.length * 2);
|
StringBuilder hexBuilder = new StringBuilder(hashBytes.length * 2);
|
||||||
for (byte hashByte : hashBytes) {
|
for (byte hashByte : hashBytes) {
|
||||||
hexBuilder.append(String.format(Locale.ROOT, "%02X", hashByte));
|
hexBuilder.append(String.format(Locale.ROOT, "%02X", hashByte));
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.pukka.jiecheng.utils;
|
package com.pukka.jiecheng.utils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class UrlParamBuilder {
|
public class UrlParamBuilder {
|
||||||
|
|
||||||
@@ -60,9 +60,15 @@ public class UrlParamBuilder {
|
|||||||
urlBuilder.append("&");
|
urlBuilder.append("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
urlBuilder.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8))
|
try {
|
||||||
|
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
|
||||||
.append("=")
|
.append("=")
|
||||||
.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8));
|
.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
urlBuilder.append(entry.getKey())
|
||||||
|
.append("=")
|
||||||
|
.append(entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.pukka.jiecheng.R;
|
|||||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||||
import com.pukka.libcore.utils.LogUtils;
|
import com.pukka.libcore.utils.LogUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|||||||
11
day.code-workspace
Normal file
11
day.code-workspace
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "../../Desktop/tv.huashi.jetsenx.jetsenfilx.jsttvday/day"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.pukka.libcore.cipher;
|
package com.pukka.libcore.cipher;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.Charset;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ public class HMacShaUtils {
|
|||||||
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA256_ALGORITHM);
|
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA256_ALGORITHM);
|
||||||
Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM);
|
Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM);
|
||||||
mac.init(signingKey);
|
mac.init(signingKey);
|
||||||
return mac.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
return mac.doFinal(data.getBytes(Charset.forName("UTF-8")));
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InvalidKeyException e) {
|
} catch (InvalidKeyException e) {
|
||||||
@@ -51,7 +51,7 @@ public class HMacShaUtils {
|
|||||||
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
|
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
|
||||||
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
|
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
|
||||||
mac.init(signingKey);
|
mac.init(signingKey);
|
||||||
return mac.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
return mac.doFinal(data.getBytes(Charset.forName("UTF-8")));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.pukka.libcore.cipher;
|
|||||||
|
|
||||||
import com.pukka.libcore.utils.ByteConversionUtils;
|
import com.pukka.libcore.utils.ByteConversionUtils;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.Charset;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +61,7 @@ public class Md5Utils {
|
|||||||
public static String encrypt(String message) {
|
public static String encrypt(String message) {
|
||||||
String md5str = "";
|
String md5str = "";
|
||||||
try {
|
try {
|
||||||
md5str = encrypt(message.getBytes(StandardCharsets.UTF_8));
|
md5str = encrypt(message.getBytes(Charset.forName("UTF-8")));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user