App-wide "pretend to be GPlay" option (#1859)

This commit is contained in:
Imran Remtulla
2024-10-01 17:07:11 -04:00
parent 9f50d8db2d
commit 738dd5649f
3 changed files with 34 additions and 15 deletions

View File

@ -578,6 +578,22 @@ class _SettingsPageState extends State<SettingsPage> {
}) })
], ],
), ),
height16,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(
tr('shizukuPretendToBeGooglePlay'))),
Switch(
value: settingsProvider
.shizukuPretendToBeGooglePlay,
onChanged: (value) {
settingsProvider
.shizukuPretendToBeGooglePlay = value;
})
],
),
height32, height32,
Text( Text(
tr('sourceSpecific'), tr('sourceSpecific'),

View File

@ -879,22 +879,20 @@ class AppsProvider with ChangeNotifier {
apps[id]?.installedInfo == null ? context : null; apps[id]?.installedInfo == null ? context : null;
bool needBGWorkaround = bool needBGWorkaround =
willBeSilent && context == null && !settingsProvider.useShizuku; willBeSilent && context == null && !settingsProvider.useShizuku;
bool shizukuPretendToBeGooglePlay = settingsProvider
.shizukuPretendToBeGooglePlay ||
apps[id]!.app.additionalSettings['shizukuPretendToBeGooglePlay'] ==
true;
if (downloadedFile != null) { if (downloadedFile != null) {
if (needBGWorkaround) { if (needBGWorkaround) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
installApk(downloadedFile, contextIfNewInstall, installApk(downloadedFile, contextIfNewInstall,
needsBGWorkaround: true, needsBGWorkaround: true,
shizukuPretendToBeGooglePlay: apps[id]! shizukuPretendToBeGooglePlay: shizukuPretendToBeGooglePlay);
.app
.additionalSettings['shizukuPretendToBeGooglePlay'] ==
true);
} else { } else {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
sayInstalled = await installApk(downloadedFile, contextIfNewInstall, sayInstalled = await installApk(downloadedFile, contextIfNewInstall,
shizukuPretendToBeGooglePlay: apps[id]! shizukuPretendToBeGooglePlay: shizukuPretendToBeGooglePlay);
.app
.additionalSettings['shizukuPretendToBeGooglePlay'] ==
true);
} }
} else { } else {
if (needBGWorkaround) { if (needBGWorkaround) {
@ -905,10 +903,7 @@ class AppsProvider with ChangeNotifier {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
sayInstalled = await installXApkDir( sayInstalled = await installXApkDir(
downloadedDir!, contextIfNewInstall, downloadedDir!, contextIfNewInstall,
shizukuPretendToBeGooglePlay: apps[id]! shizukuPretendToBeGooglePlay: shizukuPretendToBeGooglePlay);
.app
.additionalSettings['shizukuPretendToBeGooglePlay'] ==
true);
} }
} }
if (willBeSilent && context == null) { if (willBeSilent && context == null) {

View File

@ -48,7 +48,7 @@ class SettingsProvider with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool get useShizuku{ bool get useShizuku {
return prefs?.getBool('useShizuku') ?? false; return prefs?.getBool('useShizuku') ?? false;
} }
@ -69,8 +69,7 @@ class SettingsProvider with ChangeNotifier {
Color get themeColor { Color get themeColor {
int? colorCode = prefs?.getInt('themeColor'); int? colorCode = prefs?.getInt('themeColor');
return (colorCode != null) ? return (colorCode != null) ? Color(colorCode) : obtainiumThemeColor;
Color(colorCode) : obtainiumThemeColor;
} }
set themeColor(Color themeColor) { set themeColor(Color themeColor) {
@ -469,4 +468,13 @@ class SettingsProvider with ChangeNotifier {
prefs?.setBool('beforeNewInstallsShareToAppVerifier', val); prefs?.setBool('beforeNewInstallsShareToAppVerifier', val);
notifyListeners(); notifyListeners();
} }
bool get shizukuPretendToBeGooglePlay {
return prefs?.getBool('shizukuPretendToBeGooglePlay') ?? false;
}
set shizukuPretendToBeGooglePlay(bool val) {
prefs?.setBool('shizukuPretendToBeGooglePlay', val);
notifyListeners();
}
} }