Add switch to disable hidden api bypass

ElderDrivers/EdXposed@00e18cf
This commit is contained in:
NekoInverter 2020-04-06 18:39:28 +08:00
parent 686c281a6f
commit b0c865a7d0
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
6 changed files with 57 additions and 15 deletions

View File

@ -30,8 +30,8 @@ android {
minSdkVersion 26
//noinspection OldTargetApi
targetSdkVersion 27
versionCode 457000
versionName "4.5.7.1"
versionCode 457020
versionName "4.5.7.2"
signingConfig signingConfigs.release
}
buildTypes {

View File

@ -20,6 +20,6 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class org.meowcat.edxposed.manager.util.json.**{public *; }
-keep class org.meowcat.edxposed.manager.xposed.**{public *; }
-keep class org.meowcat.edxposed.manager.xposed.**{ *; }
-keep class de.robv.android.xposed.installer.**{public *; }
-repackageclasses ''

View File

@ -116,15 +116,16 @@ public class SettingsActivity extends BaseActivity {
public static class SettingsFragment extends PreferenceFragmentCompat {
private static final File pretendXposedInstallerFlag = new File(XposedApp.BASE_DIR + "conf/pretend_xposed_installer");
private static final File hideEdXposedManagerFlag = new File(XposedApp.BASE_DIR + "conf/hide_edxposed_manager");
static final File disableResourcesFlag = new File(XposedApp.BASE_DIR + "conf/disable_resources");
static final File dynamicModulesFlag = new File(XposedApp.BASE_DIR + "conf/dynamicmodules");
static final File deoptBootFlag = new File(XposedApp.BASE_DIR + "conf/deoptbootimage");
static final File whiteListModeFlag = new File(XposedApp.BASE_DIR + "conf/usewhitelist");
static final File blackWhiteListModeFlag = new File(XposedApp.BASE_DIR + "conf/blackwhitelist");
static final File disableVerboseLogsFlag = new File(XposedApp.BASE_DIR + "conf/disable_verbose_log");
static final File disableModulesLogsFlag = new File(XposedApp.BASE_DIR + "conf/disable_modules_log");
static final File verboseLogProcessID = new File(XposedApp.BASE_DIR + "log/all.pid");
static final File modulesLogProcessID = new File(XposedApp.BASE_DIR + "log/error.pid");
private static final File disableHiddenAPIBypassFlag = new File(XposedApp.BASE_DIR + "conf/disable_hidden_api_bypass");
private static final File disableResourcesFlag = new File(XposedApp.BASE_DIR + "conf/disable_resources");
private static final File dynamicModulesFlag = new File(XposedApp.BASE_DIR + "conf/dynamicmodules");
private static final File deoptBootFlag = new File(XposedApp.BASE_DIR + "conf/deoptbootimage");
private static final File whiteListModeFlag = new File(XposedApp.BASE_DIR + "conf/usewhitelist");
private static final File blackWhiteListModeFlag = new File(XposedApp.BASE_DIR + "conf/blackwhitelist");
private static final File disableVerboseLogsFlag = new File(XposedApp.BASE_DIR + "conf/disable_verbose_log");
private static final File disableModulesLogsFlag = new File(XposedApp.BASE_DIR + "conf/disable_modules_log");
private static final File verboseLogProcessID = new File(XposedApp.BASE_DIR + "log/all.pid");
private static final File modulesLogProcessID = new File(XposedApp.BASE_DIR + "log/error.pid");
@SuppressLint({"WorldReadableFiles", "WorldWriteableFiles"})
static void setFilePermissionsFromMode(String name) {
@ -559,6 +560,37 @@ public class SettingsActivity extends BaseActivity {
return (enabled == hideEdXposedManagerFlag.exists());
});
SwitchPreferenceCompat prefDisableHiddenAPIBypass = findPreference("disable_hidden_api_bypass");
Objects.requireNonNull(prefDisableHiddenAPIBypass).setChecked(disableHiddenAPIBypassFlag.exists());
prefDisableHiddenAPIBypass.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
if (enabled) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(disableHiddenAPIBypassFlag.getPath());
setFilePermissionsFromMode(disableHiddenAPIBypassFlag.getPath());
} catch (FileNotFoundException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
try {
disableHiddenAPIBypassFlag.createNewFile();
} catch (IOException e1) {
Toast.makeText(getActivity(), e1.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
}
} else {
disableHiddenAPIBypassFlag.delete();
}
return (enabled == disableHiddenAPIBypassFlag.exists());
});
}
}

