Check file size first before checking hash to save cycles.
This commit is contained in:
parent
2a40e082e6
commit
2fc8060a5d
@ -107,6 +107,7 @@ public class AppUpdateStatusService extends IntentService {
|
||||
PackageInfo info = getPackageManager().getPackageInfo(downloadedApk.packageName, 0);
|
||||
File pathToInstalled = InstalledAppProviderService.getPathToInstalledApk(info);
|
||||
if (pathToInstalled != null && pathToInstalled.canRead() &&
|
||||
pathToInstalled.length() == downloadedApk.size && // Check size before hash for performance.
|
||||
TextUtils.equals(Utils.getBinaryHash(pathToInstalled, "sha256"), downloadedApk.hash)) {
|
||||
Log.i(TAG, downloadedApk.packageName + " is pending install, but we already have the correct version installed.");
|
||||
AppUpdateStatusManager.getInstance(this).markAsNoLongerPendingInstall(downloadedApk.getUrl());
|
||||
|
Loading…
x
Reference in New Issue
Block a user