Evolver: Add spoofing features

* Add switch to spoof QSB
 * Bring back old Games spoof method
 * Drop PIF
 * Enable Photos spoof by default
 * Restart dialog upon toggle
 * Hide Pixel props switch on pixel 8+ devices
 * Hide tensor switch on tensor devices

Co-authored-by: minaripenguin <minaripenguin@users.noreply.github.com>
Co-authored-by: Alvin Francis <nivlafx@gmail.com>
Co-authored-by: Gustavo Mendes <gusttavo.me@outlook.com>
Signed-off-by: AnierinB <anierin@evolution-x.org>
This commit is contained in:
AnierinB
2024-04-24 03:03:29 -07:00
committed by Joey Huab
parent bb67204039
commit b6aee704ff
5 changed files with 289 additions and 0 deletions

View File

@@ -88,6 +88,31 @@
<string name="status_bar_tuner_title">Status bar tuner</string>
<string name="status_bar_tuner_summary">Choose which system icons can be shown</string>
<!-- Miscellaneous -->
<string name="miscellaneous_spoofing_category">Spoofing</string>
<!-- Miscellaneous/Spoofing -->
<string name="spoofing_title">Component spoofing</string>
<string name="spoofing_summary">Bypass app restrictions by spoofing components</string>
<string name="spoofing_system_wide_category">System-Wide</string>
<string name="spoofing_pixel_props_title">Pixel props</string>
<string name="spoofing_pixel_props_summary">Spoof a select group of Google apps to the latest Pixel device</string>
<string name="tensor_spoof_title">Spoof tensor features</string>
<string name="tensor_spoof_summary">Unlock tensor/pixel features</string>
<string name="spoofing_storage_encryption_title">Storage encryption</string>
<string name="spoofing_storage_encryption_summary">Spoof the device storage encryption status to \'Encrypted\'</string>
<string name="spoofing_app_specific_category">App-Specific</string>
<string name="spoofing_qsb_title">Google app</string>
<string name="spoofing_qsb_summary">Spoof the Google app to the latest Pixel device to unlock exclusive features</string>
<string name="spoofing_vending_title">Play Store</string>
<string name="spoofing_vending_summary">Spoof the Play Store to the latest Pixel device</string>
<string name="spoofing_photos_title">Google Photos</string>
<string name="spoofing_photos_summary">Spoof the Google Photos app as a Pixel XL</string>
<string name="spoofing_snap_title">Snapchat</string>
<string name="spoofing_snap_summary">Spoof Snapchat as a Pixel XL to fix possible chat issues</string>
<string name="gameprops_title">Unlock higher FPS in games</string>
<string name="gameprops_summary">Spoof your device as different model for specific games to unlock higher FPS</string>
<!-- About -->
<string name="about_info">Evolution X aims to provide users with a Pixel-like feel at first glance, with additional features at your disposal</string>
<string name="about_website_title">Website</string>

View File

@@ -9,4 +9,15 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/miscellaneous_title">
<PreferenceCategory
android:key="miscellaneous_spoofing_category"
android:title="@string/miscellaneous_spoofing_category">
<!-- Component spoofing -->
<Preference
android:key="spoofing"
android:title="@string/spoofing_title"
android:summary="@string/spoofing_summary"
android:fragment="org.evolution.settings.fragments.miscellaneous.Spoofing" />
</PreferenceCategory>
</PreferenceScreen>

