From a3798b01c03911efcd7f7b28f78cebc35871c528 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 06 八月 2024 18:37:07 +0800
Subject: [PATCH] 2024年08月06日18:37:05
---
app/src/main/java/com/hdl/photovoltaic/widget/apkwgtupload/AppDownloadManager.java | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 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..8c02c16 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 {
@@ -199,9 +203,9 @@
@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