From a0ad95363367656656136bf204596a1dcb74c217 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 20 六月 2025 16:26:32 +0800
Subject: [PATCH] 2025年06月20日16:26:30
---
app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java b/app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java
index 4274497..0fb6fc8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java
+++ b/app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java
@@ -87,7 +87,7 @@
request.setDescription(desc);
// 瀹屾垚鍚庢樉绀洪�氱煡鏍�
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
- request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HdlAppUpdateLogic.ApkFileName);
+ request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HdlAppUpdateLogic.getInstance().getApkFileName());
request.setMimeType("application/vnd.android.package-archive");
} else {
request.setDestinationInExternalFilesDir(weakReference.get(), Environment.DIRECTORY_DOWNLOADS, HDLUniMP.UNI_APP_ID + ".wgt");
@@ -110,8 +110,11 @@
//璁剧疆鐩戝惉Uri.parse("content://downloads/my_downloads")
weakReference.get().getContentResolver().registerContentObserver(Uri.parse("content://downloads/my_downloads"), true,
mDownLoadChangeObserver);
+
+ IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
// 娉ㄥ唽骞挎挱锛岀洃鍚珹PK鏄惁涓嬭浇瀹屾垚
- weakReference.get().registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
+ weakReference.get().registerReceiver(mDownloadReceiver, intentFilter);
}
/**
@@ -148,7 +151,8 @@
downSuccess = true;
Log.i(TAG, "涓嬭浇杩涘害锛氬畬鎴�");
}
- Log.i(TAG, "涓嬭浇杩涘害锛�" + bytesAndStatus[0] + "/" + bytesAndStatus[1] + "");
+ long value = bytesAndStatus[0] * 100L / bytesAndStatus[1];
+ Log.i(TAG, "涓嬭浇杩涘害锛�" + value + "");
}
class DownloadChangeObserver extends ContentObserver {
@@ -192,16 +196,16 @@
@Override
public void permissionFail() {
- HdlThreadLogic.toast(HDLApp.getInstance(), HDLApp.getInstance().getResources().getString(R.string.app_update_fail));
+ HdlThreadLogic.toast(HDLApp.getInstance(), HDLApp.getInstance().getAppLocaleContext().getString(R.string.app_update_fail));
}
};
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
AndroidPermissionActivity.sListener = listener;
- Intent intent1 = new Intent(context, AndroidPermissionActivity.class);
- intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent1);
+ Intent intentPermission = new Intent(context, AndroidPermissionActivity.class);
+ intentPermission.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intentPermission);
}
}, 2000);
@@ -221,8 +225,8 @@
/**
- * @param context
- * @param intent
+ * @param context -
+ * @param intent -
*/
private void installApk(Context context, Intent intent) {
long completeDownLoadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
@@ -235,7 +239,7 @@
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { // 6.0浠ヤ笅
uri = mDownloadManager.getUriForDownloadedFile(completeDownLoadId);
if (null == uri) {
- File apkFile = new File(weakReference.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.ApkFileName);
+ File apkFile = new File(weakReference.get().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.getInstance().getApkFileName());
if (apkFile.exists()) {
uri = Uri.fromFile(apkFile);
}
@@ -245,8 +249,8 @@
uri = Uri.fromFile(apkFile);
} else { // Android 7.0 浠ヤ笂
uri = FileProvider.getUriForFile(context,
- "com.hdl.debugtreasure.dc.fileprovider",
- new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.ApkFileName));
+ "com.hdl.photovoltaic.fileProvider",
+ new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), HdlAppUpdateLogic.getInstance().getApkFileName()));
intentInstall.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
}
// 瀹夎搴旂敤
--
Gitblit v1.8.0