mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-22 17:19:42 +02:00
This commit is contained in:
@@ -243,19 +243,28 @@ class HTML extends AppSource {
|
|||||||
if ((additionalSettings['customLinkFilterRegex'] as String?)?.isNotEmpty ==
|
if ((additionalSettings['customLinkFilterRegex'] as String?)?.isNotEmpty ==
|
||||||
true) {
|
true) {
|
||||||
var reg = RegExp(additionalSettings['customLinkFilterRegex']);
|
var reg = RegExp(additionalSettings['customLinkFilterRegex']);
|
||||||
links = allLinks
|
links = allLinks.where((element) {
|
||||||
.where((element) => reg.hasMatch(
|
var link = element.key;
|
||||||
filterLinkByText ? element.value : Uri.decodeFull(element.key)))
|
try {
|
||||||
.toList();
|
link = Uri.decodeFull(element.key);
|
||||||
|
} catch (e) {
|
||||||
|
// Some links may not have valid encoding
|
||||||
|
}
|
||||||
|
return reg.hasMatch(filterLinkByText ? element.value : link);
|
||||||
|
}).toList();
|
||||||
} else {
|
} else {
|
||||||
links = allLinks
|
links = allLinks.where((element) {
|
||||||
.where((element) => Uri.parse(filterLinkByText
|
var link = element.key;
|
||||||
? element.value
|
try {
|
||||||
: Uri.decodeFull(element.key))
|
link = Uri.decodeFull(element.key);
|
||||||
.path
|
} catch (e) {
|
||||||
.toLowerCase()
|
// Some links may not have valid encoding
|
||||||
.endsWith('.apk'))
|
}
|
||||||
.toList();
|
return Uri.parse(filterLinkByText ? element.value : link)
|
||||||
|
.path
|
||||||
|
.toLowerCase()
|
||||||
|
.endsWith('.apk');
|
||||||
|
}).toList();
|
||||||
}
|
}
|
||||||
if (!skipSort) {
|
if (!skipSort) {
|
||||||
links.sort((a, b) => additionalSettings['sortByLastLinkSegment'] == true
|
links.sort((a, b) => additionalSettings['sortByLastLinkSegment'] == true
|
||||||
@@ -310,13 +319,19 @@ class HTML extends AppSource {
|
|||||||
links = [MapEntry(currentUrl, currentUrl)];
|
links = [MapEntry(currentUrl, currentUrl)];
|
||||||
}
|
}
|
||||||
var rel = links.last.key;
|
var rel = links.last.key;
|
||||||
|
var relDecoded = rel;
|
||||||
|
try {
|
||||||
|
relDecoded = Uri.decodeFull(rel);
|
||||||
|
} catch (e) {
|
||||||
|
// Some links may not have valid encoding
|
||||||
|
}
|
||||||
String? version;
|
String? version;
|
||||||
version = extractVersion(
|
version = extractVersion(
|
||||||
additionalSettings['versionExtractionRegEx'] as String?,
|
additionalSettings['versionExtractionRegEx'] as String?,
|
||||||
additionalSettings['matchGroupToUse'] as String?,
|
additionalSettings['matchGroupToUse'] as String?,
|
||||||
additionalSettings['versionExtractWholePage'] == true
|
additionalSettings['versionExtractWholePage'] == true
|
||||||
? versionExtractionWholePageString
|
? versionExtractionWholePageString
|
||||||
: Uri.decodeFull(rel));
|
: relDecoded);
|
||||||
version ??=
|
version ??=
|
||||||
additionalSettings['defaultPseudoVersioningMethod'] == 'APKLinkHash'
|
additionalSettings['defaultPseudoVersioningMethod'] == 'APKLinkHash'
|
||||||
? rel.hashCode.toString()
|
? rel.hashCode.toString()
|
||||||
|
@@ -525,10 +525,11 @@ class AppsProvider with ChangeNotifier {
|
|||||||
?.installingPackageName
|
?.installingPackageName
|
||||||
: (await pm.getInstallerPackageName(packageName: app.id));
|
: (await pm.getInstallerPackageName(packageName: app.id));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false; // App probably not installed
|
return false; // App probably not installed
|
||||||
}
|
}
|
||||||
|
|
||||||
int? targetSDK = (await getInstalledInfo(app.id))?.applicationInfo?.targetSdkVersion;
|
int? targetSDK =
|
||||||
|
(await getInstalledInfo(app.id))?.applicationInfo?.targetSdkVersion;
|
||||||
// The APK should target a new enough API
|
// The APK should target a new enough API
|
||||||
// https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
// https://developer.android.com/reference/android/content/pm/PackageInstaller.SessionParams#setRequireUserAction(int)
|
||||||
if (!(targetSDK != null && targetSDK >= (osInfo.version.sdkInt - 3))) {
|
if (!(targetSDK != null && targetSDK >= (osInfo.version.sdkInt - 3))) {
|
||||||
@@ -571,7 +572,8 @@ class AppsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
Future<bool> installXApkDir(
|
Future<bool> installXApkDir(
|
||||||
DownloadedXApkDir dir, BuildContext? firstTimeWithContext,
|
DownloadedXApkDir dir, BuildContext? firstTimeWithContext,
|
||||||
{bool needsBGWorkaround = false, bool shizukuPretendToBeGooglePlay = false}) async {
|
{bool needsBGWorkaround = false,
|
||||||
|
bool shizukuPretendToBeGooglePlay = false}) async {
|
||||||
// We don't know which APKs in an XAPK are supported by the user's device
|
// We don't know which APKs in an XAPK are supported by the user's device
|
||||||
// So we try installing all of them and assume success if at least one installed
|
// So we try installing all of them and assume success if at least one installed
|
||||||
// If 0 APKs installed, throw the first install error encountered
|
// If 0 APKs installed, throw the first install error encountered
|
||||||
@@ -610,7 +612,8 @@ class AppsProvider with ChangeNotifier {
|
|||||||
|
|
||||||
Future<bool> installApk(
|
Future<bool> installApk(
|
||||||
DownloadedApk file, BuildContext? firstTimeWithContext,
|
DownloadedApk file, BuildContext? firstTimeWithContext,
|
||||||
{bool needsBGWorkaround = false, bool shizukuPretendToBeGooglePlay = false}) async {
|
{bool needsBGWorkaround = false,
|
||||||
|
bool shizukuPretendToBeGooglePlay = false}) async {
|
||||||
if (firstTimeWithContext != null &&
|
if (firstTimeWithContext != null &&
|
||||||
settingsProvider.beforeNewInstallsShareToAppVerifier &&
|
settingsProvider.beforeNewInstallsShareToAppVerifier &&
|
||||||
(await getInstalledInfo('dev.soupslurpr.appverifier')) != null) {
|
(await getInstalledInfo('dev.soupslurpr.appverifier')) != null) {
|
||||||
@@ -651,7 +654,8 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
int? code;
|
int? code;
|
||||||
if (!settingsProvider.useShizuku) {
|
if (!settingsProvider.useShizuku) {
|
||||||
code = await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
|
code =
|
||||||
|
await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
|
||||||
} else {
|
} else {
|
||||||
code = await ShizukuApkInstaller.installAPK(file.file.uri.toString(),
|
code = await ShizukuApkInstaller.installAPK(file.file.uri.toString(),
|
||||||
shizukuPretendToBeGooglePlay ? "com.android.vending" : "");
|
shizukuPretendToBeGooglePlay ? "com.android.vending" : "");
|
||||||
@@ -828,7 +832,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
throw ObtainiumError(tr('cancelled'));
|
throw ObtainiumError(tr('cancelled'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch((await ShizukuApkInstaller.checkPermission())!){
|
switch ((await ShizukuApkInstaller.checkPermission())!) {
|
||||||
case 'binder_not_found':
|
case 'binder_not_found':
|
||||||
throw ObtainiumError(tr('shizukuBinderNotFound'));
|
throw ObtainiumError(tr('shizukuBinderNotFound'));
|
||||||
case 'old_shizuku':
|
case 'old_shizuku':
|
||||||
@@ -839,7 +843,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
throw ObtainiumError(tr('cancelled'));
|
throw ObtainiumError(tr('cancelled'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!willBeSilent && context != null) {
|
if (!willBeSilent && context != null && !settingsProvider.useShizuku) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
await waitForUserToReturnToForeground(context);
|
await waitForUserToReturnToForeground(context);
|
||||||
}
|
}
|
||||||
@@ -850,31 +854,46 @@ class AppsProvider with ChangeNotifier {
|
|||||||
bool sayInstalled = true;
|
bool sayInstalled = true;
|
||||||
var contextIfNewInstall =
|
var contextIfNewInstall =
|
||||||
apps[id]?.installedInfo == null ? context : null;
|
apps[id]?.installedInfo == null ? context : null;
|
||||||
bool needBGWorkaround = willBeSilent && context == null && !settingsProvider.useShizuku;
|
bool needBGWorkaround =
|
||||||
|
willBeSilent && context == null && !settingsProvider.useShizuku;
|
||||||
if (downloadedFile != null) {
|
if (downloadedFile != null) {
|
||||||
if (needBGWorkaround) {
|
if (needBGWorkaround) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
installApk(downloadedFile, contextIfNewInstall, needsBGWorkaround: true);
|
installApk(downloadedFile, contextIfNewInstall,
|
||||||
|
needsBGWorkaround: true);
|
||||||
} else {
|
} else {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
sayInstalled = await installApk(downloadedFile, contextIfNewInstall, shizukuPretendToBeGooglePlay: apps[id]!.app.additionalSettings['shizukuPretendToBeGooglePlay'] == true);
|
sayInstalled = await installApk(
|
||||||
|
downloadedFile, contextIfNewInstall,
|
||||||
|
shizukuPretendToBeGooglePlay:
|
||||||
|
apps[id]!.app.additionalSettings[
|
||||||
|
'shizukuPretendToBeGooglePlay'] ==
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (needBGWorkaround) {
|
if (needBGWorkaround) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
installXApkDir(downloadedDir!, contextIfNewInstall, needsBGWorkaround: true);
|
installXApkDir(downloadedDir!, contextIfNewInstall,
|
||||||
|
needsBGWorkaround: true);
|
||||||
} else {
|
} else {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
sayInstalled = await installXApkDir(downloadedDir!, contextIfNewInstall, shizukuPretendToBeGooglePlay: apps[id]!.app.additionalSettings['shizukuPretendToBeGooglePlay'] == true);
|
sayInstalled = await installXApkDir(
|
||||||
|
downloadedDir!, contextIfNewInstall,
|
||||||
|
shizukuPretendToBeGooglePlay:
|
||||||
|
apps[id]!.app.additionalSettings[
|
||||||
|
'shizukuPretendToBeGooglePlay'] ==
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (willBeSilent && context == null) {
|
if (willBeSilent && context == null) {
|
||||||
if (!settingsProvider.useShizuku) {
|
if (!settingsProvider.useShizuku) {
|
||||||
notificationsProvider?.notify(SilentUpdateAttemptNotification(
|
notificationsProvider?.notify(SilentUpdateAttemptNotification(
|
||||||
[apps[id]!.app], id: id.hashCode));
|
[apps[id]!.app],
|
||||||
|
id: id.hashCode));
|
||||||
} else {
|
} else {
|
||||||
notificationsProvider?.notify(SilentUpdateNotification(
|
notificationsProvider?.notify(SilentUpdateNotification(
|
||||||
[apps[id]!.app], sayInstalled, id: id.hashCode));
|
[apps[id]!.app], sayInstalled,
|
||||||
|
id: id.hashCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sayInstalled) {
|
if (sayInstalled) {
|
||||||
|
Reference in New Issue
Block a user