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

@@ -288,7 +288,7 @@
"shizukuBinderNotFound": "Shizuku service not found, probably it's not launched", "shizukuBinderNotFound": "Shizuku service not found, probably it's not launched",
"shizukuOld": "Old Shizuku version (<11), update it", "shizukuOld": "Old Shizuku version (<11), update it",
"shizukuOldAndroidWithADB": "Shizuku running on Android < 8.1 with ADB, update Android or use Sui instead", "shizukuOldAndroidWithADB": "Shizuku running on Android < 8.1 with ADB, update Android or use Sui instead",
"shizukuPretendToBeGooglePlay": "Set Google Play as the installation source", "shizukuPretendToBeGooglePlay": "Set Google Play as the installation source (if Shizuku is used)",
"useSystemFont": "Use the system font", "useSystemFont": "Use the system font",
"useVersionCodeAsOSVersion": "Use app versionCode as OS-detected version", "useVersionCodeAsOSVersion": "Use app versionCode as OS-detected version",
"requestHeader": "Request header", "requestHeader": "Request header",

View File

@@ -288,7 +288,7 @@
"shizukuBinderNotFound": "Совместимый сервис Shizuku не найден, возможно он не запущен", "shizukuBinderNotFound": "Совместимый сервис Shizuku не найден, возможно он не запущен",
"shizukuOld": "Устаревшая версия Shizuku (<11), обновите", "shizukuOld": "Устаревшая версия Shizuku (<11), обновите",
"shizukuOldAndroidWithADB": "Shizuku работает на Android < 8.1 с ADB, обновите Android или используйте Sui", "shizukuOldAndroidWithADB": "Shizuku работает на Android < 8.1 с ADB, обновите Android или используйте Sui",
"shizukuPretendToBeGooglePlay": "Указать Google Play как источник установки", "shizukuPretendToBeGooglePlay": "Указать Google Play как источник установки (если используется Shizuku)",
"useSystemFont": "Использовать системный шрифт", "useSystemFont": "Использовать системный шрифт",
"useVersionCodeAsOSVersion": "Использовать код версии приложения как версию, обнаруженную ОС", "useVersionCodeAsOSVersion": "Использовать код версии приложения как версию, обнаруженную ОС",
"requestHeader": "Заголовок запроса", "requestHeader": "Заголовок запроса",

View File

@@ -55,21 +55,21 @@ class _SettingsPageState extends State<SettingsPage> {
updateInterval = valInterpolated; updateInterval = valInterpolated;
updateIntervalLabel = plural('minute', valInterpolated); updateIntervalLabel = plural('minute', valInterpolated);
} else if (valInterpolated < 8 * 60) { } else if (valInterpolated < 8 * 60) {
int valRounded = (valInterpolated / 15).ceil() * 15; int valRounded = (valInterpolated / 15).floor() * 15;
updateInterval = valRounded; updateInterval = valRounded;
updateIntervalLabel = plural('hour', valRounded ~/ 60); updateIntervalLabel = plural('hour', valRounded ~/ 60);
int mins = valRounded % 60; int mins = valRounded % 60;
if (mins != 0) updateIntervalLabel += " ${plural('minute', mins)}"; if (mins != 0) updateIntervalLabel += " ${plural('minute', mins)}";
} else if (valInterpolated < 24 * 60) { } else if (valInterpolated < 24 * 60) {
int valRounded = (valInterpolated / 30).ceil() * 30; int valRounded = (valInterpolated / 30).floor() * 30;
updateInterval = valRounded; updateInterval = valRounded;
updateIntervalLabel = plural('hour', valRounded / 60); updateIntervalLabel = plural('hour', valRounded / 60);
} else if (valInterpolated < 7 * 24 * 60){ } else if (valInterpolated < 7 * 24 * 60){
int valRounded = (valInterpolated / (12 * 60)).ceil() * 12 * 60; int valRounded = (valInterpolated / (12 * 60)).floor() * 12 * 60;
updateInterval = valRounded; updateInterval = valRounded;
updateIntervalLabel = plural('day', valRounded / (24 * 60)); updateIntervalLabel = plural('day', valRounded / (24 * 60));
} else { } else {
int valRounded = (valInterpolated / (24 * 60)).ceil() * 24 * 60; int valRounded = (valInterpolated / (24 * 60)).floor() * 24 * 60;
updateInterval = valRounded; updateInterval = valRounded;
updateIntervalLabel = plural('day', valRounded ~/ (24 * 60)); updateIntervalLabel = plural('day', valRounded ~/ (24 * 60));
} }
@@ -501,24 +501,6 @@ class _SettingsPageState extends State<SettingsPage> {
}) })
], ],
), ),
if (settingsProvider.useShizuku)
Column(
children: [
height16,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(tr('shizukuPretendToBeGooglePlay'))),
Switch(
value: settingsProvider.pretendToBeGooglePlay,
onChanged: (value) {
settingsProvider.pretendToBeGooglePlay = value;
})
],
)
],
),
height32, height32,
Text( Text(
tr('sourceSpecific'), tr('sourceSpecific'),

View File

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

View File

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

View File

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