shortx命令
1 subscriber
1 photo
1 file
5 links
Download Telegram
Forwarded from 𝓗𝓮
import android.app.StatusBarManager;
import android.content.Context;

// 获取状态栏管理器
StatusBarManager statusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);

// 尝试隐藏通知和系统信息以及时钟
statusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ICONS | StatusBarManager.DISABLE_SYSTEM_INFO | StatusBarManager.DISABLE_CLOCK);
Forwarded from 𝓗𝓮
import android.app.StatusBarManager;
import android.content.Context;

// 获取状态栏管理器
StatusBarManager statusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);

// 恢复所有图标
statusBarManager.disable(0); // 0表示不禁用任何功能
Forwarded from 𝓗𝓮
import android.content.Context;
import android.view.Surface;
import android.view.WindowManager;

// 获取当前的屏幕方向
WindowManager windowManager = context.getSystemService(Context.WINDOW_SERVICE);
int rotation = windowManager.getDefaultDisplay().getRotation();

//设置当前屏幕方向
android.provider.Settings$System.putInt(context.contentResolver, "user_rotation", rotation);

//关闭自动旋转
android.provider.Settings$System.putInt(context.contentResolver, "accelerometer_rotation", 0);
Forwarded from 𝓗𝓮
import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
import android.os.ServiceManager;
import android.view.SurfaceControl;

// 直接设置电源模式
int displayMode = 0; // 2: 开启, 0: 关闭

if (Build.VERSION.SDK_INT < 34) { // Android 14 之前的版本
// 获取 SurfaceControl 类
CLASS = Class.forName("android.view.SurfaceControl");

// 根据 Android 版本获取显示器 Token 方法
getGetBuiltInDisplayMethod = (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) ?
CLASS.getMethod("getBuiltInDisplay", Integer.TYPE) :
CLASS.getMethod("getInternalDisplayToken");

// 获取显示器 Token
getBuiltInDisplay = (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) ?
getGetBuiltInDisplayMethod.invoke(null, 0) :
getGetBuiltInDisplayMethod.invoke(null);

// 设置电源模式
method = CLASS.getMethod("setDisplayPowerMode", IBinder, Integer.TYPE);
if (displayMode == 0 || displayMode == 2) {
method.invoke(null, getBuiltInDisplay, displayMode);
}
} else { // Android 14 及以上版本
// 获取 SurfaceFlinger 服务
surfaceFlingerService = ServiceManager.getService("SurfaceFlingerAIDL");

// 获取显示器 ID 列表
parcelData = Parcel.obtain();
parcelReply = Parcel.obtain();
parcelData.writeInterfaceToken("android.gui.ISurfaceComposer");
surfaceFlingerService.transact(IBinder.FIRST_CALL_TRANSACTION + 5, parcelData, parcelReply, 0);
parcelReply.readException();
int displayCount = parcelReply.readInt();
long[] displayIds = new long[displayCount];

// 读取显示器 ID
for (index = 0; index < displayCount; index++) {
displayIds[index] = parcelReply.readLong();
}
parcelData.recycle();
parcelReply.recycle();

// 遍历每个显示器,设置电源模式
for (displayId : displayIds) {
// 开启电源模式
parcelData = Parcel.obtain();
parcelReply = Parcel.obtain();
parcelData.writeInterfaceToken("android.gui.ISurfaceComposer");
parcelData.writeLong(displayId);
surfaceFlingerService.transact(IBinder.FIRST_CALL_TRANSACTION + 6, parcelData, parcelReply, 0);
parcelReply.readException();
IBinder displayToken = parcelReply.readStrongBinder();
parcelData.recycle();
parcelReply.recycle();

// 直接调用 SurfaceControl 的方法,设置电源模式
SurfaceControl.setDisplayPowerMode(displayToken, displayMode);
}
}
Forwarded from 𝓗𝓮
import android.content.Context;
import android.view.Surface;
import android.view.WindowManager;

// 获取当前的屏幕方向
WindowManager windowManager = context.getSystemService(Context.WINDOW_SERVICE);
int rotation = windowManager.getDefaultDisplay().getRotation();

//设置当前屏幕方向
android.provider.Settings$System.putInt(context.contentResolver, "user_rotation", rotation);

//关闭自动旋转
android.provider.Settings$System.putInt(context.contentResolver, "accelerometer_rotation", 0);
Forwarded from 𝓗𝓮
import android.os.ServiceManager;
import android.hardware.input.IInputManager;
import android.view.InputDevice; // 导入 InputDevice 类
import android.os.IBinder;

