Enhancement module
This commit is contained in:
parent
106da8e752
commit
2c563ec9e2
|
|
@ -24,15 +24,14 @@ android {
|
|||
}
|
||||
}
|
||||
compileSdkVersion 29
|
||||
//noinspection GradleDependency
|
||||
buildToolsVersion "29.0.2"
|
||||
buildToolsVersion "29.0.3"
|
||||
defaultConfig {
|
||||
applicationId "org.meowcat.edxposed.manager"
|
||||
minSdkVersion 26
|
||||
//noinspection OldTargetApi
|
||||
targetSdkVersion 27
|
||||
versionCode 45611
|
||||
versionName "4.5.6.1"
|
||||
versionCode 457000
|
||||
versionName "4.5.7.1"
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
buildTypes {
|
||||
|
|
@ -73,6 +72,7 @@ dependencies {
|
|||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.takisoft.preferencex:preferencex:1.1.0'
|
||||
implementation 'com.takisoft.preferencex:preferencex-colorpicker:1.1.0'
|
||||
implementation 'com.github.NekoInverter.preferencex-android:preferencex-simplemenu:88f93154b2'
|
||||
implementation 'tech.rectifier.preferencex-android:preferencex-simplemenu:88f93154b2'
|
||||
implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar'
|
||||
compileOnly 'de.robv.android.xposed:api:82'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,18 @@
|
|||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<meta-data
|
||||
android:name="xposedmodule"
|
||||
android:value="true" />
|
||||
|
||||
<meta-data
|
||||
android:name="xposeddescription"
|
||||
android:value="@string/xposed_description" />
|
||||
|
||||
<meta-data
|
||||
android:name="xposedminversion"
|
||||
android:value="82" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -44,6 +44,10 @@ public class StatusInstallerFragment extends Fragment {
|
|||
.setNegativeButton(R.string.later, null).show());
|
||||
}
|
||||
|
||||
public static boolean isEnhancementEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void update(Context context) {
|
||||
Uri uri = Uri.parse(updateLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
|
|
@ -103,7 +107,12 @@ public class StatusInstallerFragment extends Fragment {
|
|||
installedXposedVersion = null;
|
||||
}
|
||||
|
||||
String mAppVer = "v" + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")";
|
||||
String mAppVer;
|
||||
if (isEnhancementEnabled()) {
|
||||
mAppVer = String.format("v%s (%s) (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, getString(R.string.status_enhancement));
|
||||
} else {
|
||||
mAppVer = String.format("v%s (%s)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
binding.manager.setText(mAppVer);
|
||||
if (installedXposedVersion != null) {
|
||||
int installedXposedVersionInt = extractIntPart(installedXposedVersion);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import androidx.fragment.app.FragmentManager;
|
|||
|
||||
import org.meowcat.edxposed.manager.BuildConfig;
|
||||
import org.meowcat.edxposed.manager.R;
|
||||
import org.meowcat.edxposed.manager.StatusInstallerFragment;
|
||||
import org.meowcat.edxposed.manager.XposedApp;
|
||||
import org.meowcat.edxposed.manager.util.CompileUtil;
|
||||
|
||||
|
|
@ -26,6 +27,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
|
@ -44,7 +46,7 @@ public class AppHelper {
|
|||
private static final String WHITE_LIST_MODE = "conf/usewhitelist";
|
||||
private static final String BLACK_LIST_MODE = "conf/blackwhitelist";
|
||||
|
||||
private static final List<String> FORCE_WHITE_LIST = new ArrayList<>(Collections.singletonList(BuildConfig.APPLICATION_ID));
|
||||
private static final List<String> FORCE_WHITE_LIST = new ArrayList<>(StatusInstallerFragment.isEnhancementEnabled() ? Arrays.asList(BuildConfig.APPLICATION_ID, "android") : Collections.singletonList(BuildConfig.APPLICATION_ID));
|
||||
public static List<String> FORCE_WHITE_LIST_MODULE = new ArrayList<>(FORCE_WHITE_LIST);
|
||||
|
||||
@SuppressWarnings("OctalInteger")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package org.meowcat.edxposed.manager.xposed;
|
||||
import android.os.Build;
|
||||
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||
import de.robv.android.xposed.XC_MethodHook;
|
||||
import de.robv.android.xposed.XC_MethodReplacement;
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
import de.robv.android.xposed.XposedHelpers;
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
||||
|
||||
import static org.meowcat.edxposed.manager.BuildConfig.APPLICATION_ID;
|
||||
|
||||
public class Enhancement implements IXposedHookLoadPackage {
|
||||
|
||||
private static final String LEGACY_INSTALLER = "de.robv.android.xposed.installer";
|
||||
|
||||
private static void hookAllMethods(String className, ClassLoader classLoader, String methodName, XC_MethodHook callback) {
|
||||
try {
|
||||
Class<?> hookClass = XposedHelpers.findClassIfExists(className, classLoader);
|
||||
if (hookClass == null || XposedBridge.hookAllMethods(hookClass, methodName, callback).size() == 0)
|
||||
XposedBridge.log("Failed to hook " + methodName + " method in " + className);
|
||||
} catch (Throwable t) {
|
||||
XposedBridge.log(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
|
||||
if (lpparam.packageName.equals("android")) {
|
||||
// Hook PM to pretend to have legacy Xposed Installer installed
|
||||
hookAllMethods("com.android.server.pm.PackageManagerService", lpparam.classLoader, "getApplicationInfo", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void beforeHookedMethod(MethodHookParam param) {
|
||||
if (param.args != null && param.args[0] != null) {
|
||||
if (param.args[0].equals(LEGACY_INSTALLER)) {
|
||||
param.args[0] = APPLICATION_ID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
hookAllMethods("com.android.server.pm.PackageManagerService", lpparam.classLoader, "getPackageInfo", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void beforeHookedMethod(MethodHookParam param) {
|
||||
if (param.args != null && param.args[0] != null) {
|
||||
if (param.args[0].equals(LEGACY_INSTALLER)) {
|
||||
param.args[0] = APPLICATION_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Hook AM to remove restrict of EdXposed Manager
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
hookAllMethods("com.android.server.am.ActivityManagerService", lpparam.classLoader, "appRestrictedInBackgroundLocked", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void afterHookedMethod(MethodHookParam param) {
|
||||
if (param.args != null && param.args[1] != null) {
|
||||
if (param.args[1].equals(APPLICATION_ID)) {
|
||||
param.setResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
hookAllMethods("com.android.server.am.ActivityManagerService", lpparam.classLoader, "appServicesRestrictedInBackgroundLocked", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void afterHookedMethod(MethodHookParam param) {
|
||||
if (param.args != null && param.args[1] != null) {
|
||||
if (param.args[1].equals(APPLICATION_ID)) {
|
||||
param.setResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
hookAllMethods("com.android.server.am.ActivityManagerService", lpparam.classLoader, "getAppStartModeLocked", new XC_MethodHook() {
|
||||
@Override
|
||||
protected void afterHookedMethod(MethodHookParam param) {
|
||||
if (param.args != null && param.args[1] != null) {
|
||||
if (param.args[1].equals(APPLICATION_ID)) {
|
||||
param.setResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (lpparam.packageName.equals(APPLICATION_ID)) {
|
||||
// Make sure Xposed work
|
||||
XposedHelpers.findAndHookMethod("org.meowcat.edxposed.manager.StatusInstallerFragment", lpparam.classLoader, "isEnhancementEnabled", XC_MethodReplacement.returnConstant(true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -302,4 +302,6 @@
|
|||
<string name="colorized_action_bar">着色应用栏</string>
|
||||
<string name="settings_group_theme">主题</string>
|
||||
<string name="material_design_2">惨白设计</string>
|
||||
<string name="xposed_description">启用 EdXposed 的增强功能:\n判断 Xposed 是否正常工作\n移除针对 EdXposed 的后台限制\n假装安装了 Xposed Installer</string>
|
||||
<string name="status_enhancement">增强模式已激活</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -333,4 +333,6 @@
|
|||
<string name="colorized_action_bar">Colorized action bar</string>
|
||||
<string name="settings_group_theme">Theme</string>
|
||||
<string name="material_design_2">Material Design 2</string>
|
||||
<string name="xposed_description">Enable EdXposed enhancements:\nRemove background restrictions on EdXposed\nDetermine if Xposed is working properly\nPretend to have Xposed Installer installed</string>
|
||||
<string name="status_enhancement">Enhancement mode</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue