mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-11-03 23:03:29 +01:00 
			
		
		
		
	Make pretending to be a Google Play setting per app based⚙️
This commit is contained in:
		@@ -288,7 +288,7 @@
 | 
			
		||||
    "shizukuBinderNotFound": "Shizuku service not found, probably it's not launched",
 | 
			
		||||
    "shizukuOld": "Old Shizuku version (<11), update it",
 | 
			
		||||
    "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",
 | 
			
		||||
    "useVersionCodeAsOSVersion": "Use app versionCode as OS-detected version",
 | 
			
		||||
    "requestHeader": "Request header",
 | 
			
		||||
 
 | 
			
		||||
@@ -288,7 +288,7 @@
 | 
			
		||||
    "shizukuBinderNotFound": "Совместимый сервис Shizuku не найден, возможно он не запущен",
 | 
			
		||||
    "shizukuOld": "Устаревшая версия Shizuku (<11), обновите",
 | 
			
		||||
    "shizukuOldAndroidWithADB": "Shizuku работает на Android < 8.1 с ADB, обновите Android или используйте Sui",
 | 
			
		||||
    "shizukuPretendToBeGooglePlay": "Указать Google Play как источник установки",
 | 
			
		||||
    "shizukuPretendToBeGooglePlay": "Указать Google Play как источник установки (если используется Shizuku)",
 | 
			
		||||
    "useSystemFont": "Использовать системный шрифт",
 | 
			
		||||
    "useVersionCodeAsOSVersion": "Использовать код версии приложения как версию, обнаруженную ОС",
 | 
			
		||||
    "requestHeader": "Заголовок запроса",
 | 
			
		||||
 
 | 
			
		||||
@@ -55,21 +55,21 @@ class _SettingsPageState extends State<SettingsPage> {
 | 
			
		||||
      updateInterval = valInterpolated;
 | 
			
		||||
      updateIntervalLabel = plural('minute', valInterpolated);
 | 
			
		||||
    } else if (valInterpolated < 8 * 60) {
 | 
			
		||||
      int valRounded = (valInterpolated / 15).ceil() * 15;
 | 
			
		||||
      int valRounded = (valInterpolated / 15).floor() * 15;
 | 
			
		||||
      updateInterval = valRounded;
 | 
			
		||||
      updateIntervalLabel = plural('hour', valRounded ~/ 60);
 | 
			
		||||
      int mins = valRounded % 60;
 | 
			
		||||
      if (mins != 0) updateIntervalLabel += " ${plural('minute', mins)}";
 | 
			
		||||
    } else if (valInterpolated < 24 * 60) {
 | 
			
		||||
      int valRounded = (valInterpolated / 30).ceil() * 30;
 | 
			
		||||
      int valRounded = (valInterpolated / 30).floor() * 30;
 | 
			
		||||
      updateInterval = valRounded;
 | 
			
		||||
      updateIntervalLabel = plural('hour', valRounded / 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;
 | 
			
		||||
      updateIntervalLabel = plural('day', valRounded / (24 * 60));
 | 
			
		||||
    } else {
 | 
			
		||||
      int valRounded = (valInterpolated / (24 * 60)).ceil() * 24 * 60;
 | 
			
		||||
      int valRounded = (valInterpolated / (24 * 60)).floor() * 24 * 60;
 | 
			
		||||
      updateInterval = valRounded;
 | 
			
		||||
      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,
 | 
			
		||||
                            Text(
 | 
			
		||||
                              tr('sourceSpecific'),
 | 
			
		||||
 
 | 
			
		||||
@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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];
 | 
			
		||||
 
 | 
			
		||||
@@ -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'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user