View File

@ -108,7 +108,7 @@
<string name="settings_release_type">要显示的版本</string>
<string name="settings_group_framework">框架</string>
<string name="settings_disable_resources">禁用资源钩子</string>
<string name="settings_disable_resources_summary">解决与主题引擎的冲突\n<b>警告: </b> 启用该选项将导致修改资源的模块无法工作</string>
<string name="settings_disable_resources_summary">解决与主题引擎的冲突 <b>警告: </b> 启用该选项将导致修改资源的模块无法工作</string>
<string name="settings_group_app">应用</string>
<string name="settings_theme">主题</string>
<string name="settings_theme_light">亮色</string>
@ -313,4 +313,6 @@
<string name="settings_summary_pretend_xposed_installer">假装已安装 Xposed Installer 来使一些过时但有用的模块正常工作\n仅对「模块」中已启用模块生效\n注开启此功能可能会被某些软件如 RootBeer检测到 EdXposed</string>
<string name="settings_title_hide_edxposed_manager">隐藏 EdXposed Manager</string>
<string name="settings_summary_hide_edxposed_manager">防止软件检测到 EdXposed Manager\n注模块可能无法正常打开 EdXposed Manager 界面,系统中关于 EdXposed Manager 的一些功能可能无法正常使用</string>
<string name="settings_title_disable_hidden_api_bypass">禁用绕过隐藏 API 的限制</string>
<string name="settings_summary_disable_hidden_api_bypass">禁用绕过隐藏 API 的限制将会通过某些检测如Snapchat\n<b>警告:</b> 启用此选项可能会使某些功能无法正常工作,或出现一些其他问题</string>
</resources>

View File

@ -344,4 +344,6 @@
<string name="settings_summary_pretend_xposed_installer">Pretend that Xposed Installer is installed to make some outdated but useful modules work\nOnly work for the enabled modules in \"Modules\"\nWARNING: Some software (eg. RootBeer) may detect that EdXposed when this function is turned on</string>
<string name="settings_title_hide_edxposed_manager">Hide EdXposed Manager</string>
<string name="settings_summary_hide_edxposed_manager">Prevent the software from detecting EdXposed Manager\nWARNING: Modules may not be able to start the EdXposed Manager UI properly, some fratures of EdXposed Manager in the system may not work properly</string>
<string name="settings_title_disable_hidden_api_bypass">Disable hidden API restrictions bypass</string>
<string name="settings_summary_disable_hidden_api_bypass">Disable hidden API restrictions bypass will pass some detection (eg Snapchat), these APIs are disabled by default\n<b>WARNING:</b> Enable this option may cause some features do not work properly, or some other problems</string>
</resources>

View File

@ -160,10 +160,16 @@
android:title="@string/pref_title_enable_boot_image_deopt"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="disable_hidden_api_bypass"
android:summary="@string/settings_summary_disable_hidden_api_bypass"
android:title="@string/settings_title_disable_hidden_api_bypass"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="disable_resources"
android:persistent="false"
android:summary="@string/settings_disable_resources_summary"
android:title="@string/settings_disable_resources"
app:iconSpaceReserved="false" />
@ -196,8 +202,8 @@
<Preference
android:key="enhancement_status"
android:title="@string/settings_title_enhancement"
android:summary="@string/settings_summary_enhancement"
android:title="@string/settings_title_enhancement"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat