6.0.0 - 部分插件及工具版本更新

This commit is contained in:
SuperMonster003
2021-12-01 13:39:18 +08:00
parent 684938893a
commit 99a1d8490f
195 changed files with 5540 additions and 3909 deletions

View File

@@ -11,6 +11,7 @@ import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import androidx.annotation.Nullable;
import android.util.Base64;
import android.util.Log;
import java.io.IOException;
import java.lang.ref.WeakReference;
@@ -19,6 +20,8 @@ import java.util.concurrent.ExecutorService;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import kotlin.text.Regex;
/**
* Created by Stardust on 2017/4/5.
*/
@@ -26,8 +29,7 @@ import java.util.zip.ZipFile;
public class DeveloperUtils {
private static final String PACKAGE_NAME = "org.autojs.autojs";
private static final String SIGNATURE = "nPNPcy4Lk/eP6fLvZitP0VPbHdFCbKua77m59vis5fA=";
private static final String LOG_TAG = "DeveloperUtils";
private static final Regex SIGNATURE_REX = new Regex(".*(CbKua77m59vis|N7YkpKxKjsPWe).*");
private static final ExecutorService sExecutor = UnderuseExecutors.getExecutor();
private static final String SALT = "let\nlife\nbe\nbeautiful\nlike\nsummer\nflowers\nand\ndeath\nlike\nautumn\nleaves\n.";
@@ -80,7 +82,7 @@ public class DeveloperUtils {
if (sha.endsWith("\n")) {
sha = sha.substring(0, sha.length() - 1);
}
return SIGNATURE.equals(sha);
return SIGNATURE_REX.matches(sha);
}
@@ -150,7 +152,7 @@ public class DeveloperUtils {
}
}
public static void verifyApk(Activity activity, final int crcRes) {
public static void verifyApk(Activity activity) {
final WeakReference<Activity> activityWeakReference = new WeakReference<>(activity);
sExecutor.execute(new Runnable() {
@Override
@@ -160,13 +162,7 @@ public class DeveloperUtils {
return;
if (!checkSignature(a)) {
a.finish();
return;
}
//long[] crc = readCrc(a.getString(crcRes));
//if (!checkDexFile(a, crc)) {
//a.finish();
//}
}
});
}

View File

@@ -8,13 +8,41 @@ import android.util.SparseArray;
import com.stardust.BuildConfig;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
public final class ResourceMonitor {
private static final String LOG_TAG = "ResourceMonitor";
private static final ConcurrentHashMap<Class<?>, SparseArray<Exception>> mResources = new ConcurrentHashMap<>();
// @Reference to TonyJiangWJ/Auto.js on Nov 22, 2021
private static class LockedResource {
private ReentrantLock lock;
private SparseArray<Exception> resource;
public LockedResource() {
this.resource = new SparseArray<>();
this.lock = new ReentrantLock();
}
public ReentrantLock getLock() {
return lock;
}
public void setLock(ReentrantLock lock) {
this.lock = lock;
}
public SparseArray<Exception> getResource() {
return resource;
}
public void setResource(SparseArray<Exception> resource) {
this.resource = resource;
}
}
private static final ConcurrentHashMap<Class<?>, LockedResource> mResources = new ConcurrentHashMap<>();
private static Handler sHandler;
private static boolean sEnabled = BuildConfig.DEBUG;
private static ExceptionCreator sExceptionCreator;
@@ -32,9 +60,9 @@ public final class ResourceMonitor {
if (!sEnabled) {
return;
}
SparseArray<Exception> map = mResources.get(resource.getClass());
LockedResource map = mResources.get(resource.getClass());
if (map == null) {
map = new SparseArray<>();
map = new LockedResource();
mResources.put(resource.getClass(), map);
}
int resourceId = resource.getResourceId();
@@ -45,16 +73,20 @@ public final class ResourceMonitor {
} else {
exception = sExceptionCreator.create(resource);
}
map.put(resourceId, exception);
map.getLock().lock();
map.getResource().put(resourceId, exception);
map.getLock().unlock();
}
public static void onClose(ResourceMonitor.Resource resource) {
if (!sEnabled) {
return;
}
SparseArray map = mResources.get(resource.getClass());
LockedResource map = mResources.get(resource.getClass());
if (map != null) {
map.remove(resource.getResourceId());
map.getLock().lock();
map.getResource().remove(resource.getResourceId());
map.getLock().unlock();
}
}
@@ -62,12 +94,16 @@ public final class ResourceMonitor {
if (!sEnabled) {
return;
}
SparseArray<Exception> map = mResources.get(resource.getClass());
LockedResource map = mResources.get(resource.getClass());
if (map != null) {
int indexOfKey = map.indexOfKey(resource.getResourceId());
if (indexOfKey >= 0) {
final Exception exception = map.valueAt(indexOfKey);
map.removeAt(indexOfKey);
map.getLock().lock();
int indexOfKey = map.getResource().indexOfKey(resource.getResourceId());
if (indexOfKey < 0) {
map.getLock().unlock();
} else {
final Exception exception = map.getResource().valueAt(indexOfKey);
map.getResource().removeAt(indexOfKey);
map.getLock().unlock();
if (sHandler == null) {
sHandler = new Handler(Looper.getMainLooper());
}

View File

@@ -3,9 +3,15 @@ package com.stardust.util;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import android.content.ContextWrapper;
import android.graphics.Rect;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
/**
* Created by Stardust on 2017/1/24.
@@ -19,7 +25,7 @@ public class ViewUtil {
}
// FIXME: 2018/1/23 not working in some devices (https://github.com/hyb1996/Auto.js/issues/268)
public static int getStatusBarHeight(Context context) {
public static int getStatusBarHeightLegacy(Context context) {
int result = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
@@ -28,6 +34,36 @@ public class ViewUtil {
return result;
}
public static int getStatusBarHeight(Context context) {
Rect rectangle = new Rect();
Window window = getWindowForContext(context);
if (window == null) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources().getDisplayMetrics());
}
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
return rectangle.top;
}
public static int getTitleBarHeight(Context context) {
Window window = getWindowForContext(context);
int contentViewTop = 0;
if (window != null) {
contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
}
return contentViewTop - getStatusBarHeight(context);
}
@Nullable
private static Window getWindowForContext(Context context) {
if (context instanceof Activity) {
return ((Activity) context).getWindow();
}
if (context instanceof ContextWrapper) {
return getWindowForContext(((ContextWrapper) context).getBaseContext());
}
return null;
}
public static int getScreenHeight(Activity activity) {
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);