mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-04 07:13:28 +01:00 
			
		
		
		
	Bugfix for different ID same URL Apps (#299)
This commit is contained in:
		@@ -118,7 +118,7 @@ class _AddAppPageState extends State<AddAppPage> {
 | 
			
		||||
            await settingsProvider.getInstallPermission();
 | 
			
		||||
          }
 | 
			
		||||
          // Only download the APK here if you need to for the package ID
 | 
			
		||||
          if (sourceProvider.isTempId(app.id) &&
 | 
			
		||||
          if (sourceProvider.isTempId(app) &&
 | 
			
		||||
              app.additionalSettings['trackOnly'] != true) {
 | 
			
		||||
            // ignore: use_build_context_synchronously
 | 
			
		||||
            var apkUrl = await appsProvider.confirmApkUrl(app, context);
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@ class _AppPageState extends State<AppPage> {
 | 
			
		||||
      mainAxisAlignment: MainAxisAlignment.center,
 | 
			
		||||
      crossAxisAlignment: CrossAxisAlignment.stretch,
 | 
			
		||||
      children: [
 | 
			
		||||
        const SizedBox(height: 150),
 | 
			
		||||
        const SizedBox(height: 125),
 | 
			
		||||
        app?.installedInfo != null
 | 
			
		||||
            ? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
 | 
			
		||||
                Image.memory(
 | 
			
		||||
@@ -136,6 +136,14 @@ class _AppPageState extends State<AppPage> {
 | 
			
		||||
          textAlign: TextAlign.center,
 | 
			
		||||
          style: Theme.of(context).textTheme.headlineMedium,
 | 
			
		||||
        ),
 | 
			
		||||
        const SizedBox(
 | 
			
		||||
          height: 8,
 | 
			
		||||
        ),
 | 
			
		||||
        Text(
 | 
			
		||||
          app?.app.id ?? '',
 | 
			
		||||
          textAlign: TextAlign.center,
 | 
			
		||||
          style: Theme.of(context).textTheme.labelSmall,
 | 
			
		||||
        ),
 | 
			
		||||
        const SizedBox(
 | 
			
		||||
          height: 32,
 | 
			
		||||
        ),
 | 
			
		||||
 
 | 
			
		||||
@@ -182,7 +182,7 @@ class AppsProvider with ChangeNotifier {
 | 
			
		||||
    // The former case should be handled (give the App its real ID), the latter is a security issue
 | 
			
		||||
    var newInfo = await PackageArchiveInfo.fromPath(downloadedFile.path);
 | 
			
		||||
    if (app.id != newInfo.packageName) {
 | 
			
		||||
      if (apps[app.id] != null && !SourceProvider().isTempId(app.id)) {
 | 
			
		||||
      if (apps[app.id] != null && !SourceProvider().isTempId(app)) {
 | 
			
		||||
        throw IDChangedError();
 | 
			
		||||
      }
 | 
			
		||||
      var originalAppId = app.id;
 | 
			
		||||
 
 | 
			
		||||
@@ -350,21 +350,12 @@ class SourceProvider {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  String generateTempID(AppNames names, AppSource source) =>
 | 
			
		||||
      '${names.author.toLowerCase()}_${names.name.toLowerCase()}_${source.host}';
 | 
			
		||||
  String generateTempID(
 | 
			
		||||
          String standardUrl, Map<String, dynamic> additionalSettings) =>
 | 
			
		||||
      (standardUrl + additionalSettings.toString()).hashCode.toString();
 | 
			
		||||
 | 
			
		||||
  bool isTempId(String id) {
 | 
			
		||||
    List<String> parts = id.split('_');
 | 
			
		||||
    if (parts.length < 3) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    for (int i = 0; i < parts.length - 1; i++) {
 | 
			
		||||
      if (RegExp('.*[A-Z].*').hasMatch(parts[i])) {
 | 
			
		||||
        // TODO: Look into RegEx for non-Latin characters
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
  bool isTempId(App app) {
 | 
			
		||||
    return app.id == generateTempID(app.url, app.additionalSettings);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<App> getApp(
 | 
			
		||||
@@ -400,7 +391,7 @@ class SourceProvider {
 | 
			
		||||
        currentApp?.id ??
 | 
			
		||||
            source.tryInferringAppId(standardUrl,
 | 
			
		||||
                additionalSettings: additionalSettings) ??
 | 
			
		||||
            generateTempID(apk.names, source),
 | 
			
		||||
            generateTempID(standardUrl, additionalSettings),
 | 
			
		||||
        standardUrl,
 | 
			
		||||
        apk.names.author[0].toUpperCase() + apk.names.author.substring(1),
 | 
			
		||||
        name.trim().isNotEmpty
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user