76
res/xml/spoofing.xml Normal file
View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019-2024 Evolution X
SPDX-License-Identifier: Apache-2.0
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/spoofing_title">
<PreferenceCategory
android:key="spoofing_system_wide_category"
android:title="@string/spoofing_system_wide_category">
<!-- Pixel props -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops"
android:title="@string/spoofing_pixel_props_title"
android:summary="@string/spoofing_pixel_props_summary"
android:defaultValue="true" />
<!-- Tensor features -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.features.tensor"
android:title="@string/tensor_spoof_title"
android:summary="@string/tensor_spoof_summary"
android:defaultValue="false" />
<!-- Encryption -->
<org.evolution.settings.preferences.GlobalSettingSwitchPreference
android:key="spoofing_storage_encryption"
android:title="@string/spoofing_storage_encryption_title"
android:summary="@string/spoofing_storage_encryption_summary"
android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory
android:key="spoofing_app_specific_category"
android:title="@string/spoofing_app_specific_category">
<!-- Google App -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops.qsb"
android:title="@string/spoofing_qsb_title"
android:summary="@string/spoofing_qsb_summary"
android:defaultValue="false" />
<!-- Play Store -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops.vending"
android:title="@string/spoofing_vending_title"
android:summary="@string/spoofing_vending_summary"
android:defaultValue="false" />
<!-- Google Photos -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops.gphotos"
android:title="@string/spoofing_photos_title"
android:summary="@string/spoofing_photos_summary"
android:defaultValue="true" />
<!-- Games FPS -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops.games"
android:title="@string/gameprops_title"
android:summary="@string/gameprops_summary"
android:defaultValue="true" />
<!-- Snapchat -->
<org.evolution.settings.preferences.SystemPropertySwitchPreference
android:key="persist.sys.pixelprops.snap"
android:title="@string/spoofing_snap_title"
android:summary="@string/spoofing_snap_summary"
android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -0,0 +1,170 @@
/*
* Copyright (C) 2019-2024 The Evolution X Project
* SPDX-License-Identifier: Apache-2.0
*/
package org.evolution.settings.fragments.miscellaneous;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemProperties;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.android.SystemRestartUtils;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settingslib.search.SearchIndexable;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.evolution.settings.preferences.SystemPropertySwitchPreference;
import org.evolution.settings.utils.DeviceUtils;
@SearchIndexable
public class Spoofing extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "Spoofing";
private static final String KEY_SYSTEM_WIDE_CATEGORY = "spoofing_system_wide_category";
private static final String SYS_GOOGLE_SPOOF = "persist.sys.pixelprops";
private static final String SYS_GAMEPROP_SPOOF = "persist.sys.pixelprops.games";
private static final String SYS_GPHOTOS_SPOOF = "persist.sys.pixelprops.gphotos";
private static final String SYS_QSB_SPOOF = "persist.sys.pixelprops.qsb";
private static final String SYS_SNAP_SPOOF = "persist.sys.pixelprops.snap";
private static final String SYS_VENDING_SPOOF = "persist.sys.pixelprops.vending";
private static final String SYS_ENABLE_TENSOR_FEATURES = "persist.sys.features.tensor";
private PreferenceCategory mSystemWideCategory;
private SystemPropertySwitchPreference mGoogleSpoof;
private SystemPropertySwitchPreference mGamePropsSpoof;
private SystemPropertySwitchPreference mGphotosSpoof;
private SystemPropertySwitchPreference mQsbSpoof;
private SystemPropertySwitchPreference mSnapSpoof;
private SystemPropertySwitchPreference mVendingSpoof;
private SystemPropertySwitchPreference mTensorFeaturesToggle;
private Handler mHandler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHandler = new Handler();
addPreferencesFromResource(R.xml.spoofing);
final Context context = getContext();
final ContentResolver resolver = context.getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources resources = context.getResources();
mSystemWideCategory = (PreferenceCategory) findPreference(KEY_SYSTEM_WIDE_CATEGORY);
mGamePropsSpoof = (SystemPropertySwitchPreference) findPreference(SYS_GAMEPROP_SPOOF);
mGphotosSpoof = (SystemPropertySwitchPreference) findPreference(SYS_GPHOTOS_SPOOF);
mGoogleSpoof = (SystemPropertySwitchPreference) findPreference(SYS_GOOGLE_SPOOF);
mQsbSpoof = (SystemPropertySwitchPreference) findPreference(SYS_QSB_SPOOF);
mSnapSpoof = (SystemPropertySwitchPreference) findPreference(SYS_SNAP_SPOOF);
mVendingSpoof = (SystemPropertySwitchPreference) findPreference(SYS_VENDING_SPOOF);
mTensorFeaturesToggle = (SystemPropertySwitchPreference) findPreference(SYS_ENABLE_TENSOR_FEATURES);
String model = SystemProperties.get("ro.product.model");
boolean isTensorDevice = model.matches("Pixel [6-9][a-zA-Z ]*");
if (DeviceUtils.isCurrentlySupportedPixel()) {
mGoogleSpoof.setDefaultValue(false);
if (isMainlineTensorModel(model)) {
mSystemWideCategory.removePreference(mGoogleSpoof);
}
}
if (isTensorDevice) {
mSystemWideCategory.removePreference(mTensorFeaturesToggle);
}
mGoogleSpoof.setOnPreferenceChangeListener(this);
mGphotosSpoof.setOnPreferenceChangeListener(this);
mGamePropsSpoof.setOnPreferenceChangeListener(this);
mQsbSpoof.setOnPreferenceChangeListener(this);
mSnapSpoof.setOnPreferenceChangeListener(this);
mVendingSpoof.setOnPreferenceChangeListener(this);
mTensorFeaturesToggle.setOnPreferenceChangeListener(this);
}
private boolean isMainlineTensorModel(String model) {
return model.matches("Pixel [8-9][a-zA-Z ]*");
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final Context context = getContext();
final ContentResolver resolver = context.getContentResolver();
if (preference == mGoogleSpoof
|| preference == mGphotosSpoof
|| preference == mGamePropsSpoof
|| preference == mQsbSpoof
|| preference == mSnapSpoof
|| preference == mVendingSpoof) {
SystemRestartUtils.showSystemRestartDialog(getContext());
return true;
}
if (preference == mTensorFeaturesToggle) {
boolean enabled = (Boolean) newValue;
SystemProperties.set(SYS_ENABLE_TENSOR_FEATURES, enabled ? "true" : "false");
SystemRestartUtils.showSystemRestartDialog(getContext());
return true;
}
return false;
}
@Override
public int getMetricsCategory() {
return MetricsEvent.EVOLVER;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.spoofing) {
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
final Resources resources = context.getResources();
return keys;
}
};
}

View File

@@ -36,6 +36,8 @@ import static org.lineageos.internal.util.DeviceKeysConstants.*;
import androidx.annotation.NonNull;
import java.util.Arrays;
public class DeviceUtils {
/* returns whether the device has a centered display cutout or not. */
@@ -282,4 +284,9 @@ public class DeviceUtils {
return NAV_BAR_MODE_GESTURAL == context.getResources().getInteger(
com.android.internal.R.integer.config_navBarInteractionMode);
}
public static boolean isCurrentlySupportedPixel() {
boolean isPixelDevice = SystemProperties.get("ro.product.model").matches("Pixel [3-9][a-zA-Z ]*");
return isPixelDevice;
}
}