mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-26 03:03:45 +01:00 
			
		
		
		
	Less restrictive install permission requests (#488)
This commit is contained in:
		| @@ -124,9 +124,6 @@ class _AddAppPageState extends State<AddAppPage> { | ||||
|               pickedSource!, userInput, additionalSettings, | ||||
|               trackOnlyOverride: trackOnly, | ||||
|               overrideSource: pickedSourceOverride); | ||||
|           if (!trackOnly) { | ||||
|             await settingsProvider.getInstallPermission(); | ||||
|           } | ||||
|           // Only download the APK here if you need to for the package ID | ||||
|           if (sourceProvider.isTempId(app) && | ||||
|               app.additionalSettings['trackOnly'] != true) { | ||||
|   | ||||
| @@ -327,9 +327,6 @@ class _AppPageState extends State<AppPage> { | ||||
|             ? () async { | ||||
|                 try { | ||||
|                   HapticFeedback.heavyImpact(); | ||||
|                   if (app?.app.additionalSettings['trackOnly'] != true) { | ||||
|                     await settingsProvider.getInstallPermission(); | ||||
|                   } | ||||
|                   var res = await appsProvider.downloadAndInstallLatestApps( | ||||
|                       [app!.app.id], globalNavigatorKey.currentContext); | ||||
|                   if (res.isNotEmpty && mounted) { | ||||
|   | ||||
| @@ -624,11 +624,6 @@ class AppsPageState extends State<AppsPage> { | ||||
|                   bool shouldInstallNew = values['installs'] == true; | ||||
|                   bool shouldMarkTrackOnlies = values['trackonlies'] == true; | ||||
|                   (() async { | ||||
|                     if (shouldInstallNew || shouldInstallUpdates) { | ||||
|                       await settingsProvider.getInstallPermission(); | ||||
|                     } | ||||
|                   })() | ||||
|                       .then((_) { | ||||
|                     List<String> toInstall = []; | ||||
|                     if (shouldInstallUpdates) { | ||||
|                       toInstall.addAll(existingUpdateIdsAllOrSelected); | ||||
| @@ -639,6 +634,12 @@ class AppsPageState extends State<AppsPage> { | ||||
|                     if (shouldMarkTrackOnlies) { | ||||
|                       toInstall.addAll(trackOnlyUpdateIdsAllOrSelected); | ||||
|                     } | ||||
|                     if (toInstall.length > 1) { | ||||
|                       // Permission is requested automatically, but if there are more than 1 installs, | ||||
|                       // We want to explicitly request it and wait for the result to avoid multiple requests | ||||
|                       await settingsProvider.getInstallPermission( | ||||
|                           enforce: false); | ||||
|                     } | ||||
|                     appsProvider | ||||
|                         .downloadAndInstallLatestApps( | ||||
|                             toInstall, globalNavigatorKey.currentContext) | ||||
|   | ||||
| @@ -120,7 +120,7 @@ class SettingsProvider with ChangeNotifier { | ||||
|     return result; | ||||
|   } | ||||
|  | ||||
|   Future<void> getInstallPermission() async { | ||||
|   Future<void> getInstallPermission({bool enforce = false}) async { | ||||
|     while (!(await Permission.requestInstallPackages.isGranted)) { | ||||
|       // Explicit request as InstallPlugin request sometimes bugged | ||||
|       Fluttertoast.showToast( | ||||
| @@ -129,6 +129,9 @@ class SettingsProvider with ChangeNotifier { | ||||
|           PermissionStatus.granted) { | ||||
|         break; | ||||
|       } | ||||
|       if (!enforce) { | ||||
|         break; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user