mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-13 21:36:42 +02:00
Compare commits
6 Commits
v0.14.5-be
...
v0.14.6-be
Author | SHA1 | Date | |
---|---|---|---|
e215585a64 | |||
8b01fc03ec | |||
9af2c8370d | |||
01f9003b8d | |||
73a3c7eb71 | |||
370ec1432e |
@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
|
|||||||
// ignore: implementation_imports
|
// ignore: implementation_imports
|
||||||
import 'package:easy_localization/src/localization.dart';
|
import 'package:easy_localization/src/localization.dart';
|
||||||
|
|
||||||
const String currentVersion = '0.14.5';
|
const String currentVersion = '0.14.6';
|
||||||
const String currentReleaseTag =
|
const String currentReleaseTag =
|
||||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
|
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
|
||||||
import 'package:android_intent_plus/flag.dart';
|
import 'package:android_intent_plus/flag.dart';
|
||||||
@ -116,16 +117,19 @@ moveStrToEnd(List<String> arr, String str, {String? strB}) {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveStrToEndMapEntryWithCount(
|
List<MapEntry<String, int>> moveStrToEndMapEntryWithCount(
|
||||||
List<MapEntry<String, int>> arr, MapEntry<String, int> str,
|
List<MapEntry<String, int>> arr, MapEntry<String, int> str,
|
||||||
{MapEntry<String, int>? strB}) {
|
{MapEntry<String, int>? strB}) {
|
||||||
MapEntry<String, int>? temp;
|
MapEntry<String, int>? temp;
|
||||||
arr.removeWhere((element) {
|
arr.removeWhere((element) {
|
||||||
bool res = element.key == str.key || element.key == strB?.key;
|
bool resA = element.key == str.key;
|
||||||
if (res) {
|
bool resB = element.key == strB?.key;
|
||||||
temp = element;
|
if (resA) {
|
||||||
|
temp = str;
|
||||||
|
} else if (resB) {
|
||||||
|
temp = strB;
|
||||||
}
|
}
|
||||||
return res;
|
return resA || resB;
|
||||||
});
|
});
|
||||||
if (temp != null) {
|
if (temp != null) {
|
||||||
arr = [...arr, temp!];
|
arr = [...arr, temp!];
|
||||||
@ -364,6 +368,9 @@ class AppsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
Future<bool> canInstallSilently(
|
Future<bool> canInstallSilently(
|
||||||
App app, SettingsProvider settingsProvider) async {
|
App app, SettingsProvider settingsProvider) async {
|
||||||
|
if (app.id == obtainiumId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!settingsProvider.enableBackgroundUpdates) {
|
if (!settingsProvider.enableBackgroundUpdates) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -393,7 +400,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
(await getInstalledInfo(app.id))?.applicationInfo?.targetSdkVersion;
|
(await getInstalledInfo(app.id))?.applicationInfo?.targetSdkVersion;
|
||||||
|
|
||||||
// The OS must also be new enough and the APK should target a new enough API
|
// The OS must also be new enough and the APK should target a new enough API
|
||||||
return osInfo.version.sdkInt >= 30 &&
|
return osInfo.version.sdkInt >= 31 &&
|
||||||
targetSDK != null &&
|
targetSDK != null &&
|
||||||
targetSDK >= // https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
targetSDK >= // https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
||||||
(osInfo.version.sdkInt - 3);
|
(osInfo.version.sdkInt - 3);
|
||||||
@ -1331,67 +1338,75 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
|
|||||||
(netResult != ConnectivityResult.ethernet);
|
(netResult != ConnectivityResult.ethernet);
|
||||||
}
|
}
|
||||||
// Loop through all updates and check each
|
// Loop through all updates and check each
|
||||||
for (int i = 0; i < toCheck.length; i++) {
|
List<App> toNotify = [];
|
||||||
var appId = toCheck[i].key;
|
try {
|
||||||
var retryCount = toCheck[i].value;
|
for (int i = 0; i < toCheck.length; i++) {
|
||||||
AppInMemory? app = appsProvider.apps[appId];
|
var appId = toCheck[i].key;
|
||||||
if (app?.app.installedVersion != null) {
|
var attemptCount = toCheck[i].value + 1;
|
||||||
try {
|
AppInMemory? app = appsProvider.apps[appId];
|
||||||
notificationsProvider.notify(
|
if (app?.app.installedVersion != null) {
|
||||||
notif = CheckingUpdatesNotification(app?.name ?? appId),
|
try {
|
||||||
cancelExisting: true);
|
notificationsProvider.notify(
|
||||||
App? newApp = await appsProvider.checkUpdate(appId);
|
notif = CheckingUpdatesNotification(app?.name ?? appId),
|
||||||
if (newApp != null) {
|
cancelExisting: true);
|
||||||
if (networkRestricted ||
|
App? newApp = await appsProvider.checkUpdate(appId);
|
||||||
!(await appsProvider.canInstallSilently(
|
if (newApp != null) {
|
||||||
app!.app, settingsProvider))) {
|
if (networkRestricted ||
|
||||||
notificationsProvider.notify(
|
!(await appsProvider.canInstallSilently(
|
||||||
UpdateNotification([newApp], id: newApp.id.hashCode - 1));
|
app!.app, settingsProvider))) {
|
||||||
|
toNotify.add(newApp);
|
||||||
|
} else {
|
||||||
|
toInstall.add(MapEntry(appId, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == (toCheck.length - 1)) {
|
||||||
|
didCompleteChecking = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// If you got an error, move the offender to the back of the line (increment their fail count) and schedule another task to continue checking shortly
|
||||||
|
logs.add(
|
||||||
|
'BG update task $taskId: Got error on checking for $appId \'${e.toString()}\'.');
|
||||||
|
if (attemptCount < maxAttempts) {
|
||||||
|
var remainingSeconds = e is RateLimitError
|
||||||
|
? (i == 0 ? (e.remainingMinutes * 60) : (5 * 60))
|
||||||
|
: e is ClientException
|
||||||
|
? (15 * 60)
|
||||||
|
: pow(attemptCount, 2).toInt();
|
||||||
|
logs.add(
|
||||||
|
'BG update task $taskId: Will continue in $remainingSeconds seconds (with $appId moved to the end of the line).');
|
||||||
|
var remainingToCheck = moveStrToEndMapEntryWithCount(
|
||||||
|
toCheck.sublist(i), MapEntry(appId, attemptCount));
|
||||||
|
AndroidAlarmManager.oneShot(Duration(seconds: remainingSeconds),
|
||||||
|
taskId + 1, bgUpdateCheck,
|
||||||
|
params: {
|
||||||
|
'toCheck': remainingToCheck
|
||||||
|
.map(
|
||||||
|
(entry) => {'key': entry.key, 'value': entry.value})
|
||||||
|
.toList(),
|
||||||
|
'toInstall': toInstall
|
||||||
|
.map(
|
||||||
|
(entry) => {'key': entry.key, 'value': entry.value})
|
||||||
|
.toList(),
|
||||||
|
});
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
toInstall.add(MapEntry(appId, 0));
|
// If the offender has reached its fail limit, notify the user and remove it from the list (task can continue)
|
||||||
|
toCheck.removeAt(i);
|
||||||
|
i--;
|
||||||
|
notificationsProvider
|
||||||
|
.notify(ErrorCheckingUpdatesNotification(e.toString()));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (notif != null) {
|
||||||
|
notificationsProvider.cancel(notif.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == (toCheck.length - 1)) {
|
|
||||||
didCompleteChecking = true;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// If you got an error, move the offender to the back of the line (increment their fail count) and schedule another task to continue checking shortly
|
|
||||||
logs.add(
|
|
||||||
'BG update task $taskId: Got error on checking for $appId \'${e.toString()}\'.');
|
|
||||||
if (retryCount < maxAttempts) {
|
|
||||||
var remainingSeconds = e is RateLimitError
|
|
||||||
? (i == 0 ? (e.remainingMinutes * 60) : (5 * 60))
|
|
||||||
: e is ClientException
|
|
||||||
? (15 * 60)
|
|
||||||
: (retryCount ^ 2);
|
|
||||||
logs.add(
|
|
||||||
'BG update task $taskId: Will continue in $remainingSeconds seconds (with $appId moved to the end of the line).');
|
|
||||||
var remainingToCheck = moveStrToEndMapEntryWithCount(
|
|
||||||
toCheck.sublist(i), MapEntry(appId, retryCount + 1));
|
|
||||||
AndroidAlarmManager.oneShot(
|
|
||||||
Duration(seconds: remainingSeconds), taskId + 1, bgUpdateCheck,
|
|
||||||
params: {
|
|
||||||
'toCheck': remainingToCheck
|
|
||||||
.map((entry) => {'key': entry.key, 'value': entry.value})
|
|
||||||
.toList(),
|
|
||||||
'toInstall': toInstall
|
|
||||||
.map((entry) => {'key': entry.key, 'value': entry.value})
|
|
||||||
.toList(),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// If the offender has reached its fail limit, notify the user and remove it from the list (task can continue)
|
|
||||||
toCheck.removeAt(i);
|
|
||||||
i--;
|
|
||||||
notificationsProvider
|
|
||||||
.notify(ErrorCheckingUpdatesNotification(e.toString()));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (notif != null) {
|
|
||||||
notificationsProvider.cancel(notif.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (toNotify.isNotEmpty) {
|
||||||
|
notificationsProvider.notify(UpdateNotification(toNotify));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If you're done checking and found some silently installable updates, schedule another task which will run in install mode
|
// If you're done checking and found some silently installable updates, schedule another task which will run in install mode
|
||||||
if (didCompleteChecking && toInstall.isNotEmpty) {
|
if (didCompleteChecking && toInstall.isNotEmpty) {
|
||||||
|
@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.14.5+197 # When changing this, update the tag in main() accordingly
|
version: 0.14.6+198 # When changing this, update the tag in main() accordingly
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.2 <3.0.0'
|
sdk: '>=2.18.2 <3.0.0'
|
||||||
|
Reference in New Issue
Block a user