Forwarded from 𝓗𝓮
audioManager = context.getSystemService("audio");
// 获取指定音量类型的音量值并返回
function getVolumeInfo(context, streamType) {
volume = android.os.ServiceManager.getService("audio").getStreamVolume(streamType);
return volume;
}
getVolumeInfo(context, audioManager.STREAM_RING);
// 获取当前铃声音量
// 获取指定音量类型当前音量#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
audioManager = context.getSystemService("audio");
function getVolumeInfo(context, streamType, targetVolume) {
volume = android.os.ServiceManager.getService("audio").setStreamVolume(streamType, targetVolume, 0, null);
return volume;
}
getVolumeInfo(context, audioManager.STREAM_ALARM, 7);
// 设置闹钟音量
// 设置指定音量类型#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
audioManager = context.getSystemService("audio");
audio =android.os.ServiceManager.getService("audio");
function getVolumeInfo(context, streamType, targetVolume) {
currentVolume = audio.getStreamVolume(streamType);
newVolume = currentVolume + targetVolume;
maxVolume = audio.getStreamMaxVolume(streamType);
minVolume = 0;
newVolume = Math.max(minVolume, Math.min(newVolume, maxVolume));
audio.setStreamVolume(streamType, newVolume, 0, null);
return newVolume;
}
getVolumeInfo(context, audioManager.STREAM_ALARM, 2);
// 调整闹钟音量(比如2 或 -2)
// 调节指定音量类型#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
audioManager = context.getSystemService("audio");
audio =android.os.ServiceManager.getService("audio");
function getVolumeInfo(context, streamType, targetVolume) {
currentVolume = audio.getStreamVolume(streamType);
maxVolume = audio.getStreamMaxVolume(streamType);
return maxVolume;
}
getVolumeInfo(context, audioManager.STREAM_ALARM);
// 获取指定音量类型的上限#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
/*
* 显示刷新率开关控制函数
* 0 = 关闭
* 1 = 开启
* 2 = 查询当前状态(返回 true/false)
* 3 = 切换(打开→关 / 关→开)
*/
function showRefreshRate(mode) {
sf = android.os.ServiceManager.getService("SurfaceFlinger");
function call(flag, needReply) {
data = android.os.Parcel.obtain();
reply = needReply ? android.os.Parcel.obtain() : null;
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(flag);
sf.transact(1034, data, reply, 0);
return reply;
}
if (mode == 3) {
current = call(2, true).readBoolean();
call(current ? 0 : 1, false);
return !current;
}
// mode: 0=关 1=开 2=查
if (mode == 2) {
return call(2, true).readBoolean();
} else {
call(mode, false);
return mode == 1;
}
}
// 切换显示屏刷新率显示开关
showRefreshRate(3);
#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
modes = (android.os.ServiceManager.getService("display").getDisplayInfo(android.view.Display.DEFAULT_DISPLAY)).supportedModes;
s = "";
for (i = 0; i < modes.length; i++) {
m = modes[i];
s += "id=" + m.getModeId() + ": " + m.getRefreshRate() + "Hz\n";
}
s.trim();
// 获取当前显示屏支持的刷新率以及对应ID#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
/*
* 强制锁定指定刷新率
*/
function lockRefreshRate(modeId) {
realMode = modeId - 1;
sf = android.os.ServiceManager.getService("SurfaceFlinger");
data = android.os.Parcel.obtain();
data.writeInterfaceToken("android.ui.ISurfaceComposer");
data.writeInt(realMode);
sf.transact(1035, data, null, 0);
}
// 重启需重新设置,个别系统锁屏后也会失效,自己测试。
// 改成自己想锁定的刷新率对应ID,不要乱填
lockRefreshRate(1);
#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
importClass(Packages.github.tornaco.android.thanos.core.app.ThanosManagerNative);
var iThanos = ThanosManagerNative.getDefault();
var pkgManager = iThanos.getPkgManager();
result = pkgManager.createPackageSet("测试创建集合");
#Javascript
Forwarded from 𝓗𝓮
//给指定应用动态快捷方式添加指定Intent URI
importClass(android.content.Context);
importClass(android.content.pm.ShortcutInfo);
importClass(android.graphics.drawable.Icon);
importClass(android.content.Intent);
importClass(java.util.ArrayList);
importClass(java.util.Collections);
// ===== 目标包名 =====
var targetPackage = "tornaco.apps.shortx";
// ===== 指定要写入的 Intent URI =====
var intentUri = `intent:#Intent;action=com.tmessages.openchat0;component=org.telegram.messenger/.OpenChatReceiver;l.chatId=1604486631;end`;
try {
var otherContext = context.createPackageContext(
targetPackage,
Context.CONTEXT_IGNORE_SECURITY
);
var shortcutManager =
otherContext.getSystemService(Context.SHORTCUT_SERVICE);
if (!shortcutManager) {
throw "ShortcutManager 不可用";
}
var targetIntent = Intent.parseUri(intentUri, 0);
targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// ===== 新快捷方式ID=====
//ID用来区分不同的快捷方式,删除也必须使用同样ID
var shortcutId = "shortcut_0001";
var newShortcut =
new ShortcutInfo.Builder(otherContext, shortcutId)
//快捷方式 桌面显示名称
.setShortLabel("ShortX群组")
//长名称
.setLongLabel("ShortX群组")
.setIcon(
Icon.createWithResource(
otherContext,
otherContext.getApplicationInfo().icon
)
)
.setIntent(targetIntent)
.build();
var existing = shortcutManager.getDynamicShortcuts();
if (existing.size() >= shortcutManager.getMaxShortcutCountPerActivity()) {
throw "动态快捷方式数量已达系统上限";
}
shortcutManager.addDynamicShortcuts(
Collections.singletonList(newShortcut)
);
shortcutId;
} catch (e) {
"写入失败: " + e;
}
#Javascript
Forwarded from 𝓗𝓮
// 删掉指定应用指定动态快捷方式
importClass(android.content.Context);
importClass(android.content.pm.ShortcutManager);
importClass(java.util.Collections);
// ================= 目标应用包名 =================
var targetPackage = "包名"; // ← 可修改为任意 app 包名
try {
// 获取目标应用上下文
var otherContext = context.createPackageContext(
targetPackage,
Context.CONTEXT_INCLUDE_CODE |
Context.CONTEXT_IGNORE_SECURITY |
Context.CONTEXT_DEVICE_PROTECTED_STORAGE |
Context.CONTEXT_REGISTER_PACKAGE
);
// 获取系统服务 ShortcutManager
var shortcutManager = otherContext.getSystemService(Context.SHORTCUT_SERVICE);
if (shortcutManager == null) {
console.log("❌ 此设备不支持 ShortcutManager。");
JSON.stringify([]);
}
// ================= 删除指定 ID 的动态快捷方式 =================
var shortcutId = "shortcut_1759818721903"; // ← 只删这个 ID
var list = java.util.Collections.singletonList(shortcutId);
shortcutManager.removeDynamicShortcuts(list);
"✅ 已删除 " + targetPackage + " 的快捷方式 ID: " + shortcutId;
} catch (e) {
console.log("❌ 删除快捷方式出错: " + e);
JSON.stringify([]);
}
#Javascript
Forwarded from 𝓗𝓮
// 使用指定语法解析HTML
importPackage(Packages.org.jsoup);
var htmlContent = `<html><body><h1>这是一个标题</h1><p>这是段落内容。</p></body></html>`;
// 解析 HTML
var document = Jsoup.parse(htmlContent);
// 获取 p 标签
var pElement = document.select("p").first();
// 提取 p 标签的文本内容
pText = pElement.text();
#Javascript
Forwarded from 𝓗𝓮
importClass(Packages.tornaco.apps.shortx.core.proto.action.OcrDetect);
importClass(Packages.tornaco.apps.shortx.core.proto.common.RectSourceRect);
importClass(Packages.tornaco.apps.shortx.core.proto.common.Rect);
importClass(com.google.protobuf.Any);
var action = OcrDetect.newBuilder()
.setRectSrc(
Any.pack(
RectSourceRect.newBuilder()
.setRect(
Rect.newBuilder()
.setLeft("")
.setTop("")
.setRight("")
.setBottom("")
.build()
)
.build()
)
)
.build();
var result = shortx.executeAction(action);
result.contextData.get("ocrResult")
// 输入屏幕区域
#Javascript
Forwarded from 𝓗𝓮
importPackage(android.bluetooth);
importPackage(android.content);
importClass(java.util.concurrent.CountDownLatch);
importClass(java.util.concurrent.TimeUnit);
function enableBt() {
var a = BluetoothAdapter.getDefaultAdapter();
if (a == null) throw new Error("不支持蓝牙");
a.enable();
return a;
}
function withPan(adapter, fn) {
var latch = new CountDownLatch(1);
var out = { v: false };
adapter.getProfileProxy(context, new BluetoothProfile.ServiceListener({
onServiceConnected: function(p, proxy) {
if (p == BluetoothProfile.PAN) {
out.v = fn(proxy);
adapter.closeProfileProxy(BluetoothProfile.PAN, proxy);
}
latch.countDown();
},
onServiceDisconnected: function() {
latch.countDown();
}
}), BluetoothProfile.PAN);
latch.await(2, TimeUnit.SECONDS);
return out.v;
}
function toggleBluetoothTethering(context) {
var adapter = enableBt();
var state = withPan(adapter, function(p) { return p.isTetheringOn(); });
withPan(adapter, function(p) { p.setBluetoothTethering(!state); });
return state ? "蓝牙网络共享已关闭" : "蓝牙网络共享已开启";
}
toggleBluetoothTethering(context);
// 通过蓝牙共享手机的网络连接
#Javascript
Forwarded from 𝓗𝓮
android.os.ServiceManager.getService("ethernet").setEthernetEnabled(true);
// false 关闭
// 通过以太网共享手机的网络连接#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
android.os.ServiceManager.getService("usb").setCurrentFunctions(32, 0);
// 通过 USB 共享手机的网络连接#MVEL表达式 #Javascript
Forwarded from 𝓗𝓮
𝓗𝓮
android.os.ServiceManager.getService("usb").isFunctionEnabled("adb"); /* rndis → USB共享网络 none → 仅充电 mtp → 文件传输 ptp → 图片传输 adb → 设备调试 */ // 检查USB功能是否启用(如adb、mtp) #MVEL表达式 #Javascript
android.os.ServiceManager.getService("usb").setCurrentFunctions(4, 0);
// 开启USB文件传输模式
/*
none → 仅充电 → 0
adb → 设备调试 → 1
accessory → 外设模式 → 2
mtp → 文件传输 → 4
midi → MIDI → 8
ptp → 图片传输 → 16
rndis → USB共享网络 → 32
audio_source → USB音频 → 64
uvc → USB摄像头 → 128
ncm → USB网络(NCM) → 1024
*/#MVEL表达式 #Javascript
var clazz = shortx .getClass();
var className = clazz.getName();
var methods = clazz.getMethods();
var methodNames = [];
for (var i = 0; i < methods.length; i++) {
methodNames.push(methods[i].getName());
}
var uniqueMethods = Array.from(new java.util.HashSet(methodNames));
"class: " + className + "\nnums: " + uniqueMethods.length + "\n" + uniqueMethods.join("\n");
获取shortx公开的方法
Forwarded from 𝓗𝓮
ShortX新版本提供了一个新方法,
通过
这是目前支持的Api,不懂啥意思,问AI就行。
getUiAutomation
通过
shortx.getUiAutomation()调用。boolean clearCache();
void connect();
void disconnect();
boolean dispatchGesture(GestureDescription, GestureResultCallback, Handler);
AccessibilityNodeInfo findFocus(int);
AccessibilityNodeInfo getRootInActiveWindow();
AccessibilityServiceInfo getServiceInfo();
List getWindows();
boolean injectInputEvent(InputEvent, boolean);
boolean isCacheEnabled();
boolean isConnected();
void performAccessibilityAction(long, int, int);
boolean performGlobalAction(int);
void waitForIdle(long, long);
这是目前支持的Api,不懂啥意思,问AI就行。
Forwarded from 𝓗𝓮
importClass(Packages.tornaco.apps.shortx.core.proto.action.ShowListDialog);
importClass(Packages.tornaco.apps.shortx.core.proto.action.ShowListDialogDataType);
importClass(Packages.tornaco.apps.shortx.core.proto.common.DialogUiStyleSettings);
var dataJson = `[
{
"name": "Android",
"version": 16,
"__value": "android",
"__icon": "android-fill"
},
{
"name": "Ubuntu",
"version": 24,
"summary": "Ubuntu is the modern, open source operating system on Linux for the enterprise server, desktop, cloud, and IoT.",
"__value": "ubuntu",
"__icon": "ubuntu-fill"
}
]`;
// ShowListDialog Action
var action = ShowListDialog.newBuilder()
.setTitle("choose")
.setData(dataJson)
.setDataType(ShowListDialogDataType.ShowListDialogDataType_Json)
.setStyle(
DialogUiStyleSettings.newBuilder()
.setFontScale(1.0)
.build()
)
.setIsMultipleChoice(true)
// Show bottom OK button
.setNeedConfirmAction(true)
// Support multiple selection
.setCancelable(true)
// Can it be cancelled
.build();
var result = shortx.executeAction(action);
result.contextData.get("selectedListItem");