mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Update SNET extension dialog interface
This commit is contained in:
@ -45,10 +45,12 @@ public class CheckSafetyNet extends ParallelTask<Void, Void, Exception> {
|
||||
private void dyload() throws Exception {
|
||||
DexClassLoader loader = new DexClassLoader(dexPath.getPath(), dexPath.getParent(),
|
||||
null, ISafetyNetHelper.class.getClassLoader());
|
||||
Class<?> clazz = loader.loadClass("com.topjohnwu.snet.SafetyNetHelper");
|
||||
helper = (ISafetyNetHelper) clazz.getConstructors()[0]
|
||||
.newInstance(getActivity(), (ISafetyNetHelper.Callback)
|
||||
code -> MagiskManager.get().safetyNetDone.publish(false, code));
|
||||
Class<?> clazz = loader.loadClass("com.topjohnwu.snet.Snet");
|
||||
helper = (ISafetyNetHelper) clazz.getMethod("newHelper",
|
||||
Class.class, String.class, Activity.class, Object.class)
|
||||
.invoke(null, ISafetyNetHelper.class, dexPath.getPath(), getActivity(),
|
||||
(ISafetyNetHelper.Callback) code ->
|
||||
MagiskManager.get().safetyNetDone.publish(false, code));
|
||||
if (helper.getVersion() != Const.SNET_VER) {
|
||||
throw new Exception();
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.topjohnwu.magisk.components;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@ -15,10 +12,6 @@ import com.topjohnwu.magisk.utils.Topic;
|
||||
|
||||
public abstract class FlavorActivity extends AppCompatActivity {
|
||||
|
||||
private AssetManager swappedAssetManager = null;
|
||||
private Resources swappedResources = null;
|
||||
private Resources.Theme backupTheme = null;
|
||||
|
||||
@StyleRes
|
||||
public int getDarkTheme() {
|
||||
return -1;
|
||||
@ -61,48 +54,4 @@ public abstract class FlavorActivity extends AppCompatActivity {
|
||||
setFinishOnTouchOutside(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources.Theme getTheme() {
|
||||
return backupTheme == null ? super.getTheme() : backupTheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetManager getAssets() {
|
||||
return swappedAssetManager == null ? super.getAssets() : swappedAssetManager;
|
||||
}
|
||||
|
||||
private AssetManager getAssets(String apk) {
|
||||
try {
|
||||
AssetManager asset = AssetManager.class.newInstance();
|
||||
AssetManager.class.getMethod("addAssetPath", String.class).invoke(asset, apk);
|
||||
return asset;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
return swappedResources == null ? super.getResources() : swappedResources;
|
||||
}
|
||||
|
||||
@Keep
|
||||
public void swapResources(String dexPath) {
|
||||
AssetManager asset = getAssets(dexPath);
|
||||
if (asset != null) {
|
||||
backupTheme = super.getTheme();
|
||||
Resources res = super.getResources();
|
||||
swappedResources = new Resources(asset, res.getDisplayMetrics(), res.getConfiguration());
|
||||
swappedAssetManager = asset;
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
public void restoreResources() {
|
||||
swappedAssetManager = null;
|
||||
swappedResources = null;
|
||||
backupTheme = null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user