Init resources hook when call SystemWideReplace (#1400)

Fix #1399
This commit is contained in:
LoveSy 2021-11-13 16:25:02 +08:00 committed by GitHub
parent a04f2159ad
commit b26c8bc59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -57,6 +57,7 @@ import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodHook.MethodHookParam; import de.robv.android.xposed.XC_MethodHook.MethodHookParam;
import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedBridge.CopyOnWriteSortedSet; import de.robv.android.xposed.XposedBridge.CopyOnWriteSortedSet;
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;
@ -567,6 +568,13 @@ public class XResources extends XResourcesSuperClass {
private static void setReplacement(int id, Object replacement, XResources res) { private static void setReplacement(int id, Object replacement, XResources res) {
String resDir = (res != null) ? res.mResDir : null; String resDir = (res != null) ? res.mResDir : null;
if (res == null) {
try {
XposedInit.hookResources();
} catch (Throwable throwable) {
throw new IllegalStateException("Failed to initialize resources hook");
}
}
if (id == 0) if (id == 0)
throw new IllegalArgumentException("id 0 is not an allowed resource identifier"); throw new IllegalArgumentException("id 0 is not an allowed resource identifier");
else if (resDir == null && id >= 0x7f000000) else if (resDir == null && id >= 0x7f000000)