修复 captureScreen()可能造成死循环的问题
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<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.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- 非Auto.js运行必需,不会主动申请,某些脚本可以自行申请-->
|
<!-- 非Auto.js运行必需,不会主动申请,某些脚本可以自行申请-->
|
||||||
@@ -116,8 +117,8 @@
|
|||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.CREATE_SHORTCUT" />
|
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,39 @@
|
|||||||
"ui";
|
"ui";
|
||||||
|
|
||||||
//音乐文件的后缀名
|
var IconView = (function() {
|
||||||
var musicExts = [".mp3", ".wma", ".rm", ".wav", ".mid", ".ape", ".flac"];
|
//继承ui.Widget
|
||||||
//扫描路径
|
util.extend(IconView, ui.Widget);
|
||||||
var path = files.getSdcardPath();
|
|
||||||
//保存音乐文件列表的数组
|
function IconView() {
|
||||||
var musicFiles = [];
|
//调用父类构造函数
|
||||||
|
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(
|
ui.layout(
|
||||||
<vertical bg="#ffffff">
|
<vertical bg="#ffffff">
|
||||||
<list id="files" layout_weight="1">
|
<list id="files" layout_weight="1">
|
||||||
<linear bg="?selectableItemBackground">
|
<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>
|
<vertical>
|
||||||
<text id="name" textSize="16sp" textColor="#000000" text="{{this.name}}" marginTop="16" 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.path}}" marginTop="8" maxLines="1" ellipsize="end"/>
|
<text id="path" textSize="13sp" textColor="#929292" text="{{this.packageName}}" marginTop="8" maxLines="1" ellipsize="end"/>
|
||||||
</vertical>
|
</vertical>
|
||||||
</linear>
|
</linear>
|
||||||
</list>
|
</list>
|
||||||
@@ -22,38 +41,31 @@ ui.layout(
|
|||||||
</vertical>
|
</vertical>
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.files.setDataSource(musicFiles);
|
ui.apps.setDataSource(musicFiles);
|
||||||
|
|
||||||
ui.files.on("item_click", function(item, pos){
|
ui.apps.on("item_click", function(item, pos){
|
||||||
media.playMusic(item.path, 1);
|
toast(item);
|
||||||
});
|
});
|
||||||
|
|
||||||
//启动线程来扫描音乐文件
|
//启动线程来扫描音乐文件
|
||||||
threads.start(function () {
|
threads.start(function () {
|
||||||
listMuiscFiles(path, musicFiles);
|
listApps(apps);
|
||||||
ui.run(()=> {
|
ui.run(()=> {
|
||||||
ui.progressbar.setVisility(8);
|
ui.progressbar.setVisility(8);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function listMuiscFiles(dir, list) {
|
function listApps(apps) {
|
||||||
//遍历该文件夹的文件
|
var pm = context.getPackageManager();
|
||||||
files.listDir(dir).forEach(fileName => {
|
let list = pm.getInstalledPackages(0);
|
||||||
var path = files.join(dir, fileName);
|
for(let i = 0; i < list.size(); i++){
|
||||||
//如果是子文件夹则继续扫描子文件夹的文件
|
let p = list.get(i);
|
||||||
if (files.isDir(path)) {
|
apps.push({
|
||||||
listMuiscFiles(path, list);
|
appName: p.applicationInfo.loadLabel(pm).toString(),
|
||||||
return;
|
packageName: p.packageName,
|
||||||
}
|
versionName: p.versionName,
|
||||||
for (var i = 0; i < musicExts.length; i++) {
|
versionCode: p.versionCode,
|
||||||
//如果文件名的后缀是音乐格式
|
icon: p.applicationInfo.loadIcon(pm)
|
||||||
if (fileName.endsWith(musicExts[i])) {
|
});
|
||||||
//则把它添加到列表中
|
}
|
||||||
list.push({
|
|
||||||
name: fileName,
|
|
||||||
path: path
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
package com.stardust.autojs.core.http;
|
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.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
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.ScriptException;
|
||||||
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
|
||||||
|
import com.stardust.lang.ThreadCompat;
|
||||||
import com.stardust.util.ScreenMetrics;
|
import com.stardust.util.ScreenMetrics;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@@ -152,7 +153,8 @@ public class ScreenCapturer {
|
|||||||
mException = null;
|
mException = null;
|
||||||
throw new ScriptException(e);
|
throw new ScriptException(e);
|
||||||
}
|
}
|
||||||
while (true) {
|
Thread thread = ThreadCompat.currentThread();
|
||||||
|
while (!thread.isInterrupted()) {
|
||||||
Image cachedImage = mCachedImage.getAndSet(null);
|
Image cachedImage = mCachedImage.getAndSet(null);
|
||||||
if (cachedImage != null) {
|
if (cachedImage != null) {
|
||||||
if (mUnderUsingImage != null) {
|
if (mUnderUsingImage != null) {
|
||||||
@@ -162,6 +164,7 @@ public class ScreenCapturer {
|
|||||||
return cachedImage;
|
return cachedImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new ScriptInterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getScreenDensity() {
|
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,
|
"appVersionCode": 437,
|
||||||
"appVersionName": "4.0.4 Alpha7",
|
"appVersionName": "4.0.4 Alpha8",
|
||||||
"target": 28,
|
"target": 28,
|
||||||
"mini": 17,
|
"mini": 17,
|
||||||
"compile": 28,
|
"compile": 28,
|
||||||
|
|||||||
Reference in New Issue
Block a user