From 0d052b6a4b702d10db19f741ec411e991d970c6d Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Tue, 6 Sep 2022 18:00:26 +0700 Subject: [PATCH] Cherish: [SQUASH] User toggle for unlimited photos storage and GamesProp [2/2][2/2] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: spezi77 Signed-off-by: Hưng Phan --- res/values/cherish_strings.xml | 8 +++++ res/xml/cherish_settings_misc.xml | 12 ++++++++ .../settings/fragments/MiscSettings.java | 30 +++++++++++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index 022f89b..3b55baf 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -459,4 +459,12 @@ Users Logout Emergency + + + Unlock higher FPS in games + Spoof your device as a different model for specific games to unlock higher FPS + + + Unlimited Photos storage + Spoof your device as Pixel XL for Google Photos app only to provide unlimited storage for backup diff --git a/res/xml/cherish_settings_misc.xml b/res/xml/cherish_settings_misc.xml index 1b8c42c..31981dd 100644 --- a/res/xml/cherish_settings_misc.xml +++ b/res/xml/cherish_settings_misc.xml @@ -31,4 +31,16 @@ android:summary="@string/laboratory_ignore_window_secure_summary" android:defaultValue="false"/> + + + + + diff --git a/src/com/cherish/settings/fragments/MiscSettings.java b/src/com/cherish/settings/fragments/MiscSettings.java index f811e7f..35b3b22 100644 --- a/src/com/cherish/settings/fragments/MiscSettings.java +++ b/src/com/cherish/settings/fragments/MiscSettings.java @@ -7,6 +7,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; +import android.os.SystemProperties; import android.content.Context; import android.content.ContentResolver; import android.content.res.Resources; @@ -44,6 +45,14 @@ import java.util.List; @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) public class MiscSettings extends SettingsPreferenceFragment implements OnPreferenceChangeListener { + private static final String KEY_GAMES_SPOOF = "use_games_spoof"; + private static final String KEY_PHOTOS_SPOOF = "use_photos_spoof"; + + private static final String SYS_GAMES_SPOOF = "persist.sys.pixelprops.games"; + private static final String SYS_PHOTOS_SPOOF = "persist.sys.pixelprops.gphotos"; + + private SwitchPreference mGamesSpoof; + private SwitchPreference mPhotosSpoof; @Override public void onCreate(Bundle icicle) { @@ -61,11 +70,28 @@ public class MiscSettings extends SettingsPreferenceFragment implements } catch (NameNotFoundException e) { e.printStackTrace(); } + + mGamesSpoof = (SwitchPreference) findPreference(KEY_GAMES_SPOOF); + mGamesSpoof.setChecked(SystemProperties.getBoolean(SYS_GAMES_SPOOF, false)); + mGamesSpoof.setOnPreferenceChangeListener(this); + + mPhotosSpoof = (SwitchPreference) findPreference(KEY_PHOTOS_SPOOF); + mPhotosSpoof.setChecked(SystemProperties.getBoolean(SYS_PHOTOS_SPOOF, true)); + mPhotosSpoof.setOnPreferenceChangeListener(this); } - @Override - public boolean onPreferenceChange(Preference preference, Object objValue) { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (preference == mGamesSpoof) { + boolean value = (Boolean) newValue; + SystemProperties.set(SYS_GAMES_SPOOF, value ? "true" : "false"); + return true; + } else if (preference == mPhotosSpoof) { + boolean value = (Boolean) newValue; + SystemProperties.set(SYS_PHOTOS_SPOOF, value ? "true" : "false"); + return true; + } return false; }