Make pretending to be a Google Play setting per app based⚙️

This commit is contained in:
Gregory Velichko
2024-04-19 17:57:22 +03:00
parent 49022726d3
commit c16cda1962
6 changed files with 18 additions and 39 deletions

View File

@@ -573,7 +573,7 @@ class AppsProvider with ChangeNotifier {
Future<bool> installXApkDir(
DownloadedXApkDir dir, BuildContext? firstTimeWithContext,
{bool needsBGWorkaround = 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
// 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
@@ -588,7 +588,8 @@ class AppsProvider with ChangeNotifier {
somethingInstalled = somethingInstalled ||
await installApk(
DownloadedApk(dir.appId, file), firstTimeWithContext,
needsBGWorkaround: needsBGWorkaround);
needsBGWorkaround: needsBGWorkaround,
shizukuPretendToBeGooglePlay: shizukuPretendToBeGooglePlay);
} catch (e) {
logs.add(
'Could not install APK from XAPK \'${file.path}\': ${e.toString()}');
@@ -611,7 +612,7 @@ class AppsProvider with ChangeNotifier {
Future<bool> installApk(
DownloadedApk file, BuildContext? firstTimeWithContext,
{bool needsBGWorkaround = false}) async {
{bool needsBGWorkaround = false, bool shizukuPretendToBeGooglePlay = false}) async {
if (firstTimeWithContext != null &&
settingsProvider.beforeNewInstallsShareToAppVerifier &&
(await getInstalledInfo('dev.soupslurpr.appverifier')) != null) {
@@ -655,7 +656,7 @@ class AppsProvider with ChangeNotifier {
code = await AndroidPackageInstaller.installApk(apkFilePath: file.file.path);
} else {
code = await ShizukuApkInstaller.installAPK(file.file.uri.toString(),
settingsProvider.pretendToBeGooglePlay ? "com.android.vending" : "");
shizukuPretendToBeGooglePlay ? "com.android.vending" : "");
}
bool installed = false;
if (code != null && code != 0 && code != 3) {
@@ -858,7 +859,7 @@ class AppsProvider with ChangeNotifier {
installApk(downloadedFile, contextIfNewInstall, needsBGWorkaround: true);
} else {
// ignore: use_build_context_synchronously
sayInstalled = await installApk(downloadedFile, contextIfNewInstall);
sayInstalled = await installApk(downloadedFile, contextIfNewInstall, shizukuPretendToBeGooglePlay: apps[id]!.app.additionalSettings['shizukuPretendToBeGooglePlay'] == true);
}
} else {
if (needBGWorkaround) {
@@ -866,7 +867,7 @@ class AppsProvider with ChangeNotifier {
installXApkDir(downloadedDir!, contextIfNewInstall, needsBGWorkaround: true);
} else {
// ignore: use_build_context_synchronously
sayInstalled = await installXApkDir(downloadedDir!, contextIfNewInstall);
sayInstalled = await installXApkDir(downloadedDir!, contextIfNewInstall, shizukuPretendToBeGooglePlay: apps[id]!.app.additionalSettings['shizukuPretendToBeGooglePlay'] == true);
}
}
if (willBeSilent && context == null) {

View File

@@ -61,15 +61,6 @@ class SettingsProvider with ChangeNotifier {
notifyListeners();
}
bool get pretendToBeGooglePlay{
return prefs?.getBool('pretendToBeGooglePlay') ?? false;
}
set pretendToBeGooglePlay(bool pretendToBeGooglePlay) {
prefs?.setBool('pretendToBeGooglePlay', pretendToBeGooglePlay);
notifyListeners();
}
ThemeSettings get theme {
return ThemeSettings
.values[prefs?.getInt('theme') ?? ThemeSettings.system.index];

View File

@@ -521,6 +521,11 @@ abstract class AppSource {
label: tr('autoApkFilterByArch'), defaultValue: true)
],
[GeneratedFormTextField('appName', label: tr('appName'), required: false)],
[
GeneratedFormSwitch('shizukuPretendToBeGooglePlay',
label: tr('shizukuPretendToBeGooglePlay'),
defaultValue: false)
],
[
GeneratedFormSwitch('exemptFromBackgroundUpdates',
label: tr('exemptFromBackgroundUpdates'))