This commit is contained in:
GH Action - Upstream Sync 2023-06-01 12:32:49 +00:00
commit 555e03ddf5
3 changed files with 5 additions and 8 deletions

View File

@ -12,6 +12,7 @@ android {
targetSdk 28 targetSdk 28
ndk { abiFilters "armeabi-v7a" } ndk { abiFilters "armeabi-v7a" }
buildConfigField("String", "CLIENT_ID", "\"${clientId}\"") buildConfigField("String", "CLIENT_ID", "\"${clientId}\"")
multiDexEnabled true
} }
buildTypes { buildTypes {

View File

@ -460,7 +460,7 @@ public class API {
public Object[] proxySub(Map<String, String> params) throws Exception { public Object[] proxySub(Map<String, String> params) throws Exception {
String fileId = params.get("file_id"); String fileId = params.get("file_id");
Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth()); Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth());
byte[] body = Utils.getUTF8(res.body().bytes()); byte[] body = Utils.toUtf8(res.body().bytes());
Object[] result = new Object[3]; Object[] result = new Object[3];
result[0] = 200; result[0] = 200;
result[1] = "application/octet-stream"; result[1] = "application/octet-stream";

View File

@ -49,19 +49,15 @@ public class Utils {
return hasCamera && hasPhone && hasBT; return hasCamera && hasPhone && hasBT;
} }
public static boolean isGBK(byte[] bytes) { public static boolean isGbk(byte[] bytes) {
Charset charset = Charset.forName("GBK"); Charset charset = Charset.forName("GBK");
String str = new String(bytes, charset); String str = new String(bytes, charset);
byte[] newBytes = str.getBytes(charset); byte[] newBytes = str.getBytes(charset);
return Arrays.equals(bytes, newBytes); return Arrays.equals(bytes, newBytes);
} }
public static byte[] getUTF8(byte[] bytes) throws Exception { public static byte[] toUtf8(byte[] bytes) throws Exception {
if (isGBK(bytes)) { return isGbk(bytes) ? new String(bytes, Charset.forName("GBK")).getBytes("UTF-8") : bytes;
return new String(bytes, Charset.forName("GBK")).getBytes("UTF-8");
} else {
return bytes;
}
} }
public static boolean isSub(String ext) { public static boolean isSub(String ext) {