Remove xposedResources
This commit is contained in:
parent
53fec857a0
commit
b52c40615e
|
|
@ -67,7 +67,7 @@ import de.robv.android.xposed.XposedInit;
|
||||||
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
|
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
|
||||||
import de.robv.android.xposed.callbacks.XC_LayoutInflated.LayoutInflatedParam;
|
import de.robv.android.xposed.callbacks.XC_LayoutInflated.LayoutInflatedParam;
|
||||||
import de.robv.android.xposed.callbacks.XCallback;
|
import de.robv.android.xposed.callbacks.XCallback;
|
||||||
import io.github.libxposed.XposedResources;
|
import xposed.dummy.XResourcesSuperClass;
|
||||||
import xposed.dummy.XTypedArraySuperClass;
|
import xposed.dummy.XTypedArraySuperClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -78,7 +78,7 @@ import xposed.dummy.XTypedArraySuperClass;
|
||||||
* be set using the methods made available via the API methods in this class.
|
* be set using the methods made available via the API methods in this class.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("JniMissingFunction")
|
@SuppressWarnings("JniMissingFunction")
|
||||||
public class XResources extends XposedResources {
|
public class XResources extends XResourcesSuperClass {
|
||||||
private static final SparseArray<HashMap<String, Object>> sReplacements = new SparseArray<>();
|
private static final SparseArray<HashMap<String, Object>> sReplacements = new SparseArray<>();
|
||||||
private static final SparseArray<HashMap<String, ResourceNames>> sResourceNames = new SparseArray<>();
|
private static final SparseArray<HashMap<String, ResourceNames>> sResourceNames = new SparseArray<>();
|
||||||
|
|
||||||
|
|
@ -160,7 +160,6 @@ public class XResources extends XposedResources {
|
||||||
* Returns the name of the package that these resources belong to, or "android" for system resources.
|
* Returns the name of the package that these resources belong to, or "android" for system resources.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
return mPackageName;
|
return mPackageName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,8 +207,6 @@ public final class XposedInit {
|
||||||
resparam.packageName = packageName;
|
resparam.packageName = packageName;
|
||||||
resparam.res = newRes;
|
resparam.res = newRes;
|
||||||
XCallback.callAll(resparam);
|
XCallback.callAll(resparam);
|
||||||
|
|
||||||
LSPosedContext.callOnResourceLoaded(resparam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
param.setResult(newRes);
|
param.setResult(newRes);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
||||||
import io.github.libxposed.XposedModuleInterface;
|
import io.github.libxposed.XposedModuleInterface;
|
||||||
import io.github.libxposed.XposedResources;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is only used for internal purposes, except for the {@link InitPackageResourcesParam}
|
* This class is only used for internal purposes, except for the {@link InitPackageResourcesParam}
|
||||||
|
|
@ -60,7 +59,7 @@ public abstract class XC_InitPackageResources extends XCallback implements IXpos
|
||||||
/**
|
/**
|
||||||
* Wraps information about the resources being initialized.
|
* Wraps information about the resources being initialized.
|
||||||
*/
|
*/
|
||||||
public static final class InitPackageResourcesParam extends XCallback.Param implements XposedModuleInterface.ResourcesLoadedParam {
|
public static final class InitPackageResourcesParam extends XCallback.Param {
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|
@ -78,24 +77,6 @@ public abstract class XC_InitPackageResources extends XCallback implements IXpos
|
||||||
* {@link XResources#setReplacement(String, String, String, Object)}.
|
* {@link XResources#setReplacement(String, String, String, Object)}.
|
||||||
*/
|
*/
|
||||||
public XResources res;
|
public XResources res;
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public XposedResources getResources() {
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Bundle getExtras() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import de.robv.android.xposed.XposedBridge;
|
import de.robv.android.xposed.XposedBridge;
|
||||||
import de.robv.android.xposed.XposedHelpers;
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
import de.robv.android.xposed.XposedInit;
|
|
||||||
import io.github.libxposed.XposedContext;
|
import io.github.libxposed.XposedContext;
|
||||||
import io.github.libxposed.XposedModule;
|
import io.github.libxposed.XposedModule;
|
||||||
import io.github.libxposed.XposedModuleInterface;
|
import io.github.libxposed.XposedModuleInterface;
|
||||||
|
|
@ -103,16 +102,6 @@ public class LSPosedContext extends XposedContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callOnResourceLoaded(XposedModuleInterface.ResourcesLoadedParam param) {
|
|
||||||
for (XposedModule module : modules) {
|
|
||||||
try {
|
|
||||||
module.onResourceLoaded(param);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
Log.e(TAG, "Error when calling onResourceLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean loadModule(ActivityThread at, Module module) {
|
public static boolean loadModule(ActivityThread at, Module module) {
|
||||||
try {
|
try {
|
||||||
Log.d(TAG, "Loading module " + module.packageName);
|
Log.d(TAG, "Loading module " + module.packageName);
|
||||||
|
|
@ -167,9 +156,6 @@ public class LSPosedContext extends XposedContext {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (moduleClass.getMethod("onResourceLoaded", XposedModuleInterface.ResourcesLoadedParam.class).getDeclaringClass() != XposedModule.class) {
|
|
||||||
XposedInit.hookResources();
|
|
||||||
}
|
|
||||||
var moduleEntry = moduleClass.getConstructor(XposedContext.class, XposedModuleInterface.ModuleLoadedParam.class);
|
var moduleEntry = moduleClass.getConstructor(XposedContext.class, XposedModuleInterface.ModuleLoadedParam.class);
|
||||||
var moduleContext = (XposedModule) moduleEntry.newInstance(ctx, new XposedModuleInterface.ModuleLoadedParam() {
|
var moduleContext = (XposedModule) moduleEntry.newInstance(ctx, new XposedModuleInterface.ModuleLoadedParam() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
id("com.android.library")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "io.github.libxposed"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("androidx.annotation:annotation:1.5.0")
|
compileOnly("androidx.annotation:annotation:1.5.0")
|
||||||
compileOnly(project(":stubs"))
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest/>
|
||||||
|
|
@ -11,9 +11,4 @@ public abstract class XposedModule extends XposedContextWrapper implements Xpose
|
||||||
public void onPackageLoaded(@NonNull PackageLoadedParam param) {
|
public void onPackageLoaded(@NonNull PackageLoadedParam param) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResourceLoaded(@NonNull ResourcesLoadedParam param) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,5 @@ public interface XposedModuleInterface {
|
||||||
Bundle getExtras();
|
Bundle getExtras();
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ResourcesLoadedParam {
|
|
||||||
@NonNull
|
|
||||||
String getPackageName();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
XposedResources getResources();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Bundle getExtras();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onPackageLoaded(@NonNull PackageLoadedParam param);
|
void onPackageLoaded(@NonNull PackageLoadedParam param);
|
||||||
|
|
||||||
void onResourceLoaded(@NonNull ResourcesLoadedParam param);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package io.github.libxposed;
|
|
||||||
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
|
|
||||||
public abstract class XposedResources extends Resources implements XposedResourcesInterface {
|
|
||||||
public XposedResources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
|
|
||||||
super(assets, metrics, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XposedResources(ClassLoader classLoader) {
|
|
||||||
super(classLoader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package io.github.libxposed;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
public interface XposedResourcesInterface {
|
|
||||||
@NonNull String getPackageName();
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
subprojects {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
plugins {
|
||||||
|
id("com.android.library") version "7.3.1" apply false
|
||||||
|
}
|
||||||
|
|
@ -2,5 +2,4 @@ rootProject.name = "libxposed"
|
||||||
|
|
||||||
include(
|
include(
|
||||||
":api",
|
":api",
|
||||||
":stubs",
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
plugins {
|
|
||||||
`java-library`
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.content;
|
|
||||||
|
|
||||||
public abstract class Context {
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package android.content;
|
|
||||||
|
|
||||||
public class ContextWrapper extends Context {
|
|
||||||
public ContextWrapper(Context base) {
|
|
||||||
throw new UnsupportedOperationException("STUB");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void attachBaseContext(Context base) {
|
|
||||||
throw new UnsupportedOperationException("STUB");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Context getBaseContext() {
|
|
||||||
throw new UnsupportedOperationException("SUTB");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.content.pm;
|
|
||||||
|
|
||||||
public class ApplicationInfo {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.content.res;
|
|
||||||
|
|
||||||
public class AssetManager {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.content.res;
|
|
||||||
|
|
||||||
public class Configuration {
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
package android.content.res;
|
|
||||||
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
|
|
||||||
public class Resources {
|
|
||||||
protected Resources(ClassLoader classLoader) {
|
|
||||||
throw new UnsupportedOperationException("STUB");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) {
|
|
||||||
throw new UnsupportedOperationException("STUB");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package android.content.res;
|
|
||||||
|
|
||||||
public class TypedArray {
|
|
||||||
protected TypedArray(Resources resources) {
|
|
||||||
throw new UnsupportedOperationException("STUB");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.os;
|
|
||||||
|
|
||||||
public class Bundle {
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package android.util;
|
|
||||||
|
|
||||||
public class DisplayMetrics {
|
|
||||||
}
|
|
||||||
|
|
@ -328,94 +328,5 @@ task<Exec>("reRunApp") {
|
||||||
finalizedBy(reRunDaemon)
|
finalizedBy(reRunDaemon)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ExampleClassVisitorFactory :
|
|
||||||
AsmClassVisitorFactory<InstrumentationParameters.None> {
|
|
||||||
override fun createClassVisitor(
|
|
||||||
classContext: ClassContext,
|
|
||||||
nextClassVisitor: ClassVisitor
|
|
||||||
): ClassVisitor {
|
|
||||||
return object :
|
|
||||||
ClassVisitor(Opcodes.ASM9, nextClassVisitor) {
|
|
||||||
override fun visit(
|
|
||||||
version: Int,
|
|
||||||
access: Int,
|
|
||||||
name: String?,
|
|
||||||
signature: String?,
|
|
||||||
superName: String?,
|
|
||||||
interfaces: Array<out String>?
|
|
||||||
) {
|
|
||||||
val newSuperName = "xposed/dummy/X${superName?.substringAfterLast('/')}SuperClass"
|
|
||||||
println("replace super class of $name to $newSuperName")
|
|
||||||
super.visit(
|
|
||||||
version,
|
|
||||||
access,
|
|
||||||
name,
|
|
||||||
signature,
|
|
||||||
newSuperName,
|
|
||||||
interfaces
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitMethod(
|
|
||||||
access: Int,
|
|
||||||
name: String?,
|
|
||||||
descriptor: String?,
|
|
||||||
signature: String?,
|
|
||||||
exceptions: Array<out String>?
|
|
||||||
): MethodVisitor {
|
|
||||||
return object : MethodVisitor(
|
|
||||||
Opcodes.ASM9, super.visitMethod(
|
|
||||||
access,
|
|
||||||
name,
|
|
||||||
descriptor,
|
|
||||||
signature,
|
|
||||||
exceptions
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
override fun visitMethodInsn(
|
|
||||||
opcode: Int,
|
|
||||||
owner: String?,
|
|
||||||
name: String?,
|
|
||||||
instDescriptor: String?,
|
|
||||||
isInterface: Boolean
|
|
||||||
) {
|
|
||||||
if (opcode == Opcodes.INVOKESPECIAL) {
|
|
||||||
val newOwner =
|
|
||||||
"xposed/dummy/X${owner?.substringAfterLast('/')}SuperClass"
|
|
||||||
println("replace method call of $owner.$name$instDescriptor to $newOwner.$name$descriptor")
|
|
||||||
super.visitMethodInsn(
|
|
||||||
opcode,
|
|
||||||
newOwner,
|
|
||||||
name,
|
|
||||||
descriptor,
|
|
||||||
isInterface
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
super.visitMethodInsn(
|
|
||||||
opcode,
|
|
||||||
owner,
|
|
||||||
name,
|
|
||||||
instDescriptor,
|
|
||||||
isInterface
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isInstrumentable(classData: ClassData): Boolean {
|
|
||||||
return classData.className == "io.github.libxposed.XposedResources"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
androidComponents.onVariants { variant ->
|
|
||||||
variant.instrumentation.transformClassesWith(
|
|
||||||
ExampleClassVisitorFactory::class.java, InstrumentationScope.ALL
|
|
||||||
) {}
|
|
||||||
variant.instrumentation.setAsmFramesComputationMode(FramesComputationMode.COPY_FRAMES)
|
|
||||||
}
|
|
||||||
|
|
||||||
evaluationDependsOn(":app")
|
evaluationDependsOn(":app")
|
||||||
evaluationDependsOn(":daemon")
|
evaluationDependsOn(":daemon")
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ include(
|
||||||
":app",
|
":app",
|
||||||
":libxposed:api",
|
":libxposed:api",
|
||||||
":libxposed:service",
|
":libxposed:service",
|
||||||
":stubs",
|
|
||||||
":core",
|
":core",
|
||||||
":daemon",
|
":daemon",
|
||||||
":dex2oat",
|
":dex2oat",
|
||||||
|
|
@ -42,5 +41,3 @@ include(
|
||||||
":services:manager-service",
|
":services:manager-service",
|
||||||
":services:daemon-service",
|
":services:daemon-service",
|
||||||
)
|
)
|
||||||
|
|
||||||
project(":stubs").projectDir = file("libxposed/stubs")
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue