version:1.3.4
update: fix: add:开发人员选项管控推送
This commit is contained in:
@@ -1140,7 +1140,7 @@ public class ApkUtils {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("RemoveTask", "onError: ");
|
||||
Log.e("RemoveTask", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,9 @@ import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -764,4 +767,71 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeveloper(int state) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
|
||||
if (state == 1) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_developeroptions_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public void hookWebView() {
|
||||
int sdkInt = Build.VERSION.SDK_INT;
|
||||
try {
|
||||
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
|
||||
Field field = factoryClass.getDeclaredField("sProviderInstance");
|
||||
field.setAccessible(true);
|
||||
Object sProviderInstance = field.get(null);
|
||||
if (sProviderInstance != null) {
|
||||
Log.i(TAG, "sProviderInstance isn't null");
|
||||
return;
|
||||
}
|
||||
|
||||
Method getProviderClassMethod;
|
||||
if (sdkInt > 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
|
||||
} else if (sdkInt == 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
|
||||
} else {
|
||||
Log.i(TAG, "Don't need to Hook WebView");
|
||||
return;
|
||||
}
|
||||
getProviderClassMethod.setAccessible(true);
|
||||
Class<?> factoryProviderClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
|
||||
Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
|
||||
Constructor<?> delegateConstructor = delegateClass.getDeclaredConstructor();
|
||||
delegateConstructor.setAccessible(true);
|
||||
if (sdkInt < 26) {//低于Android O版本
|
||||
Constructor<?> providerConstructor = factoryProviderClass.getConstructor(delegateClass);
|
||||
if (providerConstructor != null) {
|
||||
providerConstructor.setAccessible(true);
|
||||
sProviderInstance = providerConstructor.newInstance(delegateConstructor.newInstance());
|
||||
}
|
||||
} else {
|
||||
Field chromiumMethodName = factoryClass.getDeclaredField("CHROMIUM_WEBVIEW_FACTORY_METHOD");
|
||||
chromiumMethodName.setAccessible(true);
|
||||
String chromiumMethodNameStr = (String) chromiumMethodName.get(null);
|
||||
if (chromiumMethodNameStr == null) {
|
||||
chromiumMethodNameStr = "create";
|
||||
}
|
||||
Method staticFactory = factoryProviderClass.getMethod(chromiumMethodNameStr, delegateClass);
|
||||
if (staticFactory != null) {
|
||||
sProviderInstance = staticFactory.invoke(null, delegateConstructor.newInstance());
|
||||
}
|
||||
}
|
||||
|
||||
if (sProviderInstance != null) {
|
||||
field.set("sProviderInstance", sProviderInstance);
|
||||
Log.i(TAG, "Hook success!");
|
||||
} else {
|
||||
Log.i(TAG, "Hook failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.mjsheng.myappstore.BuildConfig;
|
||||
public class Logger {
|
||||
|
||||
//设为false关闭日志
|
||||
private static final boolean LOG_ENABLE = BuildConfig.LOG_DEBUG;
|
||||
private static final boolean LOG_ENABLE = BuildConfig.DEBUG;
|
||||
|
||||
public static void i(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ToastUtil {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (BuildConfig.LOG_DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (toast != null) {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
|
||||
Reference in New Issue
Block a user