"Naive" version detection for some Sources (#946)

This commit is contained in:
Imran Remtulla
2023-09-30 10:12:49 -04:00
parent 9f19e4dc83
commit 4c811c9c04
5 changed files with 31 additions and 13 deletions

View File

@@ -22,6 +22,7 @@ class APKPure extends AppSource {
APKPure() { APKPure() {
host = 'apkpure.com'; host = 'apkpure.com';
allowSubDomains = true; allowSubDomains = true;
naiveStandardVersionDetection = true;
} }
@override @override

View File

@@ -9,6 +9,7 @@ class Aptoide extends AppSource {
host = 'aptoide.com'; host = 'aptoide.com';
name = tr('Aptoide'); name = tr('Aptoide');
allowSubDomains = true; allowSubDomains = true;
naiveStandardVersionDetection = true;
} }
@override @override

View File

@@ -8,6 +8,7 @@ class Uptodown extends AppSource {
Uptodown() { Uptodown() {
host = 'uptodown.com'; host = 'uptodown.com';
allowSubDomains = true; allowSubDomains = true;
naiveStandardVersionDetection = true;
} }
@override @override

View File

@@ -709,14 +709,21 @@ class AppsProvider with ChangeNotifier {
} }
bool isVersionDetectionPossible(AppInMemory? app) { bool isVersionDetectionPossible(AppInMemory? app) {
return app?.app.additionalSettings['trackOnly'] != true && if (app?.app == null) {
app?.app.additionalSettings['versionDetection'] != return false;
}
var naiveStandardVersionDetection = SourceProvider()
.getSource(app!.app.url, overrideSource: app.app.overrideSource)
.naiveStandardVersionDetection;
return app.app.additionalSettings['trackOnly'] != true &&
app.app.additionalSettings['versionDetection'] !=
'releaseDateAsVersion' && 'releaseDateAsVersion' &&
app?.installedInfo?.versionName != null && app.installedInfo?.versionName != null &&
app?.app.installedVersion != null && app.app.installedVersion != null &&
reconcileVersionDifferences( (reconcileVersionDifferences(app.installedInfo!.versionName!,
app!.installedInfo!.versionName!, app.app.installedVersion!) != app.app.installedVersion!) !=
null; null ||
naiveStandardVersionDetection);
} }
// Given an App and it's on-device info... // Given an App and it's on-device info...
@@ -725,8 +732,13 @@ class AppsProvider with ChangeNotifier {
App app, PackageInfo? installedInfo) { App app, PackageInfo? installedInfo) {
var modded = false; var modded = false;
var trackOnly = app.additionalSettings['trackOnly'] == true; var trackOnly = app.additionalSettings['trackOnly'] == true;
var noVersionDetection = app.additionalSettings['versionDetection'] != var versionDetectionIsStandard =
app.additionalSettings['versionDetection'] ==
'standardVersionDetection'; 'standardVersionDetection';
var naiveStandardVersionDetection = SourceProvider()
.getSource(app.url, overrideSource: app.overrideSource)
.naiveStandardVersionDetection;
;
// FIRST, COMPARE THE APP'S REPORTED AND REAL INSTALLED VERSIONS, WHERE ONE IS NULL // FIRST, COMPARE THE APP'S REPORTED AND REAL INSTALLED VERSIONS, WHERE ONE IS NULL
if (installedInfo == null && app.installedVersion != null && !trackOnly) { if (installedInfo == null && app.installedVersion != null && !trackOnly) {
// App says it's installed but isn't really (and isn't track only) - set to not installed // App says it's installed but isn't really (and isn't track only) - set to not installed
@@ -741,7 +753,7 @@ class AppsProvider with ChangeNotifier {
// SECOND, RECONCILE DIFFERENCES BETWEEN THE APP'S REPORTED AND REAL INSTALLED VERSIONS, WHERE NEITHER IS NULL // SECOND, RECONCILE DIFFERENCES BETWEEN THE APP'S REPORTED AND REAL INSTALLED VERSIONS, WHERE NEITHER IS NULL
if (installedInfo?.versionName != null && if (installedInfo?.versionName != null &&
installedInfo!.versionName != app.installedVersion && installedInfo!.versionName != app.installedVersion &&
!noVersionDetection) { versionDetectionIsStandard) {
// App's reported version and real version don't match (and it uses standard version detection) // App's reported version and real version don't match (and it uses standard version detection)
// If they share a standard format (and are still different under it), update the reported version accordingly // If they share a standard format (and are still different under it), update the reported version accordingly
var correctedInstalledVersion = reconcileVersionDifferences( var correctedInstalledVersion = reconcileVersionDifferences(
@@ -749,12 +761,15 @@ class AppsProvider with ChangeNotifier {
if (correctedInstalledVersion?.key == false) { if (correctedInstalledVersion?.key == false) {
app.installedVersion = correctedInstalledVersion!.value; app.installedVersion = correctedInstalledVersion!.value;
modded = true; modded = true;
} else if (naiveStandardVersionDetection) {
app.installedVersion = installedInfo.versionName;
modded = true;
} }
} }
// THIRD, RECONCILE THE APP'S REPORTED INSTALLED AND LATEST VERSIONS // THIRD, RECONCILE THE APP'S REPORTED INSTALLED AND LATEST VERSIONS
if (app.installedVersion != null && if (app.installedVersion != null &&
app.installedVersion != app.latestVersion && app.installedVersion != app.latestVersion &&
!noVersionDetection) { versionDetectionIsStandard) {
// App's reported installed and latest versions don't match (and it uses standard version detection) // App's reported installed and latest versions don't match (and it uses standard version detection)
// If they share a standard format, make sure the App's reported installed version uses that format // If they share a standard format, make sure the App's reported installed version uses that format
var correctedInstalledVersion = var correctedInstalledVersion =
@@ -766,8 +781,7 @@ class AppsProvider with ChangeNotifier {
} }
// FOURTH, DISABLE VERSION DETECTION IF ENABLED AND THE REPORTED/REAL INSTALLED VERSIONS ARE NOT STANDARDIZED // FOURTH, DISABLE VERSION DETECTION IF ENABLED AND THE REPORTED/REAL INSTALLED VERSIONS ARE NOT STANDARDIZED
if (installedInfo != null && if (installedInfo != null &&
app.additionalSettings['versionDetection'] == versionDetectionIsStandard &&
'standardVersionDetection' &&
!isVersionDetectionPossible( !isVersionDetectionPossible(
AppInMemory(app, null, installedInfo, null))) { AppInMemory(app, null, installedInfo, null))) {
app.additionalSettings['versionDetection'] = 'noVersionDetection'; app.additionalSettings['versionDetection'] = 'noVersionDetection';

View File

@@ -328,6 +328,7 @@ abstract class AppSource {
bool changeLogIfAnyIsMarkDown = true; bool changeLogIfAnyIsMarkDown = true;
bool appIdInferIsOptional = false; bool appIdInferIsOptional = false;
bool allowSubDomains = false; bool allowSubDomains = false;
bool naiveStandardVersionDetection = false;
AppSource() { AppSource() {
name = runtimeType.toString(); name = runtimeType.toString();