2020-01-10 15:09:55 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<script src="js/jquery-3.2.1.js"></script>
|
|
|
|
<script src="layui/layui.all.js"></script>
|
|
|
|
<link rel="stylesheet" href="layui/css/layui.css">
|
|
|
|
<link rel="stylesheet" href="layui/css/modules/layer/default/layer.css">
|
|
|
|
<link rel="stylesheet" href="layui/css/layui.css" media="all">
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<form class="layui-form">
|
|
|
|
<input id="text" name="iput" required lay-verify="required" placeholder="请输入指令" autocomplete="off"
|
|
|
|
class="layui-input" />
|
|
|
|
<label class="layui-form-label">设备列表</label>
|
|
|
|
<select id="device" name="device" lay-verify="" lay-filter="dev">
|
|
|
|
</select>
|
|
|
|
<input id="btn" name="btn" type="button" value="执行" class="layui-btn layui-btn-normal" />
|
|
|
|
|
2022-08-24 21:12:13 +08:00
|
|
|
<button type="button" class="layui-btn" id="setSignFile">
|
|
|
|
<i class="layui-icon"></i>设置签名
|
2020-01-10 15:09:55 +08:00
|
|
|
</button>
|
|
|
|
<input id="flush" name="flush" type="button" value="刷新设备列表" class="layui-btn" />
|
|
|
|
<input id="showPack" name="showPack" type="button" value="已安装列表" class="layui-btn" />
|
|
|
|
<input id="show" name="show" type="button" value="查看apk信息" class="layui-btn" />
|
|
|
|
<input id="showTopActivity" name="showTopActivity" type="button" value="设备当前顶层Activity" class="layui-btn" />
|
|
|
|
<p />
|
|
|
|
<label class="layui-form-label">日志:</label>
|
|
|
|
|
|
|
|
<textarea name="log" id="log" required lay-verify="required" placeholder="等待输出" class="layui-textarea"
|
|
|
|
style="height: 350px;"></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
<script>
|
2022-08-24 21:12:13 +08:00
|
|
|
function showWindows() {
|
|
|
|
utools.showMainWindow()
|
|
|
|
}
|
|
|
|
function uploadSign(alias, aliasPassword, password, sign) {
|
|
|
|
utools.db.put({
|
|
|
|
_id: "alias",
|
|
|
|
data: alias
|
|
|
|
})
|
|
|
|
utools.db.put({
|
|
|
|
_id: "aliasPassword",
|
|
|
|
data: aliasPassword
|
|
|
|
})
|
|
|
|
utools.db.put({
|
|
|
|
_id: "password",
|
|
|
|
data: password
|
|
|
|
})
|
|
|
|
utools.db.put({
|
|
|
|
_id: "sign",
|
|
|
|
data: sign
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
2020-01-10 15:09:55 +08:00
|
|
|
function log(data) {
|
|
|
|
console.log("日志输出:" + data)
|
|
|
|
$('#log').val($('#log').val() + "\n" + data)
|
|
|
|
}
|
|
|
|
function install() {
|
|
|
|
log("开始执行:" + $('#text').val());
|
|
|
|
window.adb($('#text').val(), (stdout) => {
|
|
|
|
log(stdout);
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
var devices = []
|
|
|
|
var path;
|
|
|
|
layui.use('form', function () {
|
|
|
|
var form = layui.form;
|
|
|
|
var upload = layui.upload;
|
|
|
|
form.render();
|
|
|
|
form.on('select(dev)', function (data) {
|
|
|
|
$('#text').val("adb -s " + data.value + " install \"" + path + "\"");
|
|
|
|
});
|
|
|
|
var uploadInst = upload.render({
|
|
|
|
elem: '#upload' //绑定元素
|
|
|
|
,
|
|
|
|
url: '/upload/', //上传接口
|
|
|
|
accept: 'file',
|
|
|
|
auto: false,
|
|
|
|
|
|
|
|
choose: function (obj) {
|
|
|
|
//上传完毕回调
|
|
|
|
var files = obj.pushFile();
|
|
|
|
obj.preview(function (index, file, result) {
|
|
|
|
path = file.path;
|
|
|
|
var dv = devices[0].split(/\s+/);
|
|
|
|
$('#text').val("adb -s " + dv[0] + " install \"" + path + "\"");
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
//请求异常回调
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
$('#btn').click(function () {
|
|
|
|
install();
|
|
|
|
})
|
|
|
|
$('#flush').click(function () {
|
|
|
|
reload()
|
|
|
|
})
|
2022-08-24 21:12:13 +08:00
|
|
|
$('#setSignFile').click(function () {
|
|
|
|
setSign()
|
|
|
|
})
|
2020-01-10 15:09:55 +08:00
|
|
|
|
|
|
|
reload()
|
|
|
|
utools.onPluginEnter(({
|
|
|
|
code,
|
|
|
|
type,
|
|
|
|
payload
|
|
|
|
}) => {
|
2022-08-24 21:12:13 +08:00
|
|
|
console.log(code)
|
|
|
|
if (type != 'window')
|
2020-01-10 15:09:55 +08:00
|
|
|
path = payload[0].path;
|
2022-08-24 21:12:13 +08:00
|
|
|
if (code == 'install') {
|
2020-01-10 15:09:55 +08:00
|
|
|
console.log("检测到文件:" + path)
|
|
|
|
log("准备安装:" + path)
|
2022-08-24 21:12:13 +08:00
|
|
|
} else if (code == 'unapk') {
|
|
|
|
log("准备反编译:" + path)
|
|
|
|
window.unapk(payload[0].path, (stdout, error) => {
|
|
|
|
log(stdout)
|
|
|
|
utools.shellBeep()
|
|
|
|
})
|
|
|
|
} else if (code == 'apkinfo') {
|
|
|
|
window.apkinfo(path, (stdout, error) => {
|
|
|
|
log(stdout)
|
|
|
|
})
|
|
|
|
} else if (code == 'packapk') {
|
|
|
|
utools.readCurrentFolderPath().then((dir) => {
|
|
|
|
log("正在回编译")
|
|
|
|
window.packapk(dir, (stdout, error) => {
|
|
|
|
log(stdout)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else if (code == 'signapk') {
|
|
|
|
let isUseSign = utools.db.get('sign')
|
|
|
|
if (isUseSign == null) {
|
|
|
|
setSign()
|
|
|
|
} else {
|
|
|
|
log("正在签名:" + path)
|
|
|
|
window.signapk(payload[0].path, (stdout, error) => {
|
|
|
|
log(stdout)
|
|
|
|
utools.shellBeep()
|
|
|
|
log('签名完成')
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-10 15:09:55 +08:00
|
|
|
}
|
|
|
|
})
|
2022-08-24 21:12:13 +08:00
|
|
|
function setSign() {
|
|
|
|
layer.open({
|
|
|
|
type: 2,
|
|
|
|
title: '设置签名'
|
|
|
|
, area: ['350px', '300px']
|
|
|
|
, content: ['sign_dialog.html', 'no']
|
|
|
|
, cancel: function (index, layero) {
|
|
|
|
layer.close(index)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-01-10 15:09:55 +08:00
|
|
|
|
|
|
|
function reload() {
|
|
|
|
chinese = [];
|
|
|
|
$('#device').empty();
|
|
|
|
$('#log').val('');
|
|
|
|
|
2022-08-24 21:12:13 +08:00
|
|
|
window.adb('adb devices', (stdout, error) => {
|
|
|
|
if (error == true) {
|
2020-01-10 15:09:55 +08:00
|
|
|
log(stdout)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var out = stdout.split("\n");
|
|
|
|
var j = 0;
|
|
|
|
for (var i = 1; i < out.length; i++) {
|
|
|
|
if (out[i].length > 5) {
|
|
|
|
devices[j++] = out[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < devices.length; i++) {
|
|
|
|
var dv = devices[i].split(/\s+/);
|
|
|
|
$('#device').append("<option value='" + dv[0] + "'>" + devices[i] + "</option>");
|
|
|
|
}
|
|
|
|
layui.form.render();
|
|
|
|
if (devices.length == 1) {
|
|
|
|
var dv = devices[0].split(/\s+/);
|
|
|
|
$('#text').val("adb -s " + dv[0] + " install \"" + path + "\"");
|
|
|
|
|
|
|
|
if (path == null || path == "") {
|
|
|
|
$('#text').val("adb -s " + dv[0] + " ");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log("开始安装:" + path);
|
|
|
|
/* window.adb("adb -s " + dv[0] + " install " + path, (stdout,error) => {
|
|
|
|
console.log("ADB err:"+err)
|
|
|
|
console.log("ADB stdout:"+stdout)
|
|
|
|
console.log("ADB stderr:"+stderr)
|
|
|
|
log(stdout,error);
|
|
|
|
}) */
|
|
|
|
install();
|
|
|
|
} else if (devices.length > 1) {
|
|
|
|
log("请选择设备");
|
|
|
|
if (path == null || path == "") {
|
|
|
|
$('#text').val("adb -s " + dv[0] + " ");
|
|
|
|
} else {
|
|
|
|
$('#text').val("adb -s " + dv[0] + " install \"" + path + "\"");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log("没有连接设备");
|
|
|
|
}
|
|
|
|
})
|
2022-08-24 21:12:13 +08:00
|
|
|
|
2020-01-10 15:09:55 +08:00
|
|
|
}
|
|
|
|
$('#showPack').click(function () {
|
2022-08-24 21:21:27 +08:00
|
|
|
var dv = devices[0].split(/\s+/);
|
|
|
|
window.adb("adb -s "+dv[0]+" shell pm list package", (stdout, error) => {
|
2022-08-24 21:12:13 +08:00
|
|
|
if (error == true) {
|
2020-01-10 15:09:55 +08:00
|
|
|
log(stdout)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log(stdout)
|
|
|
|
})
|
|
|
|
})
|
2022-08-24 21:12:13 +08:00
|
|
|
$('#show').click(function () {
|
|
|
|
console.log("aapt dump badging \"" + path + "\"")
|
|
|
|
window.adb("aapt dump badging \"" + path + "\"", (stdout, error) => {
|
|
|
|
if (error == true) {
|
2020-01-10 15:09:55 +08:00
|
|
|
log(stdout)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log(stdout)
|
2022-08-24 21:12:13 +08:00
|
|
|
window.adb("aapt dump xmltree \"" + path + "\" AndroidManifest.xml", (stdout, error) => {
|
2020-01-10 15:09:55 +08:00
|
|
|
log(stdout)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2022-08-24 21:12:13 +08:00
|
|
|
$('#showTopActivity').click(function () {
|
2022-08-24 21:21:27 +08:00
|
|
|
var dv = devices[0].split(/\s+/);
|
|
|
|
window.adb("adb -s "+dv[0]+" shell dumpsys window | findstr mCurrentFocus", (data, error) => {
|
2020-01-10 15:09:55 +08:00
|
|
|
log(data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</html>
|