From a70ee251272d61352d5ba14d471f24d9bab49397 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 11 九月 2024 15:46:58 +0800
Subject: [PATCH] 0312 加入facebook
---
SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java | 62 +++++++++++++++++++++++++------
1 files changed, 50 insertions(+), 12 deletions(-)
diff --git a/SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java b/SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java
index 173dbf4..1573e21 100644
--- a/SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java
+++ b/SdkProject/library/src/main/java/com/secondworld/sdk/utils/FileUtil.java
@@ -2,7 +2,7 @@
import android.content.res.AssetManager;
-import com.secondworld.sdk.GameApp;
+import com.secondworld.sdk.GameAppProxy;
import com.secondworld.sdk.UnityMsgHandler;
import java.io.File;
@@ -33,14 +33,12 @@
if (installVer == currentVer) {
LogUtil.i("copyAssets", "宸叉嫹璐濊繃锛宨nstallVer:" + installVer + "锛�" + "currentVer:" + currentVer);
- Map<String, Object> _msg = new HashMap<>();
- _msg.put("code", CodeA2U.AssetCopyFinished);
- UnityMsgHandler.sendMessageToUnity(_msg);
+ UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
return;
}
- String _dest = GameApp.I.getExternalFilesDir("").getAbsolutePath();
- AssetManager _assetMgr = GameApp.I.getAssets();
+ String _dest = GameAppProxy.app.getExternalFilesDir("").getAbsolutePath();
+ AssetManager _assetMgr = GameAppProxy.app.getAssets();
try {
String[] _fileNames = _assetMgr.list("android");
if (_fileNames != null) {
@@ -53,8 +51,48 @@
// 瀛樺偍姝ゆ鐨勬嫹璐濈増鏈�
SPUtils.get().edit().putLong(SPUtils.LAST_COPY_VERSION, currentVer).apply();
Map<String, Object> _msg = new HashMap<>();
- _msg.put("code", CodeA2U.AssetCopyFinished);
- UnityMsgHandler.sendMessageToUnity(_msg);
+ UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void copyConfigs() {
+
+ // 鑾峰彇褰撳墠鍖呯殑鐗堟湰鍙�
+ final long currentVer = DeviceUtil.getVersionCode();
+
+ // 宸茬粡鎷疯礉杩�, 鍒欏啀娆″垽鏂竴娆$増鏈彿
+ // 濡傛灉鐗堟湰鍙蜂笉鐩稿悓, 鍒欓噸鏂拌繘琛屾嫹璐�
+
+ // 鑾峰彇鏈湴瀛樺偍鐨勭増鏈彿
+ long installVer = SPUtils.get().getLong("configsversion", 0);
+
+ if (installVer == currentVer) {
+ LogUtil.i("copyConfigs", "宸叉嫹璐濊繃锛宨nstallVer:" + installVer + "锛�" + "currentVer:" + currentVer);
+ UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
+ return;
+ }
+
+ String _dest = GameAppProxy.app.getExternalFilesDir("").getAbsolutePath() + File.separator + "config";
+ File _file = new File(_dest);
+ if (!_file.exists()) {
+ boolean mkdir = _file.mkdir();
+ }
+ AssetManager _assetMgr = GameAppProxy.app.getAssets();
+ try {
+ String[] _fileNames = _assetMgr.list("android/config");
+ if (_fileNames != null) {
+ for (String _fileName : _fileNames) {
+ copy("android/config" + File.separator + _fileName,
+ _dest + File.separator + _fileName);
+ }
+ }
+ LogUtil.i("copyConfigs", "鍏ㄩ儴鎷疯礉瀹屾垚," + "currentVer:" + currentVer);
+ // 瀛樺偍姝ゆ鐨勬嫹璐濈増鏈�
+ SPUtils.get().edit().putLong("configsversion", currentVer).apply();
+ Map<String, Object> _msg = new HashMap<>();
+ UnityMsgHandler.sendMessageToUnity(CodeA2U.AssetCopyFinished);
} catch (Exception e) {
e.printStackTrace();
}
@@ -67,7 +105,7 @@
*/
public static void copyOneAsset(String fileName) {
String originalPath = "android" + File.separator + fileName;
- String destPath = GameApp.I.getExternalFilesDir(
+ String destPath = GameAppProxy.app.getExternalFilesDir(
"").getAbsolutePath() + File.separator + fileName;
String _destDir = destPath.substring(0, destPath.lastIndexOf('/') + 1);
File _file = new File(_destDir);
@@ -75,7 +113,7 @@
boolean mkdir = _file.mkdir();
}
try {
- InputStream _is = GameApp.I.getAssets().open(originalPath);
+ InputStream _is = GameAppProxy.app.getAssets().open(originalPath);
FileOutputStream _fos = new FileOutputStream(new File(destPath));
byte[] _buffer = new byte[1024];
int _byteCount;
@@ -92,7 +130,7 @@
public static void copy(String original, String dest) {
try {
- String[] fileNames = GameApp.I.getAssets().list(original);
+ String[] fileNames = GameAppProxy.app.getAssets().list(original);
if (fileNames.length > 0) {
File dir = new File(dest);
String mkdir = dir.mkdir() ? "鎴愬姛" : "澶辫触";
@@ -102,7 +140,7 @@
dest + File.separator + _fileName);
}
} else {
- InputStream _is = GameApp.I.getAssets().open(original);
+ InputStream _is = GameAppProxy.app.getAssets().open(original);
FileOutputStream _fos = new FileOutputStream(new File(dest));
byte[] _buffer = new byte[1024];
int _byteCount;
--
Gitblit v1.8.0