mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-12 21:01:32 +08:00
修复 captureScreen()可能造成死循环的问题
This commit is contained in:
parent
248d698708
commit
67614b8016
@ -14,6 +14,7 @@
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
|
||||
<!-- 非Auto.js运行必需,不会主动申请,某些脚本可以自行申请-->
|
||||
@ -116,8 +117,8 @@
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
@ -1,20 +1,39 @@
|
||||
"ui";
|
||||
|
||||
//音乐文件的后缀名
|
||||
var musicExts = [".mp3", ".wma", ".rm", ".wav", ".mid", ".ape", ".flac"];
|
||||
//扫描路径
|
||||
var path = files.getSdcardPath();
|
||||
//保存音乐文件列表的数组
|
||||
var musicFiles = [];
|
||||
var IconView = (function() {
|
||||
//继承ui.Widget
|
||||
util.extend(IconView, ui.Widget);
|
||||
|
||||
function IconView() {
|
||||
//调用父类构造函数
|
||||
ui.Widget.call(this);
|
||||
//自定义属性color,定义按钮颜色
|
||||
this.defineAttr("icon", (view, name, defaultGetter) => {
|
||||
return this._icon;
|
||||
}, (view, name, value, defaultSetter) => {
|
||||
this._icon = value;
|
||||
view.setImageResource(value);
|
||||
});
|
||||
}
|
||||
IconView.prototype.render = function() {
|
||||
return (
|
||||
<img />
|
||||
);
|
||||
}
|
||||
ui.registerWidget("icon", IconView);
|
||||
return IconView;
|
||||
})();
|
||||
|
||||
var apps = [];
|
||||
|
||||
ui.layout(
|
||||
<vertical bg="#ffffff">
|
||||
<list id="files" layout_weight="1">
|
||||
<linear bg="?selectableItemBackground">
|
||||
<img src="@drawable/ic_music_note_black_48dp" tint="white" bg="#ff5722" w="50" h="70" margin="16" />
|
||||
<icon icon="{{this.icon}}" w="50" h="70" margin="16" />
|
||||
<vertical>
|
||||
<text id="name" textSize="16sp" textColor="#000000" text="{{this.name}}" marginTop="16" maxLines="1" ellipsize="end"/>
|
||||
<text id="path" textSize="13sp" textColor="#929292" text="{{this.path}}" marginTop="8" maxLines="1" ellipsize="end"/>
|
||||
<text id="name" textSize="16sp" textColor="#000000" text="{{this.appName}}" marginTop="16" maxLines="1" ellipsize="end"/>
|
||||
<text id="path" textSize="13sp" textColor="#929292" text="{{this.packageName}}" marginTop="8" maxLines="1" ellipsize="end"/>
|
||||
</vertical>
|
||||
</linear>
|
||||
</list>
|
||||
@ -22,38 +41,31 @@ ui.layout(
|
||||
</vertical>
|
||||
);
|
||||
|
||||
ui.files.setDataSource(musicFiles);
|
||||
ui.apps.setDataSource(musicFiles);
|
||||
|
||||
ui.files.on("item_click", function(item, pos){
|
||||
media.playMusic(item.path, 1);
|
||||
ui.apps.on("item_click", function(item, pos){
|
||||
toast(item);
|
||||
});
|
||||
|
||||
//启动线程来扫描音乐文件
|
||||
threads.start(function () {
|
||||
listMuiscFiles(path, musicFiles);
|
||||
listApps(apps);
|
||||
ui.run(()=> {
|
||||
ui.progressbar.setVisility(8);
|
||||
});
|
||||
});
|
||||
|
||||
function listMuiscFiles(dir, list) {
|
||||
//遍历该文件夹的文件
|
||||
files.listDir(dir).forEach(fileName => {
|
||||
var path = files.join(dir, fileName);
|
||||
//如果是子文件夹则继续扫描子文件夹的文件
|
||||
if (files.isDir(path)) {
|
||||
listMuiscFiles(path, list);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < musicExts.length; i++) {
|
||||
//如果文件名的后缀是音乐格式
|
||||
if (fileName.endsWith(musicExts[i])) {
|
||||
//则把它添加到列表中
|
||||
list.push({
|
||||
name: fileName,
|
||||
path: path
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
function listApps(apps) {
|
||||
var pm = context.getPackageManager();
|
||||
let list = pm.getInstalledPackages(0);
|
||||
for(let i = 0; i < list.size(); i++){
|
||||
let p = list.get(i);
|
||||
apps.push({
|
||||
appName: p.applicationInfo.loadLabel(pm).toString(),
|
||||
packageName: p.packageName,
|
||||
versionName: p.versionName,
|
||||
versionCode: p.versionCode,
|
||||
icon: p.applicationInfo.loadIcon(pm)
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,5 @@
|
||||
package com.stardust.autojs.core.http;
|
||||
|
||||
import android.widget.AdapterView;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import android.view.OrientationEventListener;
|
||||
|
||||
import com.stardust.autojs.runtime.exception.ScriptException;
|
||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||
import com.stardust.lang.ThreadCompat;
|
||||
import com.stardust.util.ScreenMetrics;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@ -152,7 +153,8 @@ public class ScreenCapturer {
|
||||
mException = null;
|
||||
throw new ScriptException(e);
|
||||
}
|
||||
while (true) {
|
||||
Thread thread = ThreadCompat.currentThread();
|
||||
while (!thread.isInterrupted()) {
|
||||
Image cachedImage = mCachedImage.getAndSet(null);
|
||||
if (cachedImage != null) {
|
||||
if (mUnderUsingImage != null) {
|
||||
@ -162,6 +164,7 @@ public class ScreenCapturer {
|
||||
return cachedImage;
|
||||
}
|
||||
}
|
||||
throw new ScriptInterruptedException();
|
||||
}
|
||||
|
||||
public int getScreenDensity() {
|
||||
|
||||
@ -1 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":436,"versionName":"4.0.4 Alpha7","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha7.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha7.apk","properties":{}}]
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":437,"versionName":"4.0.4 Alpha8","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha8.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha8.apk","properties":{}}]
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"appVersionCode": 436,
|
||||
"appVersionName": "4.0.4 Alpha7",
|
||||
"appVersionCode": 437,
|
||||
"appVersionName": "4.0.4 Alpha8",
|
||||
"target": 28,
|
||||
"mini": 17,
|
||||
"compile": 28,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user