version:1.4

update:2021-10-21 10:14:40
fix:
add:增加浏览器桌面检测升级,修复重复请求
This commit is contained in:
2021-12-03 14:33:03 +08:00
parent 768519e14e
commit 34fa9fcdb7
70 changed files with 3189 additions and 1503 deletions

View File

@@ -7,6 +7,7 @@ import android.content.pm.PackageInstaller;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.RequiresApi;
@@ -75,7 +76,7 @@ public class XAPKUtils {
if (file.exists() && file.isFile()) {
upzipXAPK(file);
} else {
Logutils.e(TAG, "installXAPK: " + "File not exists");
Log.e(TAG, "installXAPK: " + "File not exists");
}
}
@@ -118,17 +119,17 @@ public class XAPKUtils {
//获取OBB文件配置
JsonElement split_apks_em = jsonObject.get("split_apks");
readConfig(split_configs_em, expansions_em, split_apks_em);
// Logutils.e(TAG, "installXAPK: " + jsonString);
// Log.e(TAG, "installXAPK: " + jsonString);
}
@Override
public void onError(Throwable e) {
Logutils.e(TAG, "onError: " + e.getMessage());
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Logutils.e(TAG, "onComplete: ");
Log.e(TAG, "onComplete: ");
}
});
}
@@ -140,19 +141,19 @@ public class XAPKUtils {
if (null != split_configs) {
getSplitConfigs(split_configs.getAsJsonArray());
} else {
Logutils.e(TAG, "readConfig: " + "not found split_configs json data");
Log.e(TAG, "readConfig: " + "not found split_configs json data");
}
if (null != expansions) {
readOBBConfig(expansions.getAsJsonArray());
} else {
Logutils.e(TAG, "readConfig: " + "not found expansions json data");
Log.e(TAG, "readConfig: " + "not found expansions json data");
}
if (null != split_apks) {
getSplitApks(split_apks.getAsJsonArray());
} else {
Logutils.e(TAG, "readConfig: " + "not found split_apks json data");
Log.e(TAG, "readConfig: " + "not found split_apks json data");
}
@@ -177,7 +178,7 @@ public class XAPKUtils {
// }
// configStringBuilder.append(config);
// }
// Logutils.e(TAG, "getSplitConfigs: " + configStringBuilder.toString());
// Log.e(TAG, "getSplitConfigs: " + configStringBuilder.toString());
}
/**
@@ -187,7 +188,7 @@ public class XAPKUtils {
*/
private void readOBBConfig(JsonArray jsonArray) {
if (TextUtils.isEmpty(unpackPath)) {
Logutils.e(TAG, "readOBBConfig: " + "unpack directory is empty");
Log.e(TAG, "readOBBConfig: " + "unpack directory is empty");
return;
}
Type type = new TypeToken<List<Expansions>>() {
@@ -197,9 +198,9 @@ public class XAPKUtils {
if (null != expansionsList && expansionsList.size() > 0) {
for (Expansions expansions : expansionsList) {
if (copyObbFile(expansions)) {
Logutils.e(TAG, "readOBBConfig: " + "success");
Log.e(TAG, "readOBBConfig: " + "success");
} else {
Logutils.e(TAG, "readOBBConfig: " + "copy oob File failure");
Log.e(TAG, "readOBBConfig: " + "copy oob File failure");
}
}
}
@@ -214,25 +215,25 @@ public class XAPKUtils {
String install_path = expansions.getInstall_path();
if (TextUtils.isEmpty(file)) {
Logutils.e(TAG, "copyObbFile: " + "file path is empty");
Log.e(TAG, "copyObbFile: " + "file path is empty");
return false;
} else {
File localFile = new File(unpackPath + File.separator + file);
if (localFile.exists() && localFile.isFile()) {
File installFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + install_path);
Logutils.e(TAG, "copyObbFile: " + "localFile: " + localFile.getAbsolutePath());
Logutils.e(TAG, "copyObbFile: " + "installFile: " + installFile.getAbsolutePath());
Log.e(TAG, "copyObbFile: " + "localFile: " + localFile.getAbsolutePath());
Log.e(TAG, "copyObbFile: " + "installFile: " + installFile.getAbsolutePath());
try {
Path path = Paths.get(localFile.getAbsolutePath());
Files.copy(path, new FileOutputStream(installFile));
return true;
} catch (IOException e) {
Logutils.e(TAG, "copyObbFile: " + "IOException" + e.getMessage());
Log.e(TAG, "copyObbFile: " + "IOException" + e.getMessage());
e.printStackTrace();
return false;
}
} else {
Logutils.e(TAG, "copyObbFile: " + "localFile: " + "File not exists");
Log.e(TAG, "copyObbFile: " + "localFile: " + "File not exists");
return false;
}
@@ -276,14 +277,14 @@ public class XAPKUtils {
filePath.add(unpackPath + File.separator + file);
}
}
// Logutils.e(TAG, "installxApk: " + filePath.toString());
// Log.e(TAG, "installxApk: " + filePath.toString());
} else {
//split_configs为空的情况
int position = getFileFromId(apkList, "base");
if (position != -1) {
String file = apkList.get(position).getFile();
filePath.add(file);
Logutils.e(TAG, "installxApk: " + "base file = " + file);
Log.e(TAG, "installxApk: " + "base file = " + file);
}
}
@@ -353,7 +354,7 @@ public class XAPKUtils {
session.commit(pendingIntent.getIntentSender());
} catch (IOException e) {
e.printStackTrace();
Logutils.e(TAG, "install: " + e.getMessage());
Log.e(TAG, "install: " + e.getMessage());
}
}
@@ -365,7 +366,7 @@ public class XAPKUtils {
sessionId = packageInstaller.createSession(sessionParams);
} catch (IOException e) {
e.printStackTrace();
Logutils.e(TAG, "createSession: " + e.getMessage());
Log.e(TAG, "createSession: " + e.getMessage());
}
return sessionId;
}
@@ -398,9 +399,9 @@ public class XAPKUtils {
}
} catch (IOException e) {
e.printStackTrace();
Logutils.e("fht", "copyApkFile" + e.getMessage());
Log.e("fht", "copyApkFile" + e.getMessage());
}
Logutils.e("fht", "copyApkFile" + "success = " + success);
Log.e("fht", "copyApkFile" + "success = " + success);
return success;
}
}