// 获取 IInputManager 接口
IBinder binder = ServiceManager.getService("input");
IInputManager inputManager = IInputManager.Stub.asInterface(binder);

// 获取设备ID
int[] deviceIds = inputManager.getInputDeviceIds();
int touchDeviceId = -1;

// 遍历输入设备并找到触摸设备
for (int id : deviceIds) {
int sources = inputManager.getInputDevice(id).getSources(); // 获取输入设备源
if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
touchDeviceId = id;
}
}

// 如果找到触摸设备,禁用它
if (touchDeviceId != -1) {
// 调用 IInputManager 的禁用方法
inputManager.disableInputDevice(touchDeviceId); // 请替换为实际禁用调用
// 输出禁用的设备 ID
"禁用触摸设备 ID: " + touchDeviceId;
}
Forwarded from 𝓗𝓮
import android.os.ServiceManager;
import android.hardware.input.IInputManager;
import android.view.InputDevice; // 导入 InputDevice 类
import android.os.IBinder;

// 获取 IInputManager 接口
IBinder binder = ServiceManager.getService("input");
IInputManager inputManager = IInputManager.Stub.asInterface(binder);

// 获取设备ID
int[] deviceIds = inputManager.getInputDeviceIds();
int touchDeviceId = -1;

// 遍历输入设备并找到触摸设备
for (int id : deviceIds) {
int sources = inputManager.getInputDevice(id).getSources(); // 获取输入设备源
if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
touchDeviceId = id;
}
}

// 如果找到触摸设备,启用它
if (touchDeviceId != -1) {
// 调用 IInputManager 的启用方法
inputManager.enableInputDevice(touchDeviceId); // 请替换为实际启用调用
// 输出启用的设备 ID
"启用触摸设备 ID: " + touchDeviceId;
}
Forwarded from 𝓗𝓮
import android.content.Intent;
import android.provider.AlarmClock;

// 定义闹钟的属性
String message = "闹钟标签"; // 闹钟标签
int hour = 17; // 闹钟小时(24小时制)
int minutes = 30; // 闹钟分钟

// 创建一个系统闹钟的 Intent
Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, message);
alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, hour);
alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, minutes);
alarmIntent.putExtra(AlarmClock.EXTRA_SKIP_UI, true); // 设置跳过UI

// 为 Intent 添加 FLAG_ACTIVITY_NEW_TASK 标志
alarmIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

// 发送 Intent,设置系统闹钟
context.startActivity(alarmIntent);

// 返回设置成功的信息
return "系统闹钟已设置成功";
Forwarded from Prslc
// 使用mvel写入文件
import java.io.*;
// 定义文件路径
String FilePath="/data/media/0/Download/1.txt";
// false为覆盖模式,true为追加模式
FileWriter file = new FileWriter(FilePath,false);
// 写入的内容
file.write("test");
// 关闭文件写入,如果没有这条内容无法正常写入
file.close()
Forwarded from kuro
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
String path = "/sdcard/Download/test.jpg";
Bitmap img = BitmapFactory.decodeFile(path);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
img.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bytes = stream.toByteArray();
String code = Base64.encodeToString(bytes,Base64.NO_WRAP);
code

这个mvel的功能就是把本地一个图片转换为Android的bitmap对象,然后转换为字节数组,然后base64编码。我这运行报错了,我需要一点帮助
Forwarded from Prslc
使用包名获取应用名
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

def apkname(context, app) {
// 获取PackageManager实例,用于管理应用程序
PackageManager packageManager = context.getPackageManager();

// 获取指定包名的应用信息
ApplicationInfo appInfo = packageManager.getApplicationInfo(app, 0);

// 获取应用名称
String appName = packageManager.getApplicationLabel(appInfo).toString();

return "应用名称: " + appName;
}

apkname(context, "org.telegram.messenger");
//将后面的内容修改为你需要的包名
Forwarded from 𝓗𝓮
//应用是否被冻结,用作条件
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

// 定义需要检查的应用包名
String targetPackageName = "包名";

// 获取PackageManager实例,用于管理应用程序
PackageManager packageManager = context.getPackageManager();


// 获取指定包名的应用信息
ApplicationInfo appInfo = packageManager.getApplicationInfo(targetPackageName, 0);

// 获取应用的启用状态
Boolean isApplicationEnabled =! appInfo.enabled;

//true代表已经被冻结
Forwarded from 𝓗𝓮
import java.io.File;
import java.util.Scanner;

