Allow get resource
This commit is contained in:
parent
4896974873
commit
18bedd4fbb
|
|
@ -17,6 +17,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.XModuleResources;
|
||||||
import android.database.DatabaseErrorHandler;
|
import android.database.DatabaseErrorHandler;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
@ -58,12 +59,14 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
static final Set<XposedModule> modules = ConcurrentHashMap.newKeySet();
|
static final Set<XposedModule> modules = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
private final Context base;
|
private final Context mBase;
|
||||||
private final String packageName;
|
private final String mPackageName;
|
||||||
|
private final Object mSync = new Object();
|
||||||
|
private Resources mResources;
|
||||||
|
|
||||||
LSPosedContext(Context base, String packageName) {
|
LSPosedContext(Context base, String packageName) {
|
||||||
this.base = base;
|
this.mBase = base;
|
||||||
this.packageName = packageName;
|
this.mPackageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param, Bundle extra) {
|
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param, Bundle extra) {
|
||||||
|
|
@ -71,7 +74,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
try {
|
try {
|
||||||
module.onPackageLoaded(param, extra);
|
module.onPackageLoaded(param, extra);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.e(TAG, "Error when calling onPackageLoaded of " + ((LSPosedContext) module.getBaseContext()).packageName, t);
|
Log.e(TAG, "Error when calling onPackageLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +84,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
try {
|
try {
|
||||||
module.onResourceLoaded(param, extra);
|
module.onResourceLoaded(param, extra);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.e(TAG, "Error when calling onResourceLoaded of " + ((LSPosedContext) module.getBaseContext()).packageName, t);
|
Log.e(TAG, "Error when calling onResourceLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -163,12 +166,17 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resources getResources() {
|
public Resources getResources() {
|
||||||
throw new AbstractMethodError();
|
synchronized (mSync) {
|
||||||
|
if (mResources == null) {
|
||||||
|
mResources = XModuleResources.createInstance(mBase.getPackageCodePath(), null);
|
||||||
|
}
|
||||||
|
return mResources;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PackageManager getPackageManager() {
|
public PackageManager getPackageManager() {
|
||||||
return base.getPackageManager();
|
return mBase.getPackageManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -178,7 +186,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Looper getMainLooper() {
|
public Looper getMainLooper() {
|
||||||
return base.getMainLooper();
|
return mBase.getMainLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -198,17 +206,17 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassLoader getClassLoader() {
|
public ClassLoader getClassLoader() {
|
||||||
return base.getClassLoader();
|
return mBase.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
return base.getPackageName();
|
return mBase.getPackageName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationInfo getApplicationInfo() {
|
public ApplicationInfo getApplicationInfo() {
|
||||||
return base.getApplicationInfo();
|
return mBase.getApplicationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -218,7 +226,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPackageCodePath() {
|
public String getPackageCodePath() {
|
||||||
return base.getPackageCodePath();
|
return mBase.getPackageCodePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -551,7 +559,7 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSystemService(@NonNull String name) {
|
public Object getSystemService(@NonNull String name) {
|
||||||
return base.getSystemService(name);
|
return mBase.getSystemService(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -687,11 +695,11 @@ public class LSPosedContext extends XposedContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
Log.i(TAG, packageName + ": " + message);
|
Log.i(TAG, mPackageName + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message, Throwable throwable) {
|
public void log(String message, Throwable throwable) {
|
||||||
Log.e(TAG, packageName + ": " + message, throwable);
|
Log.e(TAG, mPackageName + ": " + message, throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue