mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-18 21:10:19 +08:00
opt(autojs): optimize TimedTaskScheduler to schedule task
This commit is contained in:
parent
32548ff9f4
commit
f62958655a
Binary file not shown.
@ -8,8 +8,8 @@ android {
|
||||
applicationId "org.autojs.autojs"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 409
|
||||
versionName "4.0.2 Alpha4"
|
||||
versionCode 410
|
||||
versionName "4.0.2 Alpha5"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
@ -6,8 +6,11 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.twofortyfouram.spackle.AlarmManagerCompat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
@ -57,9 +60,12 @@ public class TimedTaskScheduler extends BroadcastReceiver {
|
||||
context.sendBroadcast(timedTask.createIntent());
|
||||
return;
|
||||
}
|
||||
assert alarmManager != null;
|
||||
// FIXME: 2017/11/28 requestCode may > 65535
|
||||
PendingIntent op = timedTask.createPendingIntent(context);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(millis, null), op);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, millis, op);
|
||||
} else {
|
||||
alarmManager.set(AlarmManager.RTC_WAKEUP, millis, op);
|
||||
|
||||
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
import dalvik.system.DexFile;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/4/5.
|
||||
@ -26,7 +25,7 @@ public class AndroidClassLoader extends ClassLoader implements GeneratedClassLoa
|
||||
|
||||
|
||||
private final ClassLoader parent;
|
||||
private List<DexClassLoader> dx;
|
||||
private List<DexClassLoader> mDexClassLoaders;
|
||||
private final File dexFile;
|
||||
private final File odexOatFile;
|
||||
private final File classFile;
|
||||
@ -41,7 +40,7 @@ public class AndroidClassLoader extends ClassLoader implements GeneratedClassLoa
|
||||
public AndroidClassLoader(ClassLoader parent, File dir) {
|
||||
this.parent = parent;
|
||||
mCacheDir = dir;
|
||||
dx = new ArrayList<>();
|
||||
mDexClassLoaders = new ArrayList<>();
|
||||
dexFile = new File(dir, "dex-" + hashCode() + ".jar");
|
||||
odexOatFile = new File(dir, "odex_oat-" + hashCode() + ".tmp");
|
||||
classFile = new File(dir, "class-" + hashCode() + ".jar");
|
||||
@ -92,7 +91,7 @@ public class AndroidClassLoader extends ClassLoader implements GeneratedClassLoa
|
||||
|
||||
public DexClassLoader loadDex(File file) throws IOException {
|
||||
DexClassLoader loader = new DexClassLoader(file.getPath(), mCacheDir.getPath(), null, parent);
|
||||
dx.add(loader);
|
||||
mDexClassLoaders.add(loader);
|
||||
return loader;
|
||||
}
|
||||
|
||||
@ -131,7 +130,7 @@ public class AndroidClassLoader extends ClassLoader implements GeneratedClassLoa
|
||||
throws ClassNotFoundException {
|
||||
Class<?> loadedClass = findLoadedClass(name);
|
||||
if (loadedClass == null) {
|
||||
for (DexClassLoader dex : dx) {
|
||||
for (DexClassLoader dex : mDexClassLoaders) {
|
||||
loadedClass = dex.loadClass(name);
|
||||
if (loadedClass != null) {
|
||||
break;
|
||||
|
||||
@ -1 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":409},"path":"commonRelease-4.0.2 Alpha4.apk","properties":{"packageId":"org.autojs.autojs","split":"","minSdkVersion":"17"}}]
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":410},"path":"commonRelease-4.0.2 Alpha5.apk","properties":{"packageId":"org.autojs.autojs","split":"","minSdkVersion":"17"}}]
|
||||
@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.stardust.auojs.inrt"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 203
|
||||
versionName "4.0.0 Beta"
|
||||
versionCode 210
|
||||
versionName "4.0.2 Alpha5"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user