// 读取文件内容
new Scanner(new File("/data/media/0/newfile.txt")).useDelimiter("\\Z").next()
Forwarded from 𝓗𝓮
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;

// 创建表示目录的File对象
File directory = new File("/data/media/0");

// 定义要创建的文件名
String newFileName = "newfile.txt";
File newFile = new File(directory, newFileName);

// 检查目录是否存在,如果不存在则创建目录
if (!directory.exists()) {
directory.mkdirs();
}

// 如果文件已存在,输出文件存在提示;否则创建新文件
if (newFile.exists()) {
return newFileName + " 文件已经存在。";
} else {
// 创建新文件
if (newFile.createNewFile()) {
return newFileName + " 文件已创建。";
}
else {
return "创建文件时发生错误。";
}
}
Forwarded from 𝓗𝓮
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;

// 创建表示目录的File对象
File directory = new File("/data/media/0");

// 获取目录中的所有文件和子目录
File[] files = directory.listFiles();

// 定义要读取的文件名
String targetFileName = "2.html";

File targetFile = new File(directory, targetFileName);

// 检查文件是否存在并且是一个文件
if (targetFile.exists() && targetFile.isFile()) {
// 读取文件内容
String content = new String(Files.readAllBytes(Paths.get(targetFile.getPath())), StandardCharsets.UTF_8);
// 返回文件路径和内容
return targetFileName + " 文件内容:\n" + content;
} else {
// 如果文件不存在,返回提示信息
return targetFileName + " 文件不存在。";
}
Forwarded from 𝓗𝓮
import java.io.File;

// 创建表示目录的File对象
File directory = new File("/data/media/0");

// 获取目录中的所有文件和子目录
File[] files = directory.listFiles();

// 检查是否成功获取文件列表
if (files != null) {
StringBuilder result = new StringBuilder();
// 遍历文件列表,并将每个文件名添加到结果字符串中
for (File file : files) {
result.append(file.getName()).append("\n");
}
// 输出结果字符串
return result.toString();
} else {
// 如果目录不存在或为空,输出提示信息
return "找不到指定目录或者目录为空。";
}
Forwarded from 𝓗𝓮
import android.content.Context;
import android.content.pm.PackageManager;

String packageName = "包名";

PackageManager packageManager = context.getPackageManager();

// 清除指定包的缓存数据
packageManager.deleteApplicationCacheFiles(packageName, null);
Forwarded from 𝓗𝓮
// 清除指定包的应用数据
packageManager.clearApplicationUserData(packageName, null);

自行替换
Forwarded from 𝓗𝓮
import java.util.HashSet;
import java.util.Set;

String text1 = "Hello";
String text2 = "Hell64664os";

// 计算两个字符串的Jaccard相似度
def jaccardSimilarity(str1,str2) {
Set set1 = new HashSet(); // 存储第一个字符串的字符集合
Set set2 = new HashSet(); // 存储第二个字符串的字符集合

// 将第一个字符串的字符添加到集合set1中
for (char c : str1.toCharArray()) {
set1.add(c);
}

// 将第二个字符串的字符添加到集合set2中
for (char c : str2.toCharArray()) {
set2.add(c);
}

// 创建集合intersection存储set1和set2的交集
Set intersection = new HashSet(set1);
intersection.retainAll(set2); // 只保留交集部分

int commonCount = intersection.size(); // 交集的大小
int totalUniqueCount = set1.size() + set2.size() - commonCount; // 并集的大小

// 计算Jaccard相似度并返回
return (double) commonCount / totalUniqueCount;
}

double similarityScore = jaccardSimilarity(text1, text2);

// 四舍五入并保留两位小数
String formattedScore = String.format("%.2f", similarityScore);

// 打印Jaccard相似度分数
return "Jaccard 相似分数: " + formattedScore;
Forwarded from 𝓗𝓮
import java.net.HttpURLConnection;
import java.net.URL;

// 创建一个URL对象,指向百度网站
URL url = new URL("https://baidu.com");

// 打开一个HTTP连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

// 设置HTTP请求方法为GET
connection.setRequestMethod("GET");

// 设置连接超时时间为1秒
connection.setReadTimeout(1000); // 1秒

// 获取HTTP响应码
int responseCode = connection.getResponseCode();

// 如果收到的状态码不是在400-499范围内,则输出网络连接正常
if (responseCode < 400 || responseCode >= 500) {
("网络连接正常");
}