[core] Upgrade manager if older version installed

This commit is contained in:
tehcneko 2021-03-07 14:22:54 +08:00 committed by LoveSy
parent cb6f14a41a
commit 4ce43df88f
1 changed files with 2 additions and 2 deletions

View File

@ -242,8 +242,8 @@ public class PackageService {
if (pkgInfo != null && pkgInfo.versionName != null && pkgInfo.applicationInfo != null) {
boolean versionMatch = pkgInfo.versionName.equals(BuildConfig.VERSION_NAME);
boolean signatureMatch = InstallerVerifier.verifyInstallerSignature(pkgInfo.applicationInfo);
if (versionMatch && signatureMatch) return false;
if (!signatureMatch || pkgInfo.versionCode > BuildConfig.VERSION_CODE)
if (versionMatch && signatureMatch && pkgInfo.versionCode >= BuildConfig.VERSION_CODE) return false;
if (!signatureMatch || !versionMatch && pkgInfo.versionCode > BuildConfig.VERSION_CODE)
uninstallPackage(new VersionedPackage(pkgInfo.packageName, pkgInfo.versionCode));
}
IPackageInstaller installerService = pm.getPackageInstaller();