Remove version check, allow version downgrades to appear in Updates tab correctly.
The version check guarded against downgrades, and would not notify the user if it found a downgrade in the apk cache. However this was from before we could ask `AppUpdateStatusManager#isPendingInstall(hash)`. Now we don't need to care whether it is an upgrade or a downgrade, because there is a more authoritative source as to whether this apk is interesting to us or not.
This commit is contained in:
parent
0d1e00b6cf
commit
25edfffcbe
@ -43,6 +43,7 @@ public class AppUpdateStatusService extends IntentService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHandleIntent(@Nullable Intent intent) {
|
protected void onHandleIntent(@Nullable Intent intent) {
|
||||||
|
Utils.debugLog(TAG, "Scanning apk cache to see if we need to prompt the user to install any apks.");
|
||||||
List<Apk> apksReadyToInstall = new ArrayList<>();
|
List<Apk> apksReadyToInstall = new ArrayList<>();
|
||||||
File cacheDir = ApkCache.getApkCacheDir(this);
|
File cacheDir = ApkCache.getApkCacheDir(this);
|
||||||
for (String repoDirName : cacheDir.list()) {
|
for (String repoDirName : cacheDir.list()) {
|
||||||
@ -76,29 +77,13 @@ public class AppUpdateStatusService extends IntentService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageInfo installedInfo = null;
|
if (AppUpdateStatusManager.getInstance(this).isPendingInstall(downloadedApk.hash)) {
|
||||||
try {
|
Utils.debugLog(TAG, downloadedApk.packageName + " is pending install, so we need to notify the user about installing it.");
|
||||||
installedInfo = getPackageManager().getPackageInfo(downloadedApk.packageName, PackageManager.GET_META_DATA);
|
return downloadedApk;
|
||||||
} catch (PackageManager.NameNotFoundException ignored) { }
|
} else {
|
||||||
|
Utils.debugLog(TAG, downloadedApk.packageName + " is NOT pending install, probably just left over from a previous install.");
|
||||||
if (installedInfo == null) {
|
|
||||||
if (AppUpdateStatusManager.getInstance(this).isPendingInstall(downloadedApk.hash)) {
|
|
||||||
Utils.debugLog(TAG, downloadedApk.packageName + " is not installed, so presuming we need to notify the user about installing it.");
|
|
||||||
return downloadedApk;
|
|
||||||
} else {
|
|
||||||
// It was probably downloaded for a previous install, and then subsequently removed
|
|
||||||
// (but stayed in the cache, as is the designed behaviour). Under these circumstances
|
|
||||||
// we don't want to tell the user to try and install it.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (installedInfo.versionCode >= downloadedInfo.versionCode) {
|
|
||||||
Utils.debugLog(TAG, downloadedApk.packageName + " already installed with versionCode " + installedInfo.versionCode + " and downloaded apk is only " + downloadedInfo.versionCode + ", so ignoring downloaded apk.");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return downloadedApk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user