Refine xresources
This commit is contained in:
parent
5b4e13727e
commit
7afdf55eec
|
|
@ -91,34 +91,17 @@ public class XResources extends XposedResources {
|
|||
private static final WeakHashMap<XmlResourceParser, XMLInstanceDetails> sXmlInstanceDetails = new WeakHashMap<>();
|
||||
|
||||
private static final String EXTRA_XML_INSTANCE_DETAILS = "xmlInstanceDetails";
|
||||
private static final ThreadLocal<LinkedList<MethodHookParam>> sIncludedLayouts = new ThreadLocal<LinkedList<MethodHookParam>>() {
|
||||
@Override
|
||||
protected LinkedList<MethodHookParam> initialValue() {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
};
|
||||
private static final ThreadLocal<LinkedList<MethodHookParam>> sIncludedLayouts = ThreadLocal.withInitial(() -> new LinkedList<>());
|
||||
|
||||
private static final HashMap<String, Long> sResDirLastModified = new HashMap<>();
|
||||
private static final HashMap<String, String> sResDirPackageNames = new HashMap<>();
|
||||
private static ThreadLocal<Object> sLatestResKey = null;
|
||||
|
||||
private boolean mIsObjectInited;
|
||||
private String mResDir;
|
||||
private String mPackageName;
|
||||
|
||||
public XResources(ClassLoader classLoader) {
|
||||
public XResources(ClassLoader classLoader, String resDir) {
|
||||
super(classLoader);
|
||||
}
|
||||
|
||||
/** Dummy, will never be called (objects are transferred to this class only). */
|
||||
// private XResources() {
|
||||
// throw new UnsupportedOperationException();
|
||||
// }
|
||||
|
||||
/** @hide */
|
||||
public void initObject(String resDir) {
|
||||
if (mIsObjectInited)
|
||||
throw new IllegalStateException("Object has already been initialized");
|
||||
|
||||
this.mResDir = resDir;
|
||||
this.mPackageName = getPackageName(resDir);
|
||||
|
|
@ -128,10 +111,13 @@ public class XResources extends XposedResources {
|
|||
mReplacementsCache = sReplacementsCacheMap.computeIfAbsent(resDir, k -> new byte[128]);
|
||||
}
|
||||
}
|
||||
|
||||
this.mIsObjectInited = true;
|
||||
}
|
||||
|
||||
/** Dummy, will never be called (objects are transferred to this class only). */
|
||||
// private XResources() {
|
||||
// throw new UnsupportedOperationException();
|
||||
// }
|
||||
|
||||
/** @hide */
|
||||
public boolean isFirstLoad() {
|
||||
synchronized (sReplacements) {
|
||||
|
|
|
|||
|
|
@ -183,9 +183,8 @@ public final class XposedInit {
|
|||
|
||||
// Replace system resources
|
||||
XResources systemRes = new XResources(
|
||||
(ClassLoader) XposedHelpers.getObjectField(Resources.getSystem(), "mClassLoader"));
|
||||
(ClassLoader) XposedHelpers.getObjectField(Resources.getSystem(), "mClassLoader"), null);
|
||||
HiddenApiBridge.Resources_setImpl(systemRes, (ResourcesImpl) XposedHelpers.getObjectField(Resources.getSystem(), "mResourcesImpl"));
|
||||
systemRes.initObject(null);
|
||||
setStaticObjectField(Resources.class, "mSystem", systemRes);
|
||||
|
||||
XResources.init(latestResKey);
|
||||
|
|
@ -199,9 +198,8 @@ public final class XposedInit {
|
|||
|
||||
// Replace the returned resources with our subclass.
|
||||
var newRes = new XResources(
|
||||
(ClassLoader) XposedHelpers.getObjectField(param.getResult(), "mClassLoader"));
|
||||
(ClassLoader) XposedHelpers.getObjectField(param.getResult(), "mClassLoader"), resDir);
|
||||
HiddenApiBridge.Resources_setImpl(newRes, (ResourcesImpl) XposedHelpers.getObjectField(param.getResult(), "mResourcesImpl"));
|
||||
newRes.initObject(resDir);
|
||||
|
||||
// Invoke handleInitPackageResources().
|
||||
if (newRes.isFirstLoad()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue