refactor(ChangeDeviceInfoUtil, MainActivity): enhance package processing null-check, cleanup unused variables

- Introduced null-checks for `packageInfo` in `ChangeDeviceInfoUtil` package processing to improve error handling.
- Removed redundant `scriptResult` assignment in `MainActivity` for cleaner execution logic.
- Updated APK and baseline profile files for release configuration.
This commit is contained in:
Administrator 2025-06-25 10:56:53 +08:00
parent cd09538426
commit 1652482e79
27 changed files with 840 additions and 488 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<bytecodeTargetLevel target="21" /> <bytecodeTargetLevel target="17" />
</component> </component>
</project> </project>

View File

@ -4,7 +4,7 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-06-19T05:28:08.364804100Z"> <DropdownSelection timestamp="2025-06-23T04:03:54.535123700Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=LMV500N03f5c1fc" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=LMV500N03f5c1fc" />

View File

@ -14,6 +14,7 @@
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

BIN
agentkey.jks Normal file

Binary file not shown.

View File

@ -74,6 +74,8 @@ dependencies {
// RxJava // RxJava
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0' implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
implementation 'org.nanohttpd:nanohttpd:2.3.1'
// Mockito // Mockito
testImplementation 'org.mockito:mockito-core:5.4.0' testImplementation 'org.mockito:mockito-core:5.4.0'

Binary file not shown.

View File

@ -26,7 +26,11 @@
<uses-permission android:name="android.permission.MEDIA_PROJECTION" /> <uses-permission android:name="android.permission.MEDIA_PROJECTION" />
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
</intent>
</queries>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
@ -63,6 +67,7 @@
android:name="android.accessibilityservice" android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" /> android:resource="@xml/accessibility_service_config" />
</service> </service>
</application> </application>
<queries> <queries>
<package android:name="org.autojs.autojs6" /> <package android:name="org.autojs.autojs6" />

View File

@ -34,7 +34,11 @@ import com.example.studyapp.device.ChangeDeviceInfoUtil;
import com.example.studyapp.proxy.ClashUtil; import com.example.studyapp.proxy.ClashUtil;
import com.example.studyapp.service.MyAccessibilityService; import com.example.studyapp.service.MyAccessibilityService;
import com.example.studyapp.task.TaskUtil; import com.example.studyapp.task.TaskUtil;
import com.example.studyapp.utils.LogFileUtil;
import com.example.studyapp.utils.ShellUtils;
import com.example.studyapp.worker.CheckAccessibilityWorker; import com.example.studyapp.worker.CheckAccessibilityWorker;
import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -92,6 +96,7 @@ public class MainActivity extends AppCompatActivity {
*/ */
private String getAndroidId(Context context) { private String getAndroidId(Context context) {
if (context == null) { if (context == null) {
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "getAndroidId: Context cannot be null",null);
throw new IllegalArgumentException("Context cannot be null"); throw new IllegalArgumentException("Context cannot be null");
} }
try { try {
@ -100,26 +105,27 @@ public class MainActivity extends AppCompatActivity {
Settings.Secure.ANDROID_ID Settings.Secure.ANDROID_ID
); );
} catch (Exception e) { } catch (Exception e) {
Log.e("MainActivity", "getAndroidId: Failed to get ANDROID_ID", e); LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "getAndroidId: Failed to get ANDROID_ID",e);
return null; return null;
} }
} }
private static final int REQUEST_CODE_PERMISSIONS = 100; private static final int REQUEST_CODE_PERMISSIONS = 100;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
LogFileUtil.initialize(this);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
instance = new WeakReference<>(this); instance = new WeakReference<>(this);
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "onCreate: Initializing application",null);
initializeExecutorService(); initializeExecutorService();
System.setProperty("java.library.path", this.getApplicationInfo().nativeLibraryDir); System.setProperty("java.library.path", this.getApplicationInfo().nativeLibraryDir);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
// 针对 Android 10 或更低版本检查普通存储权限
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED != PackageManager.PERMISSION_GRANTED) {
) {
ActivityCompat.requestPermissions( ActivityCompat.requestPermissions(
this, this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
@ -127,45 +133,38 @@ public class MainActivity extends AppCompatActivity {
); );
} }
} else { } else {
// 针对 Android 11 及更高版本检查全文件管理权限
if (!Environment.isExternalStorageManager()) { if (!Environment.isExternalStorageManager()) {
// 请求权限
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
intent.setData(Uri.parse("package:" + getPackageName())); intent.setData(Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, ALLOW_ALL_FILES_ACCESS_PERMISSION_CODE); startActivityForResult(intent, ALLOW_ALL_FILES_ACCESS_PERMISSION_CODE);
} }
} }
// 添加对 FOREGROUND_SERVICE 权限的检查和请求
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { // 判断 Android 13+
String[] requiredPermissions = {
android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION,
"android.permission.CAPTURE_VIDEO_OUTPUT"
};
ActivityCompat.requestPermissions(this, requiredPermissions, REQUEST_CODE_PERMISSIONS);
} else {
Toast.makeText(this, "当前设备不支持这些权限", Toast.LENGTH_SHORT).show();
}
if (!isNetworkAvailable(this)) { if (!isNetworkAvailable(this)) {
Toast.makeText(this, "Network is not available", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Network is not available", Toast.LENGTH_SHORT).show();
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "Network not available, closing app.",null);
finish(); finish();
} }
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "onCreate: Setting up work manager",null);
PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(CheckAccessibilityWorker.class, 15, TimeUnit.MINUTES) PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(CheckAccessibilityWorker.class, 15, TimeUnit.MINUTES)
.build(); .build();
WorkManager.getInstance(this).enqueue(workRequest); WorkManager.getInstance(this).enqueue(workRequest);
// 初始化按钮 LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "onCreate: Setting up UI components",null);
Button runScriptButton = findViewById(R.id.run_script_button); Button runScriptButton = findViewById(R.id.run_script_button);
if (runScriptButton != null) { if (runScriptButton != null) {
runScriptButton.setOnClickListener(v -> AutoJsUtil.runAutojsScript(this)); runScriptButton.setOnClickListener(v -> AutoJsUtil.runAutojsScript(this));
} else { } else {
LogFileUtil.logAndWrite(Log.WARN, "MainActivity", "Run Script Button not found",null);
Toast.makeText(this, "Button not found", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Button not found", Toast.LENGTH_SHORT).show();
} }
Button connectButton = findViewById(R.id.connectVpnButton); Button connectButton = findViewById(R.id.connectVpnButton);
if (connectButton != null) { if (connectButton != null) {
connectButton.setOnClickListener(v -> startProxyVpn(this)); connectButton.setOnClickListener(v -> {
String chmodResult = ShellUtils.execRootCmdAndGetResult("pm uninstall com.rovio.baba");
});
// connectButton.setOnClickListener(v -> startProxyVpn(this));
} else { } else {
Toast.makeText(this, "Connect button not found", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Connect button not found", Toast.LENGTH_SHORT).show();
} }
@ -228,78 +227,85 @@ public class MainActivity extends AppCompatActivity {
} }
} }
private void executeLogic(String androidId,String taskId) { private void executeLogic(String androidId, String taskId) {
Log.i("MainActivity", "executeLogic: Start execution"); LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeLogic: Start execution",null);
if (!isNetworkAvailable(this)) { if (!isNetworkAvailable(this)) {
Log.e("MainActivity", "executeLogic: Network is not available!"); LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "executeLogic: Network is not available!",null);
Toast.makeText(this, "网络不可用,请检查网络连接", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "网络不可用,请检查网络连接", Toast.LENGTH_SHORT).show();
return; return;
} }
Log.i("MainActivity", "executeLogic: Submitting job to executor");
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeLogic: Submitting job to executor",null);
initializeExecutorService(); initializeExecutorService();
executorService.submit(() -> { executorService.submit(() -> {
try { try {
AutoJsUtil.registerScriptResultReceiver(this); AutoJsUtil.registerScriptResultReceiver(this);
AutoJsUtil.flag = true; // 广播状态更新 AutoJsUtil.flag = true;
while (true) { while (isRunning) {
synchronized (taskLock) { // synchronized (taskLock) {
while (!AutoJsUtil.flag) { // while (!AutoJsUtil.flag && isRunning) {
taskLock.wait(30000); // taskLock.wait(30000);
} // }
executeSingleLogic(); //
TaskUtil.execSaveTask(this, androidId,taskId); //
if (scriptResult != null && !TextUtils.isEmpty(scriptResult)) { // AutoJsUtil.flag = false;
infoUpload(this, androidId, scriptResult); // }
} if (!isRunning) break;
// 从队列中获取最新的 scriptResult
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeSingleLogic: Running AutoJs script",null);
ChangeDeviceInfoUtil.getDeviceInfo(taskId, androidId);
executeSingleLogic();
String currentScriptResult = scriptResultQueue.take();
TaskUtil.execSaveTask(this, androidId, taskId, currentScriptResult);
LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "----发送result------;" + currentScriptResult, null);
if (currentScriptResult != null && !TextUtils.isEmpty(currentScriptResult)) {
infoUpload(this, androidId, currentScriptResult);
} }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("MainActivity", "executeLogic: Thread interrupted while waiting", e); Thread.currentThread().interrupt();
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "executeLogic: Thread interrupted while waiting", e);
} catch (Exception e) { } catch (Exception e) {
Log.e("MainActivity", "executeLogic: Unexpected task error.", e); LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "executeLogic: Unexpected task error.", e);
} }
}); });
} }
public static final LinkedBlockingQueue<String> scriptResultQueue = new LinkedBlockingQueue<>();
private volatile boolean isRunning = true; // 主线程运行状态
public static final Object taskLock = new Object(); // 任务逻辑锁 public static final Object taskLock = new Object(); // 任务逻辑锁
public void executeSingleLogic() { public void executeSingleLogic() {
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeSingleLogic: Proxy not active, starting VPN",null);
Log.i("MainActivity", "executeSingleLogic: Proxy not active, starting VPN");
startProxyVpn(this); startProxyVpn(this);
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeSingleLogic: Changing device info",null);
try {
ClashUtil.switchProxyGroup("GLOBAL", "us", "http://127.0.0.1:6170");
} catch (Exception e) {
Log.e("MainActivity", "executeSingleLogic: Failed to switch proxy group", e);
runOnUiThread(() -> Toast.makeText(this, "切换代理组失败:" + e.getMessage(), Toast.LENGTH_SHORT).show());
}
Log.i("MainActivity", "executeSingleLogic: Changing device info");
ChangeDeviceInfoUtil.changeDeviceInfo(getPackageName(), this); ChangeDeviceInfoUtil.changeDeviceInfo(getPackageName(), this);
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "executeSingleLogic: Running AutoJs script",null);
Log.i("MainActivity", "executeSingleLogic: Running AutoJs script");
AutoJsUtil.runAutojsScript(this); AutoJsUtil.runAutojsScript(this);
} }
private void startProxyVpn(Context context) { private void startProxyVpn(Context context) {
if (!isNetworkAvailable(context)) { if (!isNetworkAvailable(context)) {
Toast.makeText(context, "Network is not available", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Network is not available", Toast.LENGTH_SHORT).show();
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "startProxyVpn: Network is not available.",null);
return; return;
} }
if (!(context instanceof Activity)) { if (!(context instanceof Activity)) {
Toast.makeText(context, "Context must be an Activity", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Context must be an Activity", Toast.LENGTH_SHORT).show();
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "startProxyVpn: Context is not an Activity.",null);
return; return;
} }
try { try {
ClashUtil.startProxy(context); // 在主线程中调用 ClashUtil.startProxy(context); // 在主线程中调用
} catch (IllegalStateException e) { ClashUtil.switchProxyGroup("GLOBAL", "us", "http://127.0.0.1:6170");
Toast.makeText(context, "Failed to start VPN: VPN Service illegal state", Toast.LENGTH_SHORT).show();
} catch (Exception e) { } catch (Exception e) {
LogFileUtil.logAndWrite(Log.ERROR, "MainActivity", "startProxyVpn: Failed to start VPN",e);
Toast.makeText(context, "Failed to start VPN: " + (e.getMessage() != null ? e.getMessage() : "Unknown error"), Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Failed to start VPN: " + (e.getMessage() != null ? e.getMessage() : "Unknown error"), Toast.LENGTH_SHORT).show();
} }
} }
@ -377,13 +383,19 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
LogFileUtil.logAndWrite(Log.INFO, "MainActivity", "onDestroy: Cleaning up resources",null);
super.onDestroy(); super.onDestroy();
instance.clear(); instance.clear();
if (AutoJsUtil.scriptResultReceiver != null) { if (AutoJsUtil.scriptResultReceiver != null) {
unregisterReceiver(AutoJsUtil.scriptResultReceiver); unregisterReceiver(AutoJsUtil.scriptResultReceiver);
AutoJsUtil.scriptResultReceiver = null;
} }
if (executorService != null) { if (executorService != null) {
executorService.shutdown(); // 关闭线程池 executorService.shutdown();
}
isRunning = false;
synchronized (taskLock) {
taskLock.notifyAll();
} }
} }

View File

@ -0,0 +1,4 @@
package com.example.studyapp
class ScriptRepository {
}

View File

@ -1,6 +1,5 @@
package com.example.studyapp.autoJS; package com.example.studyapp.autoJS;
import static com.example.studyapp.MainActivity.taskLock; import static com.example.studyapp.MainActivity.taskLock;
import static com.example.studyapp.task.TaskUtil.downloadCodeFile; import static com.example.studyapp.task.TaskUtil.downloadCodeFile;
@ -12,13 +11,12 @@ import android.content.pm.PackageManager;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.example.studyapp.MainActivity; import com.example.studyapp.MainActivity;
import com.example.studyapp.utils.LogFileUtil;
import com.example.studyapp.utils.ShellUtils; import com.example.studyapp.utils.ShellUtils;
import java.io.File; import java.io.File;
@ -31,13 +29,14 @@ public class AutoJsUtil {
public static void runAutojsScript(Context context) { public static void runAutojsScript(Context context) {
// 检查脚本文件 // 检查脚本文件
Log.i("AutoJsUtil", "-------脚本运行开始:--------" + count++); LogFileUtil.logAndWrite(android.util.Log.INFO, "AutoJsUtil", "-------脚本运行开始:--------" + count++,null);
File scriptDir = new File(Environment.getExternalStorageDirectory(), "script"); File scriptDir = new File(Environment.getExternalStorageDirectory(), "script");//todo
scriptDir.delete(); scriptDir.delete();
// File scriptFile = new File(scriptDir, "main.js");
File scriptFile = downloadCodeFile("main.js", scriptDir); File scriptFile = downloadCodeFile("main.js", scriptDir);
if (scriptFile == null || !scriptFile.exists()) { if (scriptFile == null || !scriptFile.exists()) {
runOnUiThread(() -> Toast.makeText(context, "下载脚本文件失败", Toast.LENGTH_SHORT).show()); runOnUiThread(() -> Toast.makeText(context, "下载脚本文件失败", Toast.LENGTH_SHORT).show());
Log.e("AutoJsUtil", "下载脚本文件失败"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "AutoJsUtil", "下载脚本文件失败",null);
return; return;
} }
@ -54,44 +53,44 @@ public class AutoJsUtil {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try { try {
context.startActivity(intent); context.startActivity(intent);
flag = false; LogFileUtil.logAndWrite(android.util.Log.INFO, "AutoJsUtil", "脚本运行中:" + scriptFile.getAbsolutePath(),null);
Log.i("AutoJsUtil", "脚本运行中:" + scriptFile.getAbsolutePath());
} catch (Exception e) { } catch (Exception e) {
Log.e("AutoJsUtil", "运行脚本失败", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "AutoJsUtil", "运行脚本失败",e);
runOnUiThread(() -> Toast.makeText(context, "运行脚本失败: " + e.getMessage(), Toast.LENGTH_SHORT).show()); runOnUiThread(() -> Toast.makeText(context, "运行脚本失败: " + e.getMessage(), Toast.LENGTH_SHORT).show());
} }
// 注意unregisterScriptResultReceiver 不应到此时立即调用
} }
public static void registerScriptResultReceiver(Context context) { public static void registerScriptResultReceiver(Context context) {
if (scriptResultReceiver == null) { if (scriptResultReceiver == null) {
// 创建广播接收器 // 创建广播接收器
scriptResultReceiver = new BroadcastReceiver() { scriptResultReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.d("MainActivity", "----脚本运行结束通知一次------; 当前线程:" + Thread.currentThread().getName()); LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "----脚本运行结束通知一次------; 当前线程:" + Thread.currentThread().getName(), null);
String scriptResult = intent.getStringExtra(SCRIPT_RESULT_KEY); String scriptResult = intent.getStringExtra(SCRIPT_RESULT_KEY);
synchronized (taskLock) { try {
AutoJsUtil.flag = true; MainActivity.scriptResultQueue.put(scriptResult); // 将结果加入队列
MainActivity.scriptResult = scriptResult; LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "----收到result------;" + scriptResult, null);
taskLock.notifyAll(); // 唤醒任务线程 // AutoJsUtil.flag = true; // 唤醒
// taskLock.notifyAll();
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 处理中断
} }
} }
}; };
// 注册广播接收器 // 注册广播接收器
try { try {
IntentFilter filter = new IntentFilter(AUTOJS_SCRIPT_FINISHED_ACTION); IntentFilter filter = new IntentFilter(AUTOJS_SCRIPT_FINISHED_ACTION);
Context appContext = context.getApplicationContext(); Context appContext = context.getApplicationContext();
ContextCompat.registerReceiver(appContext, scriptResultReceiver, filter, ContextCompat.RECEIVER_EXPORTED); ContextCompat.registerReceiver(appContext, scriptResultReceiver, filter, ContextCompat.RECEIVER_EXPORTED);
Log.d("MainActivity", "广播接收器成功注册"); LogFileUtil.logAndWrite(android.util.Log.DEBUG, "MainActivity", "广播接收器成功注册",null);
} catch (Exception e) { } catch (Exception e) {
Log.e("MainActivity", "Failed to register receiver", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "MainActivity", "Failed to register receiver",e);
scriptResultReceiver = null; // 确保状态一致 scriptResultReceiver = null; // 确保状态一致
} }
} else { } else {
Log.w("MainActivity", "广播接收器已注册,无需重复注册"); LogFileUtil.logAndWrite(android.util.Log.WARN, "MainActivity", "广播接收器已注册,无需重复注册",null);
} }
} }
@ -109,7 +108,7 @@ public class AutoJsUtil {
// 检查目标应用是否安装 // 检查目标应用是否安装
public static boolean isAppInstalled(String packageName) { public static boolean isAppInstalled(String packageName) {
Log.d("isAppInstalled", "Checking if app is installed: " + packageName); LogFileUtil.logAndWrite(android.util.Log.DEBUG, "isAppInstalled", "Checking if app is installed: " + packageName,null);
// 通过 Shell 命令实现检测 // 通过 Shell 命令实现检测
try { try {
@ -117,19 +116,18 @@ public class AutoJsUtil {
String result = ShellUtils.execRootCmdAndGetResult(cmd); String result = ShellUtils.execRootCmdAndGetResult(cmd);
if (result != null && result.contains(packageName)) { if (result != null && result.contains(packageName)) {
Log.d("isAppInstalled", "App is installed: " + packageName); LogFileUtil.logAndWrite(android.util.Log.DEBUG, "isAppInstalled", "App is installed: " + packageName,null);
return true; return true;
} else { } else {
Log.w("isAppInstalled", "App not installed: " + packageName); LogFileUtil.logAndWrite(android.util.Log.WARN, "isAppInstalled", "App not installed: " + packageName,null);
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("isAppInstalled", "Unexpected exception while checking app installation: " + packageName, e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "isAppInstalled", "Unexpected exception while checking app installation: " + packageName,e);
return false; return false;
} }
} }
private static final String AUTOJS_SCRIPT_FINISHED_ACTION = "org.autojs.SCRIPT_FINISHED"; private static final String AUTOJS_SCRIPT_FINISHED_ACTION = "org.autojs.SCRIPT_FINISHED";
private static final String SCRIPT_RESULT_KEY = "result"; private static final String SCRIPT_RESULT_KEY = "result";
@ -141,7 +139,7 @@ public class AutoJsUtil {
// 检查目标活动是否存在 // 检查目标活动是否存在
boolean activityAvailable = isActivityAvailable(context, "org.autojs.autojs6", "org.autojs.autojs.external.open.StopServiceActivity"); boolean activityAvailable = isActivityAvailable(context, "org.autojs.autojs6", "org.autojs.autojs.external.open.StopServiceActivity");
Log.d("AutoJsUtil", "是否找到目标活动: " + activityAvailable); LogFileUtil.logAndWrite(android.util.Log.DEBUG, "AutoJsUtil", "是否找到目标活动: " + activityAvailable,null);
if (activityAvailable) { if (activityAvailable) {
try { try {
@ -149,11 +147,11 @@ public class AutoJsUtil {
Toast.makeText(context, "脚本停止命令已发送", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "脚本停止命令已发送", Toast.LENGTH_SHORT).show();
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(context, "无法发送停止命令,请检查 AutoJs 配置", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "无法发送停止命令,请检查 AutoJs 配置", Toast.LENGTH_SHORT).show();
Log.e("AutoJsUtil", "发送停止命令时发生错误", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "AutoJsUtil", "发送停止命令时发生错误",e);
} }
} else { } else {
Toast.makeText(context, "目标活动未找到或已更改,请检查 AutoJs 配置", Toast.LENGTH_LONG).show(); Toast.makeText(context, "目标活动未找到或已更改,请检查 AutoJs 配置", Toast.LENGTH_LONG).show();
Log.e("AutoJsUtil", "目标活动未找到: org.autojs.autojs.external.open.StopServiceActivity"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "AutoJsUtil", "目标活动未找到: org.autojs.autojs.external.open.StopServiceActivity",null);
} }
} }
} }

View File

@ -2,6 +2,7 @@ package com.example.studyapp.config;
import android.content.Context; import android.content.Context;
import com.example.studyapp.utils.LogFileUtil;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -38,10 +39,10 @@ public class ConfigLoader {
JSONObject jsonObject = new JSONObject(jsonStr); JSONObject jsonObject = new JSONObject(jsonStr);
return jsonObject.optString("tun_address", "172.19.0.1"); return jsonObject.optString("tun_address", "172.19.0.1");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); LogFileUtil.writeLogToFile("ERROR", "ConfigLoader", "File not found: " + e.getMessage());
return "172.19.0.1"; return "172.19.0.1";
} catch (IOException | JSONException e) { } catch (IOException | JSONException e) {
e.printStackTrace(); LogFileUtil.writeLogToFile("ERROR", "ConfigLoader", "Error reading file: " + e.getMessage());
return "172.19.0.1"; return "172.19.0.1";
} }
} }

View File

@ -1,6 +1,7 @@
package com.example.studyapp.device; package com.example.studyapp.device;
import static com.example.studyapp.autoJS.AutoJsUtil.isAppInstalled; import static com.example.studyapp.autoJS.AutoJsUtil.isAppInstalled;
import static com.example.studyapp.utils.LogFileUtil.logAndWrite;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@ -12,6 +13,7 @@ import com.example.studyapp.task.BigoInfo;
import com.example.studyapp.task.DeviceInfo; import com.example.studyapp.task.DeviceInfo;
import com.example.studyapp.task.TaskUtil; import com.example.studyapp.task.TaskUtil;
import com.example.studyapp.utils.HttpUtil; import com.example.studyapp.utils.HttpUtil;
import com.example.studyapp.utils.LogFileUtil;
import com.example.studyapp.utils.ShellUtils; import com.example.studyapp.utils.ShellUtils;
import java.io.File; import java.io.File;
@ -52,94 +54,192 @@ public class ChangeDeviceInfoUtil {
private static final ExecutorService executorService = Executors.newSingleThreadExecutor(); private static final ExecutorService executorService = Executors.newSingleThreadExecutor();
public static void initialize(String country, int tag, Context context, String androidId) { public static void initialize(String country, int tag, Context context, String androidId) {
Log.d("TaskUtil", "initialize method called with parameters:"); LogFileUtil.logAndWrite(android.util.Log.DEBUG, LOG_TAG, "Initializing device info...", null);
Log.d("TaskUtil", "Country: " + country + ", Tag: " + tag + ", Android ID: " + androidId);
Log.d("TaskUtil", "Context instance: " + (context != null ? context.getClass().getSimpleName() : "null"));
executorService.submit(() -> { executorService.submit(() -> {
try { try {
Log.d("TaskUtil", "Starting network requests..."); LogFileUtil.logAndWrite(android.util.Log.DEBUG, LOG_TAG, "Starting network requests...", null);
String bigoJson = fetchJsonSafely(buildBigoUrl(country, tag), "bigoJson");
String afJson = fetchJsonSafely(buildAfUrl(country, tag), "afJson");
// 发起网络请求 fallBackToNetworkData(bigoJson, afJson);
String bigoJson = HttpUtil.requestGet(buildBigoUrl(country, tag));
Log.d("TaskUtil", "Received bigoJson: " + bigoJson);
String afJson = HttpUtil.requestGet(buildAfUrl(country, tag)); logDeviceObjects();
Log.d("TaskUtil", "Received afJson: " + afJson); processPackageInfo(TaskUtil.getPackageInfo(androidId), context);
String response = executeQuerySafely(androidId);
Log.d("TaskUtil", "Response from executeQuerySafely: " + response);
// 解析 JSON
if (response != null && !response.isBlank() && !response.equals("{}\n")) {
Log.d("TaskUtil", "Parsing existing response JSON...");
JSONObject responseJson = new JSONObject(response);
bigoDeviceObject = responseJson.optJSONObject("bigoDeviceObject");
afDeviceObject = responseJson.optJSONObject("afDeviceObject");
Log.d("TaskUtil", "Parsed bigoDeviceObject: " + bigoDeviceObject);
Log.d("TaskUtil", "Parsed afDeviceObject: " + afDeviceObject);
} else {
Log.d("TaskUtil", "Fallback to parsing bigoJson and afJson...");
bigoDeviceObject = new JSONObject(bigoJson).optJSONObject("device");
afDeviceObject = new JSONObject(afJson).optJSONObject("device");
Log.d("TaskUtil", "Fallback bigoDeviceObject: " + bigoDeviceObject);
Log.d("TaskUtil", "Fallback afDeviceObject: " + afDeviceObject);
}
// 输出结果
Log.i("TaskUtil", "Final bigoDeviceObject: " + bigoDeviceObject);
Log.i("TaskUtil", "Final afDeviceObject: " + afDeviceObject);
// 获取包信息
Log.d("TaskUtil", "Fetching package info...");
Map<String, String> packageInfo = TaskUtil.getPackageInfo(androidId);
Log.d("TaskUtil", "Package info retrieved: " + packageInfo);
// 遍历包信息并执行逻辑
if (packageInfo != null) {
for (String packAgeName : packageInfo.keySet()) {
Log.d("TaskUtil", "Processing package: " + packAgeName);
if (isAppInstalled(packAgeName)) {
Log.d("TaskUtil", "Package installed: " + packAgeName);
File filesDir = new File(context.getExternalFilesDir(null).getAbsolutePath());
Log.d("TaskUtil", "Files directory: " + filesDir.getAbsolutePath());
File file = TaskUtil.downloadCodeFile(packageInfo.get(packAgeName), filesDir);
if (file != null && file.exists()) {
Log.d("TaskUtil", "File downloaded: " + file.getAbsolutePath());
File destDir = new File("/storage/emulated/0/Android/data/" + packAgeName);
Log.d("TaskUtil", "Unzipping to destination: " + destDir.getAbsolutePath());
TaskUtil.unZip(destDir, file);
Log.d("TaskUtil", "Unzip completed. Deleting file: " + file.getAbsolutePath());
TaskUtil.delFileSh(file.getAbsolutePath());
Log.d("TaskUtil", "Temporary file deleted: " + file.getAbsolutePath());
} else {
Log.w("TaskUtil", "File download failed or file does not exist for package: " + packAgeName);
}
} else {
Log.w("TaskUtil", "Package not installed: " + packAgeName);
}
}
}
} catch (IOException | JSONException e) { } catch (IOException | JSONException e) {
Log.e("TaskUtil", "Error occurred during initialization", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error occurred during initialization", e);
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Unexpected error occurred", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error occurred during initialization", e);
} }
}); });
} }
public static void getDeviceInfo(String taskId, String androidId) {
if (taskId == null || androidId == null || taskId.isBlank() || androidId.isBlank()) {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Invalid task",null);
return;
}
executorService.submit(() -> {
String response = "";
try{
response = executeQuerySafely(androidId, taskId);
} catch (Exception e) {
e.printStackTrace();
}
if (response == null || response.isBlank()) {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error occurred during query", null);
return;
}
if (isValidResponse(response)) {
try {
synchronized (ChangeDeviceInfoUtil.class) { // 防止并发访问
parseAndSetDeviceObjects(response);
}
} catch (JSONException e) {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error parsing JSON", e);
}
} else {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error occurred during query",null);
}
});
}
private static String fetchJsonSafely(String url, String logKey) throws IOException {
String json = null;
try {
json = HttpUtil.requestGet(url);
if (json != null && !json.isEmpty()) {
LogFileUtil.logAndWrite(android.util.Log.DEBUG, LOG_TAG, "Received " + logKey + ": " + json, null);
return json;
} else {
LogFileUtil.logAndWrite(android.util.Log.WARN, LOG_TAG, "Empty or null response for: " + logKey + ", retrying...", null);
}
} catch (IOException e) {
LogFileUtil.logAndWrite(android.util.Log.WARN, LOG_TAG, "Error fetching " + logKey + ": " + e.getMessage() + ", retrying...", e);
}
// Retry once if the initial attempt failed
json = HttpUtil.requestGet(url);
if (json != null && !json.isEmpty()) {
LogFileUtil.logAndWrite(android.util.Log.DEBUG, LOG_TAG, "Retry success for " + logKey + ": " + json, null);
return json;
} else {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Retry failed for " + logKey + ", response is still null or empty.", null);
throw new IOException("Failed to fetch valid JSON for " + logKey);
}
}
private static boolean isValidResponse(String response) {
return response != null && !response.isBlank() && !response.equals("{}\n")
&& !response.equals("{\"afDeviceObject\": null, \"bigoDeviceObject\": null, \"other\": null}")
&& response.trim().startsWith("{");
}
private static void parseAndSetDeviceObjects(String response) throws JSONException {
String cleanJson = response.trim();
if (cleanJson.startsWith("\"") && cleanJson.endsWith("\"")) {
cleanJson = cleanJson.substring(1, cleanJson.length() - 1).replace("\\\"", "\"");
}
JSONObject responseJson = new JSONObject(cleanJson);
bigoDeviceObject = responseJson.optJSONObject("bigoDeviceObject");
afDeviceObject = responseJson.optJSONObject("afDeviceObject");
}
private static void fallBackToNetworkData(String bigoJson, String afJson) throws JSONException {
bigoDeviceObject = new JSONObject(bigoJson).optJSONObject("device");
afDeviceObject = new JSONObject(afJson).optJSONObject("device");
}
private static void logDeviceObjects() {
LogFileUtil.logAndWrite(android.util.Log.INFO, LOG_TAG, "Final bigoDeviceObject: " + bigoDeviceObject, null);
LogFileUtil.logAndWrite(android.util.Log.INFO, LOG_TAG, "Final DeviceInfo: " + afDeviceObject, null);
}
private static void processPackageInfo(Map<String, String> packageInfo, Context context) {
if (packageInfo != null) {
for (Map.Entry<String, String> entry : packageInfo.entrySet()) {
String packageName = entry.getKey();
if (!isAppInstalled(packageName)) {
processPackage(packageName, entry.getValue(), context);
} else {
LogFileUtil.logAndWrite(android.util.Log.WARN, LOG_TAG, "Package not installed: " + packageName, null);
}
}
}
}
private static void processPackage(String packageName, String zipName, Context context) {
try {
File filesDir = new File(context.getExternalFilesDir(null).getAbsolutePath());
File file = TaskUtil.downloadCodeFile(zipName, filesDir);
if (file != null && file.exists()) {
File destFile = new File(context.getCacheDir(), packageName+"_download"+".apk");
if (destFile.exists()) {
TaskUtil.delFileSh(destFile.getAbsolutePath());
}
TaskUtil.unZip(destFile, file);
if (destFile.exists()) {
installApk(destFile.getAbsolutePath());
}
TaskUtil.delFileSh(destFile.getAbsolutePath());
TaskUtil.delFileSh(file.getAbsolutePath());
LogFileUtil.logAndWrite(Log.DEBUG, LOG_TAG, "Processed package: " + packageName, null);
} else {
LogFileUtil.logAndWrite(android.util.Log.WARN, LOG_TAG, "File download failed for package: " + packageName, null);
}
} catch (Exception e) {
LogFileUtil.logAndWrite(android.util.Log.ERROR, LOG_TAG, "Error processing package: " + packageName, e);
}
}
public static boolean installApk(String apkFilePath) {
// 检查文件路径
if (apkFilePath == null || apkFilePath.trim().isEmpty()) {
LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Invalid APK file path", null);
return false;
}
// 确保文件存在
File apkFile = new File(apkFilePath);
if (!apkFile.exists()) {
LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "APK file not found: " + apkFilePath, null);
return false;
}
// 构造安装命令
String command = "pm install " + apkFilePath;
// 执行命令并获取结果
String result = ShellUtils.execRootCmdAndGetResult(command);
if (result != null && result.contains("Success")) {
Log.d("ShellUtils", "APK installed successfully!");
return true;
} else {
LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Failed to install APK. Result: " + result, null);
return false;
}
}
private static final String LOG_TAG = "TaskUtil";
private static final String INIT_LOG_TEMPLATE = "initialize method called with parameters: Country: %s, Tag: %d, Android ID: %s";
private static final String CONTEXT_LOG_TEMPLATE = "Context instance: %s";
// 辅助方法执行网络请求 // 辅助方法执行网络请求
private static String fetchJson(String url) throws IOException { private static String fetchJson(String url) throws IOException {
return HttpUtil.requestGet(url); return HttpUtil.requestGet(url);
} }
// 辅助方法执行任务 // 辅助方法执行任务
private static String executeQuerySafely(String androidId) { private static String executeQuerySafely(String androidId, String taskId) {
return TaskUtil.execQueryTask(androidId); return TaskUtil.execQueryTask(androidId,taskId);
} }
@ -211,7 +311,7 @@ public class ChangeDeviceInfoUtil {
// **tz** (时区) // **tz** (时区)
callVCloudSettings_put(current_pkg_name + "_tz", tz, context); callVCloudSettings_put(current_pkg_name + "_tz", tz, context);
} catch (Throwable e) { } catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e); logAndWrite(android.util.Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred while changing device info", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e); throw new RuntimeException("Error occurred in changeDeviceInfo", e);
} }
} }
@ -341,7 +441,7 @@ public class ChangeDeviceInfoUtil {
callVCloudSettings_put("screen.device.displayMetrics", displayMetrics.toString(), context); callVCloudSettings_put("screen.device.displayMetrics", displayMetrics.toString(), context);
if (!ShellUtils.hasRootAccess()) { if (!ShellUtils.hasRootAccess()) {
Log.e("ChangeDeviceInfoUtil", "Root access is required to execute system property changes"); LogFileUtil.writeLogToFile("ERROR", "ChangeDeviceInfoUtil", "Root access is required to execute system property changes");
} }
// 设置机型, 直接设置属性 // 设置机型, 直接设置属性
ShellUtils.execRootCmd("setprop ro.product.brand " + ro_product_brand); ShellUtils.execRootCmd("setprop ro.product.brand " + ro_product_brand);
@ -370,7 +470,7 @@ public class ChangeDeviceInfoUtil {
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor " + persist_sys_cloud_gpu_egl_vendor); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_vendor " + persist_sys_cloud_gpu_egl_vendor);
ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version " + persist_sys_cloud_gpu_egl_version); ShellUtils.execRootCmd("setprop persist.sys.cloud.gpu.egl_version " + persist_sys_cloud_gpu_egl_version);
} catch (Throwable e) { } catch (Throwable e) {
Log.e("ChangeDeviceInfoUtil", "Error occurred while changing device info", e); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in changeDeviceInfo", e);
throw new RuntimeException("Error occurred in changeDeviceInfo", e); throw new RuntimeException("Error occurred in changeDeviceInfo", e);
} }
} }
@ -378,12 +478,15 @@ public class ChangeDeviceInfoUtil {
private static void callVCloudSettings_put(String key, String value, Context context) { private static void callVCloudSettings_put(String key, String value, Context context) {
if (context == null) { if (context == null) {
logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Context cannot be null", null);
throw new IllegalArgumentException("Context cannot be null"); throw new IllegalArgumentException("Context cannot be null");
} }
if (key == null || key.isEmpty()) { if (key == null || key.isEmpty()) {
logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Key cannot be null or empty", null);
throw new IllegalArgumentException("Key cannot be null or empty"); throw new IllegalArgumentException("Key cannot be null or empty");
} }
if (value == null) { if (value == null) {
logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Value cannot be null", null);
throw new IllegalArgumentException("Value cannot be null"); throw new IllegalArgumentException("Value cannot be null");
} }
@ -397,18 +500,18 @@ public class ChangeDeviceInfoUtil {
putStringMethod.invoke(null, context.getContentResolver(), key, value); putStringMethod.invoke(null, context.getContentResolver(), key, value);
Log.d("Debug", "putString executed successfully."); Log.d("Debug", "putString executed successfully.");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
Log.w("Reflection Error", "Class not found: android.provider.VCloudSettings$Global. This may not be supported on this device."); logAndWrite(Log.WARN, "ChangeDeviceInfoUtil", "Class not found: android.provider.VCloudSettings$Global. This may not be supported on this device.", e);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
Log.w("Reflection Error", "Method putString not available. Ensure your taropt Android version supports it."); logAndWrite(Log.WARN, "ChangeDeviceInfoUtil", "Method not found: android.provider.VCloudSettings$Global.putString. This may not be supported on this", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Throwable cause = e.getTargetException(); Throwable cause = e.getTargetException();
if (cause instanceof SecurityException) { if (cause instanceof SecurityException) {
Log.e("Reflection Error", "Permission denied. Ensure WRITE_SECURE_SETTINGS permission is granted.", cause); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in changeDeviceInfo", cause);
} else { } else {
Log.e("Reflection Error", "InvocationTaroptException during putString invocation", e); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in changeDeviceInfo", cause);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("Reflection Error", "Unexpected error during putString invocation: " + e.getMessage()); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Unexpected error during putString invocation", e);
} }
} }
@ -416,11 +519,11 @@ public class ChangeDeviceInfoUtil {
try { try {
Native.setBootId("00000000000000000000000000000000"); Native.setBootId("00000000000000000000000000000000");
} catch (Exception e) { } catch (Exception e) {
Log.e("resetChangedDeviceInfo", "Failed to set boot ID", e); logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Error occurred in reset", e);
} }
if (!ShellUtils.hasRootAccess()) { if (!ShellUtils.hasRootAccess()) {
Log.e("resetChangedDeviceInfo", "Root privileges are required."); LogFileUtil.logAndWrite(Log.ERROR, "ChangeDeviceInfoUtil", "Root access is required to execute system property changes", null);
return; return;
} }
ShellUtils.execRootCmd("cmd settings2 delete global global_android_id"); ShellUtils.execRootCmd("cmd settings2 delete global global_android_id");

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.util.Log; import android.util.Log;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.example.studyapp.utils.LogFileUtil;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import okhttp3.Call; import okhttp3.Call;
@ -57,7 +58,7 @@ public class ClashUtil {
checkClashStatus(context, latch); checkClashStatus(context, latch);
latch.await(); // 等待广播接收器更新状态 latch.await(); // 等待广播接收器更新状态
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e("ClashUtil", "checkProxy: Waiting interrupted", e); LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "checkProxy: Waiting interrupted", e);
Thread.currentThread().interrupt(); // 重新设置中断状态 Thread.currentThread().interrupt(); // 重新设置中断状态
return false; // 返回默认状态或尝试重试 return false; // 返回默认状态或尝试重试
} }
@ -85,9 +86,11 @@ public class ClashUtil {
public static void switchProxyGroup(String groupName, String proxyName, String controllerUrl) { public static void switchProxyGroup(String groupName, String proxyName, String controllerUrl) {
if (groupName == null || groupName.trim().isEmpty() || proxyName == null || proxyName.trim().isEmpty()) { if (groupName == null || groupName.trim().isEmpty() || proxyName == null || proxyName.trim().isEmpty()) {
LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "switchProxyGroup: Invalid arguments", null);
throw new IllegalArgumentException("Group name and proxy name must not be empty"); throw new IllegalArgumentException("Group name and proxy name must not be empty");
} }
if (controllerUrl == null || !controllerUrl.matches("^https?://.*")) { if (controllerUrl == null || !controllerUrl.matches("^https?://.*")) {
LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "switchProxyGroup: Invalid controller URL", null);
throw new IllegalArgumentException("Invalid controller URL"); throw new IllegalArgumentException("Invalid controller URL");
} }
@ -96,7 +99,7 @@ public class ClashUtil {
try { try {
json.put("name", proxyName); json.put("name", proxyName);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "switchProxyGroup: JSON error", e);
} }
String jsonBody = json.toString(); String jsonBody = json.toString();
@ -116,7 +119,7 @@ public class ClashUtil {
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {
@Override @Override
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
e.printStackTrace(); LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "switchProxyGroup: Failed to switch proxy", e);
System.out.println("Failed to switch proxy: " + e.getMessage()); System.out.println("Failed to switch proxy: " + e.getMessage());
} }
@ -124,9 +127,9 @@ public class ClashUtil {
public void onResponse(Call call, Response response) throws IOException { public void onResponse(Call call, Response response) throws IOException {
try { try {
if (response.body() != null) { if (response.body() != null) {
System.out.println("Switch proxy response: " + response.body().string()); LogFileUtil.logAndWrite(Log.INFO, "ClashUtil", "switchProxyGroup: Switch proxy response", null);
} else { } else {
System.out.println("Response body is null"); LogFileUtil.logAndWrite(Log.ERROR, "ClashUtil", "switchProxyGroup: Response body is null", null);
} }
} finally { } finally {
response.close(); response.close();

View File

@ -1,15 +0,0 @@
package com.example.studyapp.service;
import com.example.studyapp.request.ScriptResultRequest;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface CloudPhoneManageService {
// 假设服务端接口接收 POST 请求
@POST("/api/script/result")
Call<Void> sendScriptResult(@Body ScriptResultRequest request);
}

View File

@ -1,8 +1,12 @@
package com.example.studyapp.task; package com.example.studyapp.task;
import static androidx.core.content.PackageManagerCompat.LOG_TAG;
import android.content.Context; import android.content.Context;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.example.studyapp.utils.LogFileUtil;
import com.example.studyapp.utils.ShellUtils; import com.example.studyapp.utils.ShellUtils;
import com.google.android.gms.common.util.CollectionUtils; import com.google.android.gms.common.util.CollectionUtils;
import com.google.android.gms.common.util.MapUtils; import com.google.android.gms.common.util.MapUtils;
@ -16,6 +20,7 @@ import java.io.OutputStream;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -56,16 +61,16 @@ public class TaskUtil {
.readTimeout(30, TimeUnit.SECONDS) // 读取超时 .readTimeout(30, TimeUnit.SECONDS) // 读取超时
.build(); .build();
public static void postDeviceInfo(String androidId, String taskId) { public static void postDeviceInfo(String androidId, String taskId,String packageName) {
Log.i("TaskUtil", "postDeviceInfo called with androidId: " + androidId); Log.i("TaskUtil", "postDeviceInfo called with androidId: " + androidId);
if (okHttpClient == null) { if (okHttpClient == null) {
Log.e("TaskUtil", "HttpClient is not initialized"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "HttpClient is not initialized", null);
throw new IllegalStateException("HttpClient is not initialized"); throw new IllegalStateException("HttpClient is not initialized");
} }
if (BASE_URL == null || BASE_URL.isEmpty()) { if (BASE_URL == null || BASE_URL.isEmpty()) {
Log.e("TaskUtil", "BASE_URL is not initialized"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "BASE_URL is not initialized", null);
throw new IllegalStateException("BASE_URL is not initialized"); throw new IllegalStateException("BASE_URL is not initialized");
} }
@ -80,11 +85,15 @@ public class TaskUtil {
Log.d("TaskUtil", "Request payload: " + jsonRequestBody); Log.d("TaskUtil", "Request payload: " + jsonRequestBody);
if (packageName == null){
packageName = "";
}
HttpUrl url = HttpUrl.parse(BASE_URL) HttpUrl url = HttpUrl.parse(BASE_URL)
.newBuilder() .newBuilder()
.addPathSegment("device_info_upload") .addPathSegment("device_info_upload")
.addQueryParameter("id", androidId) .addQueryParameter("id", androidId)
.addQueryParameter("taskId", taskId) .addQueryParameter("taskId", taskId)
.addQueryParameter("packageName", packageName)
.build(); .build();
Log.d("TaskUtil", "Request URL: " + url.toString()); Log.d("TaskUtil", "Request URL: " + url.toString());
@ -102,7 +111,7 @@ public class TaskUtil {
Response response = okHttpClient.newCall(request).execute(); Response response = okHttpClient.newCall(request).execute();
try (ResponseBody responseBody = response.body()) { try (ResponseBody responseBody = response.body()) {
if (!response.isSuccessful()) { if (!response.isSuccessful()) {
Log.e("TaskUtil", "Request failed with status: " + response.code() + ", message: " + response.message()); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Request failed with status: " + response.code(), null);
return; return;
} }
@ -110,17 +119,17 @@ public class TaskUtil {
String responseText = responseBody.string(); String responseText = responseBody.string();
Log.i("TaskUtil", "Request succeeded. Response: " + responseText); Log.i("TaskUtil", "Request succeeded. Response: " + responseText);
} else { } else {
Log.e("TaskUtil", "Response body is null"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Response body is null", null);
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Error while processing response: " + e.getMessage(), e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error while processing response: " + e.getMessage(), e);
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Network call failed: " + e.getMessage(), e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error during HTTP request: " + e.getMessage(), e);
} }
} }
public static String getDeviceInfoSync(String androidId) { public static String getDeviceInfoSync(String androidId,String taskId) {
Log.d("TaskUtil", "getDeviceInfoSync called with androidId: " + androidId); Log.d("TaskUtil", "getDeviceInfoSync called with androidId: " + androidId);
validate(); // 检查 BASE_URL okHttpClient 的合法性 validate(); // 检查 BASE_URL okHttpClient 的合法性
@ -128,6 +137,7 @@ public class TaskUtil {
HttpUrl url = HttpUrl.parse(BASE_URL + "/device_info_download") HttpUrl url = HttpUrl.parse(BASE_URL + "/device_info_download")
.newBuilder() .newBuilder()
.addQueryParameter("androidId", androidId) .addQueryParameter("androidId", androidId)
.addQueryParameter("taskId",taskId)
.build(); .build();
Log.d("TaskUtil", "Constructed URL for device info download: " + url.toString()); Log.d("TaskUtil", "Constructed URL for device info download: " + url.toString());
@ -145,7 +155,7 @@ public class TaskUtil {
String errorMessage = "Unexpected response: Code=" + response.code() + String errorMessage = "Unexpected response: Code=" + response.code() +
", Message=" + response.message() + ", Message=" + response.message() +
", URL=" + url.toString(); ", URL=" + url.toString();
Log.e("TaskUtil", errorMessage); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", errorMessage, null);
throw new IOException(errorMessage); throw new IOException(errorMessage);
} }
@ -156,29 +166,39 @@ public class TaskUtil {
return responseString; return responseString;
} else { } else {
String errorMessage = "Response body is null: URL=" + url.toString(); String errorMessage = "Response body is null: URL=" + url.toString();
Log.e("TaskUtil", errorMessage); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", errorMessage, null);
throw new IOException(errorMessage); throw new IOException(errorMessage);
} }
} catch (IOException e) { } catch (IOException e) {
String errorMessage = "Error during HTTP request. URL=" + url.toString() + String errorMessage = "Error during HTTP request. URL=" + url.toString() +
", Android ID=" + androidId; ", Android ID=" + androidId;
Log.e("TaskUtil", errorMessage, e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", errorMessage, e);
e.printStackTrace();
return null; // 或考虑在上层抛出异常 return null; // 或考虑在上层抛出异常
} }
} }
public static String getApkPath(Context context, String packageName) {
if (packageName == null || packageName.trim().isEmpty()) {
throw new IllegalArgumentException("Package name must not be null or empty");
}
String result = ShellUtils.getPackagePath(context, packageName);
Log.d("TAG", "getApkPath: "+result);
return result;
}
public static void infoUpload(Context context, String androidId, String packAge) throws IOException { public static void infoUpload(Context context, String androidId, String packAge) throws IOException {
Log.i("TaskUtil", "infoUpload called with androidId: " + androidId + ", package: " + packAge); Log.i("TaskUtil", "infoUpload called with androidId: " + androidId + ", package: " + packAge);
if (packAge == null || packAge.isEmpty()) { if (packAge == null || packAge.isEmpty()) {
Log.e("TaskUtil", "Package name is null or empty"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Package name is null or empty", null);
throw new IllegalArgumentException("Package name cannot be null or empty"); throw new IllegalArgumentException("Package name cannot be null or empty");
} }
if (context == null) { if (context == null) {
Log.e("TaskUtil", "Context is null"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Context is null", null);
throw new IllegalArgumentException("Context cannot be null"); throw new IllegalArgumentException("Context cannot be null");
} }
@ -187,12 +207,13 @@ public class TaskUtil {
return; return;
} }
String apkSourceDir = "/storage/emulated/0/Android/data/" + packAge; String apkSourceFile = getApkPath(context, packAge);
Log.d("TaskUtil", "APK source directory: " + apkSourceDir); Log.d("TaskUtil", "APK source directory: " + apkSourceFile);
File externalDir = context.getExternalFilesDir(null); // File externalDir = context.getExternalFilesDir(null);
File externalDir = context.getCacheDir();
if (externalDir == null) { if (externalDir == null) {
Log.e("TaskUtil", "External storage directory is unavailable"); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "External storage directory is unavailable", null);
throw new IOException("External storage directory is unavailable"); throw new IOException("External storage directory is unavailable");
} }
@ -203,17 +224,19 @@ public class TaskUtil {
if (zipFile.exists()) { if (zipFile.exists()) {
delFileSh(zipFile.getAbsolutePath()); delFileSh(zipFile.getAbsolutePath());
} }
File copiedDir = new File(context.getCacheDir(), packAge); File copiedAPKFile = new File(context.getCacheDir(), packAge+"_upload.apk");
if (copiedDir.exists()) { if (copiedAPKFile.exists()) {
delFileSh(copiedDir.getAbsolutePath()); delFileSh(copiedAPKFile.getAbsolutePath());
}
copyFolderSh(apkSourceDir, copiedDir.getAbsolutePath());
boolean success = clearUpFileInDst(copiedDir);
if (success) {
// 压缩APK文件
compressToZip(copiedDir, zipFile);
} }
copyFolderSh(apkSourceFile, copiedAPKFile.getAbsolutePath());
// boolean success = clearUpFileInDst(copiedDir);
// if (success) {
// // 压缩APK文件
// compressToZip(copiedDir, zipFile);
// }
// 压缩APK文件
compressToZip(copiedAPKFile, zipFile);
// 上传压缩文件 // 上传压缩文件
if (!zipFile.exists()) { if (!zipFile.exists()) {
Log.w("TaskUtil", "Upload file does not exist: " + outputZipPath); Log.w("TaskUtil", "Upload file does not exist: " + outputZipPath);
@ -222,8 +245,11 @@ public class TaskUtil {
uploadFile(zipFile); uploadFile(zipFile);
//uninstall
String uninstall = "pm uninstall "+packAge;
String chmodResult = ShellUtils.execRootCmdAndGetResult(uninstall);
// 清理临时文件 // 清理临时文件
delFileSh(copiedDir.getAbsolutePath()); delFileSh(copiedAPKFile.getAbsolutePath());
delFileSh(zipFile.getAbsolutePath()); delFileSh(zipFile.getAbsolutePath());
} }
@ -232,7 +258,7 @@ public class TaskUtil {
try { try {
// 验证输入路径合法性 // 验证输入路径合法性
if (oldPath == null || newPath == null || oldPath.isEmpty() || newPath.isEmpty()) { if (oldPath == null || newPath == null || oldPath.isEmpty() || newPath.isEmpty()) {
Log.e("TaskUtil", "Invalid path. oldPath: " + oldPath + ", newPath: " + newPath); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Invalid path. oldPath: " + oldPath + ", newPath: " + newPath, null);
return false; return false;
} }
@ -241,7 +267,7 @@ public class TaskUtil {
File dst = new File(newPath); File dst = new File(newPath);
if (!src.exists()) { if (!src.exists()) {
Log.e("TaskUtil", "Source path does not exist: " + oldPath); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Source path does not exist: " + oldPath,null);
return false; return false;
} }
@ -254,19 +280,33 @@ public class TaskUtil {
// 调用 MockTools 执行 // 调用 MockTools 执行
String result = ShellUtils.execRootCmdAndGetResult(cmd); String result = ShellUtils.execRootCmdAndGetResult(cmd);
String chmod = "chmod 777 \"" + safeNewPath + "\"";
String chmodResult = ShellUtils.execRootCmdAndGetResult(chmod);
// if (!TextUtils.isEmpty(chmodResult)) {
LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "chmodResult. Result: " + chmodResult, null);
// return false;
// }
if (result == null || result.trim().isEmpty()) { if (result == null || result.trim().isEmpty()) {
Log.e("TaskUtil", "Command execution failed. Result: " + result); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Command execution failed. Result: " + result, null);
return false; return false;
} }
Log.i("TaskUtil", "Command executed successfully: " + result); Log.i("TaskUtil", "Command executed successfully: " + result);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error occurred during copyFolderSh operation", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error occurred during copyFolderSh operation", e);
return false; return false;
} }
} }
/**
*在给定的目标目录中清除特定的文件和目录
*子目录未命名为缓存并且删除了大于3 MB的文件
*记录保留的文件和目录的路径
*
* @param DST将处理其文件和子目录的目标目录
* @return true如果目的目录存在并且已成功处理则为false否则
*/
private static boolean clearUpFileInDst(File dst) { private static boolean clearUpFileInDst(File dst) {
if (dst.exists()) { if (dst.exists()) {
File[] files = dst.listFiles(); File[] files = dst.listFiles();
@ -300,12 +340,12 @@ public class TaskUtil {
// 1. 参数校验 // 1. 参数校验
if (path == null || path.isEmpty()) { if (path == null || path.isEmpty()) {
Log.e("TaskUtil", "Invalid or empty path provided."); LogFileUtil.logAndWrite(android.util.Log.ERROR,"TaskUtil", "Invalid or empty path provided.", null);
return; return;
} }
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
Log.e("TaskUtil", "File does not exist: " + path); LogFileUtil.logAndWrite(android.util.Log.ERROR,"TaskUtil","File does not exist: " + path, null);
return; return;
} }
@ -316,13 +356,13 @@ public class TaskUtil {
ShellUtils.execRootCmd(cmd); ShellUtils.execRootCmd(cmd);
Log.i("TaskUtil", "File deletion successful for path: " + path); Log.i("TaskUtil", "File deletion successful for path: " + path);
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error occurred while deleting file: " + e.getMessage(), e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error occurred during delFileSh operation", e);
} }
} }
private static void delFile(File file) { private static void delFile(File file) {
if (file == null || !file.exists()) { if (file == null || !file.exists()) {
Log.e("TaskUtil", "File does not exist or is null."); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "File does not exist or is null.", null);
return; return;
} }
@ -331,16 +371,16 @@ public class TaskUtil {
Log.i("TaskUtil", "Deleting file: " + file.getName()); Log.i("TaskUtil", "Deleting file: " + file.getName());
ShellUtils.execRootCmd(cmd); ShellUtils.execRootCmd(cmd);
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error occurred while deleting file: " + file, e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error occurred during delFile operation", e);
throw new RuntimeException("File deletion failed", e); throw new RuntimeException("File deletion failed", e);
} }
} }
private static void compressToZip(File src, File dst) throws IOException { private static void compressToZip(File src, File dst) throws IOException {
Log.d("TaskUtil", "Starting to compress the APK directory..."); Log.d("TaskUtil", "Starting to compress single file...");
if (!src.exists() || !src.isDirectory()) { if (!src.exists() || !src.isFile()) {
throw new IOException("Source path does not exist or is not a directory: " + src.getAbsolutePath()); throw new IOException("Source file does not exist or is not a valid file: " + src.getAbsolutePath());
} }
if (dst.exists()) { if (dst.exists()) {
throw new IOException("Destination ZIP file already exists: " + dst.getAbsolutePath()); throw new IOException("Destination ZIP file already exists: " + dst.getAbsolutePath());
@ -350,11 +390,24 @@ public class TaskUtil {
} }
try (FileOutputStream fos = new FileOutputStream(dst); try (FileOutputStream fos = new FileOutputStream(dst);
ZipOutputStream zipOut = new ZipOutputStream(fos)) { ZipOutputStream zipOut = new ZipOutputStream(fos);
addDirToZip(src, "", zipOut); FileInputStream fis = new FileInputStream(src)) {
Log.i("TaskUtil", "Directory successfully compressed to ZIP: " + dst.getName());
String zipEntryName = src.getName();
zipOut.putNextEntry(new ZipEntry(zipEntryName));
Log.d("TaskUtil", "Adding file to ZIP: " + zipEntryName);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fis.read(buffer)) >= 0) {
zipOut.write(buffer, 0, bytesRead);
}
zipOut.closeEntry();
Log.i("TaskUtil", "File successfully compressed to ZIP: " + dst.getName());
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Error during directory compression", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error during file compression", e);
throw e; throw e;
} }
} }
@ -403,87 +456,81 @@ public class TaskUtil {
throw new IOException("Shell command execution failed: " + result); throw new IOException("Shell command execution failed: " + result);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error in zipSh", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Error in zipSh", e);
} }
} }
public static void unZip(File destinationDir, File zipFile) { public static void unZip(File destFile, File zipFile) {
Log.d("TaskUtil", "unZip method called with parameters:"); Log.d("TaskUtil", "unZip method called with parameters:");
Log.d("TaskUtil", "Destination directory: " + (destinationDir != null ? destinationDir.getAbsolutePath() : "null")); Log.d("TaskUtil", "Destination file: " + (destFile != null ? destFile.getAbsolutePath() : "null"));
Log.d("TaskUtil", "ZIP file: " + (zipFile != null ? zipFile.getAbsolutePath() : "null")); Log.d("TaskUtil", "ZIP file: " + (zipFile != null ? zipFile.getAbsolutePath() : "null"));
try { try {
// 校验输入参数 // 校验输入参数
if (destinationDir == null || zipFile == null) { if (destFile == null || zipFile == null) {
Log.e("TaskUtil", "Destination directory or ZIP file is null."); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Destination file or ZIP file is null.", null);
throw new IllegalArgumentException("Destination directory or ZIP file cannot be null."); throw new IllegalArgumentException("Destination file or ZIP file cannot be null.");
} }
if (!zipFile.exists() || !zipFile.isFile()) { if (!zipFile.exists() || !zipFile.isFile()) {
Log.e("TaskUtil", "Invalid ZIP file: " + zipFile.getAbsolutePath()); LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Invalid ZIP file: " + zipFile.getAbsolutePath(), null);
throw new IllegalArgumentException("Invalid ZIP file: " + zipFile.getAbsolutePath()); throw new IllegalArgumentException("Invalid ZIP file: " + zipFile.getAbsolutePath());
} }
// 创建目标目录如果不存在 if (destFile.exists()) {
if (!destinationDir.exists()) { LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil", "Destination file already exists: " + destFile.getAbsolutePath(), null);
boolean mkdirs = destinationDir.mkdirs(); throw new IllegalArgumentException("Destination file already exists and cannot be overwritten: " + destFile.getAbsolutePath());
Log.d("TaskUtil", "Destination directory created: " + mkdirs + ", Path: " + destinationDir.getAbsolutePath());
if (!mkdirs) {
Log.e("TaskUtil", "Failed to create destination directory: " + destinationDir.getAbsolutePath());
throw new IOException("Failed to create destination directory: " + destinationDir.getAbsolutePath());
}
} else {
Log.d("TaskUtil", "Destination directory already exists: " + destinationDir.getAbsolutePath());
} }
// 使用Java自带的ZipInputStream解压文件 File parentDir = destFile.getParentFile();
if (!parentDir.exists()) {
boolean created = parentDir.mkdirs();
Log.d("TaskUtil", "Parent directory created: " + created + ", Path: " + parentDir.getAbsolutePath());
if (!created) {
throw new IOException("Failed to create parent directory: " + parentDir.getAbsolutePath());
}
}
// 使用 Java 自带的 ZipInputStream 解压文件
try (FileInputStream fis = new FileInputStream(zipFile); try (FileInputStream fis = new FileInputStream(zipFile);
java.util.zip.ZipInputStream zis = new java.util.zip.ZipInputStream(fis)) { java.util.zip.ZipInputStream zis = new java.util.zip.ZipInputStream(fis);
FileOutputStream fos = new FileOutputStream(destFile)) {
Log.d("TaskUtil", "ZipInputStream opened for ZIP file: " + zipFile.getAbsolutePath()); Log.d("TaskUtil", "ZipInputStream opened for ZIP file: " + zipFile.getAbsolutePath());
java.util.zip.ZipEntry zipEntry;
while ((zipEntry = zis.getNextEntry()) != null) {
Log.d("TaskUtil", "Processing entry: " + zipEntry.getName());
File newFile = new File(destinationDir, zipEntry.getName());
// 检查目标文件路径是否合法避免安全漏洞 java.util.zip.ZipEntry zipEntry;
if (!newFile.getCanonicalPath().startsWith(destinationDir.getCanonicalPath())) { int extractedFiles = 0;
Log.e("TaskUtil", "Unzip entry is outside of the target directory: " + newFile.getAbsolutePath()); byte[] buffer = new byte[4096];
throw new IOException("Unzip entry is outside of the target directory: " + newFile.getAbsolutePath()); int length;
while ((zipEntry = zis.getNextEntry()) != null) {
if (extractedFiles > 0) {
throw new IOException("ZIP file contains more than one entry, expected exactly one: " + zipFile.getAbsolutePath());
} }
Log.d("TaskUtil", "Processing single entry: " + zipEntry.getName());
if (zipEntry.isDirectory()) { if (zipEntry.isDirectory()) {
// 如果是目录则创建目录 LogFileUtil.logAndWrite(android.util.Log.ERROR, "TaskUtil",
if (!newFile.exists() && newFile.mkdirs()) { "ZIP file entry is a directory but only a single file can be extracted: " + zipEntry.getName(), null);
Log.d("TaskUtil", "Directory created: " + newFile.getAbsolutePath()); throw new IOException("ZIP file entry is a directory: " + zipEntry.getName());
}
} else {
// 如果是文件则写入文件
File parent = newFile.getParentFile();
if (!parent.exists()) {
boolean parentCreated = parent.mkdirs();
Log.d("TaskUtil", "Parent directory created: " + parentCreated + ", Path: " + parent.getAbsolutePath());
if (!parentCreated) {
Log.e("TaskUtil", "Failed to create parent directory: " + parent.getAbsolutePath());
throw new IOException("Failed to create parent directory: " + parent.getAbsolutePath());
}
}
try (FileOutputStream fos = new FileOutputStream(newFile)) {
Log.d("TaskUtil", "Writing to file: " + newFile.getAbsolutePath());
byte[] buffer = new byte[4096];
int length;
while ((length = zis.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
}
Log.d("TaskUtil", "File written successfully: " + newFile.getAbsolutePath());
} }
while ((length = zis.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
extractedFiles++;
zis.closeEntry(); zis.closeEntry();
} }
if (extractedFiles == 0) {
throw new IOException("ZIP file does not contain entries to extract: " + zipFile.getAbsolutePath());
}
Log.i("TaskUtil", "Unzip successful. Extracted file to: " + destFile.getAbsolutePath());
} }
Log.i("TaskUtil", "Unzip successful. Extracted to: " + destinationDir.getAbsolutePath());
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error in unZip method", e); LogFileUtil.logAndWrite(Log.ERROR, "TaskUtil", "Error in unZip method", e);
} }
} }
@ -516,13 +563,13 @@ public class TaskUtil {
// 检查返回结果 // 检查返回结果
if (result == null || result.contains("error")) { if (result == null || result.contains("error")) {
Log.e("TaskUtil", "Shell command execution failed: " + result); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Shell command execution failed: " + result,null);
throw new IOException("Shell command failed. Result: " + result); throw new IOException("Shell command failed. Result: " + result);
} }
Log.i("TaskUtil", "Unzip successful. Extracted to: " + destinationDir.getAbsolutePath()); Log.i("TaskUtil", "Unzip successful. Extracted to: " + destinationDir.getAbsolutePath());
} catch (Exception e) { } catch (Exception e) {
Log.e("TaskUtil", "Error in unzipSh", e); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Error in unzipSh", e);
} }
} }
@ -553,7 +600,7 @@ public class TaskUtil {
} }
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "File upload failed", e); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "File upload failed", e);
throw e; throw e;
} }
} }
@ -604,17 +651,17 @@ public class TaskUtil {
if (response.body() != null) { if (response.body() != null) {
try { try {
String responseBody = response.body().string(); String responseBody = response.body().string();
Log.e("TaskUtil", "Response body: " + responseBody); LogFileUtil.logAndWrite(Log.INFO,"TaskUtil", "Response body: " + responseBody,null);
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Failed to read response body for logging", e); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Failed to read response body for logging", e);
} }
} else { } else {
Log.e("TaskUtil", "Response body is null"); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Response body is null", null);
} }
return null; return null;
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Error during file download. Exception: " + e.getMessage(), e); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Error during file download", e);
return null; return null;
} }
} }
@ -653,7 +700,7 @@ public class TaskUtil {
String errorMessage = "Unexpected response: Code=" + response.code() + String errorMessage = "Unexpected response: Code=" + response.code() +
", Message=" + response.message() + ", Message=" + response.message() +
", URL=" + url.toString(); ", URL=" + url.toString();
Log.e("TaskUtil", errorMessage); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", errorMessage, null);
throw new IOException(errorMessage); throw new IOException(errorMessage);
} }
@ -680,62 +727,22 @@ public class TaskUtil {
} }
} else { } else {
String errorMessage = "Response body is null for URL=" + url.toString(); String errorMessage = "Response body is null for URL=" + url.toString();
Log.e("TaskUtil", errorMessage); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", errorMessage, null);
throw new IOException(errorMessage); throw new IOException(errorMessage);
} }
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("TaskUtil", "Error during getPackageInfo request", e); LogFileUtil.logAndWrite(Log.ERROR,"TaskUtil", "Error during getPackageInfo request", e);
} }
return null; // 如果出错返回null return null; // 如果出错返回null
} }
private static void infoDownload(String androidId) { public static String execQueryTask(String androidId,String taskId) {
// 下载压缩包 return getDeviceInfoSync(androidId,taskId);
HttpUrl url = HttpUrl.parse(BASE_URL + "/tar_info_download")
.newBuilder()
.addQueryParameter("file_name", "test")
.build();
Request request = new Request.Builder()
.url(url)
.get()
.build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
if (response.isSuccessful()) {
byte[] fileBytes = response.body().bytes();
String savePath = "/storage/emulated/0/Download/test.zip";
File file = new File(savePath);
file.getParentFile().mkdirs();
try (FileOutputStream fos = new FileOutputStream(file)) {
fos.write(fileBytes);
System.out.println("File saved to " + savePath);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("Download failed: " + response.message());
}
}
});
} }
public static String execQueryTask(String androidId) { public static void execSaveTask(Context context, String androidId, String taskId,String packName) {
return getDeviceInfoSync(androidId);
}
public static void execSaveTask(Context context, String androidId, String taskId) {
if (context == null) { if (context == null) {
throw new IllegalArgumentException("Context or Package name cannot be null or empty"); throw new IllegalArgumentException("Context or Package name cannot be null or empty");
} }
@ -746,7 +753,7 @@ public class TaskUtil {
} }
try { try {
postDeviceInfo(androidId, taskId); postDeviceInfo(androidId, taskId,packName);
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error in execReloginTask: " + e.getMessage()); System.err.println("Error in execReloginTask: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();

View File

@ -50,6 +50,7 @@ public class HttpUtil {
errorResponse = byteArrayOutputStream.toString(); errorResponse = byteArrayOutputStream.toString();
} }
connection.disconnect(); connection.disconnect();
LogFileUtil.logAndWrite(android.util.Log.ERROR, TAG, "HTTP request failed with code " + responseCode + ". Error: " + errorResponse,null);
throw new IOException("HTTP request failed with code " + responseCode + ". Error: " + errorResponse); throw new IOException("HTTP request failed with code " + responseCode + ". Error: " + errorResponse);
} }
} }
@ -99,7 +100,7 @@ public class HttpUtil {
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LogFileUtil.logAndWrite(android.util.Log.ERROR, TAG, "Error getting local IP address", e);
} }
return "0.0.0.0"; // 无法获取时返回默认值 return "0.0.0.0"; // 无法获取时返回默认值
} }

View File

@ -0,0 +1,129 @@
package com.example.studyapp.utils;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class LogFileUtil {
private static final String TAG = "LogFileUtil";
private static File LOG_DIR; // 日志文件目录
private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB 文件大小限制
/**
* 初始化日志文件目录需显式调用
*/
public static void initialize(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
LOG_DIR = new File(context.getExternalFilesDir(null), "logs"); // 应用专属目录
} else {
LOG_DIR = new File(Environment.getExternalStorageDirectory(), "Agent");
}
if (!LOG_DIR.exists() && !LOG_DIR.mkdirs()) {
LogFileUtil.logAndWrite(Log.ERROR, TAG, "日志文件目录创建失败,路径:" + LOG_DIR.getAbsolutePath(), null);
}
}
/**
* 写入日志到文件
*/
public static void writeLogToFile(String level, String tag, String message) {
if (LOG_DIR == null) {
Log.e(TAG, "日志文件目录未初始化!");
return;
}
File logFile = new File(LOG_DIR, "app_logs.txt");
if (!logFile.exists()) {
try {
if (!logFile.createNewFile()) {
Log.e(TAG, "日志文件创建失败!");
}
} catch (IOException e) {
Log.e(TAG, "日志文件创建异常", e);
}
}
String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(new Date());
String logMessage = timeStamp + " " + level + "/" + tag + ": " + message + "\n";
try (FileWriter writer = new FileWriter(logFile, true)) {
writer.append(logMessage);
checkFileSize(logFile);
} catch (IOException e) {
Log.e(TAG, "写入日志到文件失败", e);
}
}
/**
* 检查文件大小并清理日志内容
*/
private static void checkFileSize(File file) {
if (file.length() > MAX_FILE_SIZE) { // 超出大小限制
try (FileWriter writer = new FileWriter(file, false)) {
writer.write(""); // 清空文件
Log.i(TAG, "日志文件已清空(超出大小限制)");
} catch (IOException e) {
Log.e(TAG, "清空日志文件失败", e);
}
}
}
/**
* 添加到 Android 默认日志同时写入文件并可记录异常信息
*/
public static void logAndWrite(int level, String tag, String message, Throwable throwable) {
switch (level) {
case Log.DEBUG:
Log.d(tag, message);
break;
case Log.INFO:
Log.i(tag, message);
break;
case Log.WARN:
Log.w(tag, message);
break;
case Log.ERROR:
Log.e(tag, message, throwable);
break;
default:
Log.v(tag, message);
break;
}
String levelName;
switch (level) {
case Log.DEBUG:
levelName = "DEBUG";
break;
case Log.INFO:
levelName = "INFO";
break;
case Log.WARN:
levelName = "WARN";
break;
case Log.ERROR:
levelName = "ERROR";
break;
default:
levelName = "VERBOSE";
break;
}
if (throwable != null) {
message += "\n" + Log.getStackTraceString(throwable);
}
writeLogToFile(levelName, tag, message);
}
}

View File

@ -1,54 +0,0 @@
package com.example.studyapp.utils;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
* @Time: 2025/6/20 12:01
* @Creator: 初屿贤
* @File: MockTools
* @Project: study.App
* @Description:
*/
public class MockTools {
public static String exec(String cmd) {
String retString = "";
// 创建 socket
String myCmd = "SU|" + cmd;
try (Socket mSocket = new Socket()) {
InetSocketAddress inetSocketAddress = new InetSocketAddress("127.0.0.1", 12345);
// 设置连接超时时间单位毫秒
mSocket.connect(inetSocketAddress, 5000);
try (BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(mSocket.getOutputStream(), "UTF-8"));
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(mSocket.getInputStream(), "UTF-8"))) {
bufferedWriter.write(myCmd + "\r\n");
bufferedWriter.flush();
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line).append("\n");
}
retString = stringBuilder.toString();
}
} catch (IOException e) {
// 记录 IO 异常具体到日志或执行特定的恢复操作
e.printStackTrace();
} catch (Exception ex) {
// 捕获其他异常并合理处理
ex.printStackTrace();
}
return retString;
}
}

View File

@ -91,7 +91,7 @@ public class ReflectionHelper {
fld.setAccessible(true); fld.setAccessible(true);
return fld; return fld;
} catch (Exception e) { } catch (Exception e) {
android.util.Log.e("Error", "Exception occurred", e); LogFileUtil.logAndWrite(android.util.Log.ERROR, "ReflectionHelper", "Error",e);
return null; return null;
} }
} }

View File

@ -1,8 +1,13 @@
package com.example.studyapp.utils; package com.example.studyapp.utils;
import static java.security.AccessController.getContext;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
import java.io.File; import java.io.File;
@ -21,12 +26,24 @@ import java.util.concurrent.TimeUnit;
public class ShellUtils { public class ShellUtils {
public static String getPackagePath(Context context, String packageName) {
try {
PackageManager pm = context.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
return appInfo.sourceDir; // 返回 APK 的完整路径
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return "";
}
}
public static void exec(String cmd) { public static void exec(String cmd) {
try { try {
Log.e("ShellUtils", String.format("exec %s", cmd)); LogFileUtil.logAndWrite(Log.INFO, "ShellUtils", "Executing command: " + cmd, null);
Process process = Runtime.getRuntime().exec(cmd); Process process = Runtime.getRuntime().exec(cmd);
process.waitFor(); process.waitFor();
} catch (Exception e) { } catch (Exception e) {
LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error executing command: " + e.getMessage(), e);
} }
} }
@ -46,6 +63,7 @@ public class ShellUtils {
public static boolean hasBin(String binName) { public static boolean hasBin(String binName) {
// 验证 binName 是否符合规则 // 验证 binName 是否符合规则
if (binName == null || binName.isEmpty()) { if (binName == null || binName.isEmpty()) {
LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Invalid bin name",null);
throw new IllegalArgumentException("Bin name cannot be null or empty"); throw new IllegalArgumentException("Bin name cannot be null or empty");
} }
@ -58,7 +76,7 @@ public class ShellUtils {
// 获取 PATH 环境变量 // 获取 PATH 环境变量
String pathEnv = System.getenv("PATH"); String pathEnv = System.getenv("PATH");
if (pathEnv == null) { if (pathEnv == null) {
Log.e("hasBin", "PATH environment variable is not available"); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "PATH environment variable is not available", null);
return false; return false;
} }
@ -72,7 +90,7 @@ public class ShellUtils {
return true; return true;
} }
} catch (SecurityException e) { } catch (SecurityException e) {
Log.e("hasBin", "Security exception occurred while checking: " + file.getAbsolutePath(), e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Security exception occurred while checking: " + file.getAbsolutePath(), e);
} }
} }
@ -83,7 +101,7 @@ public class ShellUtils {
public static String execRootCmdAndGetResult(String cmd) { public static String execRootCmdAndGetResult(String cmd) {
Log.d("ShellUtils", "execRootCmdAndGetResult - Started execution for command: " + cmd); Log.d("ShellUtils", "execRootCmdAndGetResult - Started execution for command: " + cmd);
if (cmd == null || cmd.trim().isEmpty()) { if (cmd == null || cmd.trim().isEmpty()) {
Log.e("ShellUtils", "Unsafe or empty command. Aborting execution."); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Unsafe or empty command. Aborting execution.", null);
throw new IllegalArgumentException("Unsafe or empty command."); throw new IllegalArgumentException("Unsafe or empty command.");
} }
// if (!isCommandSafe(cmd)) { // 检查命令的合法性 // if (!isCommandSafe(cmd)) { // 检查命令的合法性
@ -121,10 +139,10 @@ public class ShellUtils {
String line; String line;
try { try {
while ((line = errorReader.readLine()) != null) { while ((line = errorReader.readLine()) != null) {
Log.e("ShellUtils", "Shell Error: " + line); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Shell Error: " + line, null);
} }
} catch (IOException e) { } catch (IOException e) {
Log.e("ShellUtils", "Error while reading process error stream: " + e.getMessage()); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error while reading process error stream: " + e.getMessage(), e);
} }
}); });
@ -144,7 +162,7 @@ public class ShellUtils {
Log.d("ShellUtils", "Awaiting process termination..."); Log.d("ShellUtils", "Awaiting process termination...");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (!process.waitFor(10, TimeUnit.SECONDS)) { if (!process.waitFor(10, TimeUnit.SECONDS)) {
Log.e("ShellUtils", "Process execution timed out. Destroying process."); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Process execution timed out. Destroying process.", null);
process.destroyForcibly(); process.destroyForcibly();
throw new RuntimeException("Shell command execution timeout."); throw new RuntimeException("Shell command execution timeout.");
} }
@ -157,7 +175,7 @@ public class ShellUtils {
break; break;
} catch (IllegalThreadStateException e) { } catch (IllegalThreadStateException e) {
if (System.currentTimeMillis() - startTime > 10000) { // 10 seconds if (System.currentTimeMillis() - startTime > 10000) { // 10 seconds
Log.e("ShellUtils", "Process execution timed out (manual tracking). Destroying process."); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Process execution timed out (manual tracking). Destroying process.", null);
process.destroy(); process.destroy();
throw new RuntimeException("Shell command execution timeout."); throw new RuntimeException("Shell command execution timeout.");
} }
@ -170,7 +188,7 @@ public class ShellUtils {
return output.toString().trim(); return output.toString().trim();
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
Log.e("ShellUtils", "Command execution failed: " + e.getMessage()); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Command execution failed: " + e.getMessage(), e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return "Error: " + e.getMessage(); return "Error: " + e.getMessage();
} finally { } finally {
@ -186,7 +204,7 @@ public class ShellUtils {
public static void execRootCmd(String cmd) { public static void execRootCmd(String cmd) {
// 校验命令是否安全 // 校验命令是否安全
if (!isCommandSafe(cmd)) { if (!isCommandSafe(cmd)) {
Log.e("ShellUtils", "Unsafe command, aborting."); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Unsafe command, aborting.", null);
return; return;
} }
List<String> cmds = new ArrayList<>(); List<String> cmds = new ArrayList<>();
@ -201,7 +219,7 @@ public class ShellUtils {
Log.d("ShellUtils", "Command Result: " + result); Log.d("ShellUtils", "Command Result: " + result);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e("ShellUtils", "Unexpected error: ", e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Unexpected error: " + e.getMessage(), e);
} }
} }
} }
@ -210,13 +228,13 @@ public class ShellUtils {
private static boolean isCommandSafe(String cmd) { private static boolean isCommandSafe(String cmd) {
// 检查空值和空字符串 // 检查空值和空字符串
if (cmd == null || cmd.trim().isEmpty()) { if (cmd == null || cmd.trim().isEmpty()) {
Log.e("ShellUtils", "Rejected command: empty or null value."); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Rejected command: empty or null value.", null);
return false; return false;
} }
// 检查非法字符 // 检查非法字符
if (!cmd.matches("^[a-zA-Z0-9._/:\\-~`'\" *|]+$")) { if (!cmd.matches("^[a-zA-Z0-9._/:\\-~`'\" *|]+$")) {
Log.e("ShellUtils", "Rejected command due to illegal characters: " + cmd); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Rejected command due to illegal characters: " + cmd, null);
return false; return false;
} }
@ -224,23 +242,23 @@ public class ShellUtils {
if (cmd.contains("&&") || cmd.contains("||")) { if (cmd.contains("&&") || cmd.contains("||")) {
Log.d("ShellUtils", "Command contains logical operators."); Log.d("ShellUtils", "Command contains logical operators.");
if (!isExpectedMultiCommand(cmd)) { if (!isExpectedMultiCommand(cmd)) {
Log.e("ShellUtils", "Rejected command due to prohibited structure: " + cmd); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Rejected command due to prohibited structure: " + cmd, null);
return false; return false;
} }
} }
// 路径遍历保护 // 路径遍历保护
if (cmd.contains("../") || cmd.contains("..\\")) { if (cmd.contains("../") || cmd.contains("..\\")) {
Log.e("ShellUtils", "Rejected command due to path traversal attempt: " + cmd); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Rejected command due to path traversal attempt: " + cmd, null);
return false; return false;
} }
// 命令长度限制 // 命令长度限制
if (cmd.startsWith("tar") && cmd.length() > 800) { // 特定命令支持更长长度 if (cmd.startsWith("tar") && cmd.length() > 800) { // 特定命令支持更长长度
Log.e("ShellUtils", "Rejected tar command due to excessive length: " + cmd.length()); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Command rejected due to excessive length.", null);
return false; return false;
} else if (cmd.length() > 500) { } else if (cmd.length() > 500) {
Log.e("ShellUtils", "Rejected command due to excessive length: " + cmd.length()); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Command rejected due to excessive length.", null);
return false; return false;
} }
@ -275,7 +293,7 @@ public class ShellUtils {
results.addAll(localResults); results.addAll(localResults);
} }
} catch (IOException ioException) { } catch (IOException ioException) {
Log.e("ShellUtils", "Error reading stdout", ioException); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error reading stdout", ioException);
} }
}); });
@ -284,10 +302,10 @@ public class ShellUtils {
try (BufferedReader errReader = new BufferedReader(new InputStreamReader(finalProcess.getErrorStream()))) { try (BufferedReader errReader = new BufferedReader(new InputStreamReader(finalProcess.getErrorStream()))) {
String line; String line;
while ((line = errReader.readLine()) != null) { while ((line = errReader.readLine()) != null) {
Log.e("ShellUtils", "Stderr: " + line); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Stderr: " + line, null);
} }
} catch (IOException ioException) { } catch (IOException ioException) {
Log.e("ShellUtils", "Error reading stderr", ioException); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error reading stderr", ioException);
} }
}); });
@ -313,7 +331,7 @@ public class ShellUtils {
process.waitFor(); process.waitFor();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 恢复中断 Thread.currentThread().interrupt(); // 恢复中断
Log.e("ShellUtils", "Error executing commands", e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error executing commands", e);
} }
// 等待子线程完成 // 等待子线程完成
@ -321,10 +339,10 @@ public class ShellUtils {
errThread.join(); errThread.join();
} catch (InterruptedIOException e) { } catch (InterruptedIOException e) {
Log.e("ShellUtils", "Error reading stdout: Interrupted", e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error reading stdout: Interrupted", e);
Thread.currentThread().interrupt(); // 恢复线程的中断状态 Thread.currentThread().interrupt(); // 恢复线程的中断状态
} catch (Exception e) { } catch (Exception e) {
Log.e("ShellUtils", "Error executing commands", e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Error executing commands", e);
} finally { } finally {
if (process != null) { if (process != null) {
process.destroy(); process.destroy();
@ -346,7 +364,7 @@ public class ShellUtils {
} }
} catch (SecurityException e) { } catch (SecurityException e) {
hasSecurityError = true; hasSecurityError = true;
Log.e("ShellUtils", "Security exception while checking: " + bin, e); LogFileUtil.logAndWrite(Log.ERROR, "ShellUtils", "Security exception while checking: " + bin, e);
} }
} }

View File

@ -131,7 +131,7 @@ public class TaskUtilTest {
// 运行上传方法 // 运行上传方法
String taskId = "asddasdasd"; String taskId = "asddasdasd";
TaskUtil.postDeviceInfo("b3d893cf9de3a85a", taskId); TaskUtil.postDeviceInfo("b3d893cf9de3a85a", taskId, "com.example.studyapp");
} }
@Test @Test

273
err.log
View File

@ -1,68 +1,205 @@
2025-06-19 15:45:05.669 1003-63750 GlobalConsole org.autojs.autojs6 D 07:45:05.669/D: 首次 计时线程 已到最大时间 脚本结束 2025-06-23 17:01:42.314 297-3144 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:05.681 1003-63750 GlobalConsole org.autojs.autojs6 D 07:45:05.681/D: 广播发送成功: 运行结束 2025-06-23 17:01:42.320 297-462 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:06.688 1003-63749 GlobalConsole org.autojs.autojs6 D 07:45:06.688/D: 等待安装 2025-06-23 17:01:42.569 297-3144 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:07.689 1003-63750 Loopers org.autojs.autojs6 D notifyThreadExit: Thread[ScriptThread-25[/storage/emulated/0/script/main.js] (Spawn-1),5] 2025-06-23 17:01:43.415 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.SubSettings com.android.settings/com.android.settings.SubSettings
2025-06-19 15:45:07.689 1003-63750 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 2 2025-06-23 17:01:44.188 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=6066, ts=1750669303948, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=6066, ts=1750669303948, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=6066, ts=1750669303948, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=209, time=9, total=6066, ts=1750669303948, pr=20, ni=0, virt=14336, shr=111, s=S, cpu=36.0, mem=6.3, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=307, time=374, total=6066, ts=1750669303948, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.3, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6066, ts=1750669303948, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]
2025-06-19 15:45:07.689 1003-63750 ContextFactory org.autojs.autojs6 D onContextReleased: count = 2 2025-06-23 17:01:45.397 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/androidx.appcompat.app.AlertDialog com.android.settings/androidx.appcompat.app.AlertDialog
2025-06-19 15:45:07.691 1003-63749 GlobalConsole org.autojs.autojs6 D 07:45:07.691/D: 首次 Threds errororg.autojs.autojs.runtime.exception.ScriptInterruptedException: null 2025-06-23 17:01:47.565 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/androidx.appcompat.app.AlertDialog com.android.settings/androidx.appcompat.app.AlertDialog
2025-06-19 15:45:07.692 1003-63749 GlobalConsole org.autojs.autojs6 D 07:45:07.692/D: 首次 脚本线程 脚本catch结束 2025-06-23 17:01:51.409 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.SubSettings com.android.settings/com.android.settings.SubSettings
2025-06-19 15:45:09.693 1003-63749 GlobalConsole org.autojs.autojs6 D 07:45:09.693/D: 任务脚本线程准备结束 2025-06-23 17:01:54.631 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.Settings$AccessibilitySettingsActivity com.android.settings/com.android.settings.Settings$AccessibilitySettingsActivity
2025-06-19 15:45:09.694 1003-63749 Loopers org.autojs.autojs6 D notifyThreadExit: Thread[ScriptThread-25[/storage/emulated/0/script/main.js] (Spawn-0),5] 2025-06-23 17:01:54.661 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.Settings$AccessibilitySettingsActivity com.android.settings/com.android.settings.Settings$AccessibilitySettingsActivity
2025-06-19 15:45:09.694 1003-63749 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 1 2025-06-23 17:01:54.733 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=6066, ts=1750669314510, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=6066, ts=1750669314510, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=6066, ts=1750669314510, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=203, time=13, total=6066, ts=1750669314510, pr=20, ni=0, virt=14336, shr=111, s=S, cpu=3.8, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=307, time=374, total=6066, ts=1750669314510, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.3, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6066, ts=1750669314510, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]
2025-06-19 15:45:09.694 1003-63749 ContextFactory org.autojs.autojs6 D onContextReleased: count = 1 2025-06-23 17:01:56.366 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.Settings$AppManageExternalStorageActivity com.android.settings/com.android.settings.Settings$AppManageExternalStorageActivity
2025-06-19 15:45:09.712 1003-63748 GlobalConsole org.autojs.autojs6 D 07:45:09.712/V: [$sdcard/script/main.js] finished in 104.085 seconds. 2025-06-23 17:01:56.413 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.settings/com.android.settings.Settings$AppManageExternalStorageActivity com.android.settings/com.android.settings.Settings$AppManageExternalStorageActivity
2025-06-19 15:45:09.712 1003-63748 RunnableJSExecution org.autojs.autojs6 D Engine destroy 2025-06-23 17:01:59.870 1532-1532 NotificationObserver org.autojs.autojs6 D onNotification: [Storage Permissions granted]; EventType: TYPE_NOTIFICATION_STATE_CHANGED; EventTime: 870589469; PackageName: com.example.studyapp; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.Toast; Text: [Storage Permissions granted]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: false; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: 0; ScrollY: 0; MaxScrollX: 0; MaxScrollY: 0; ScrollDeltaX: -1; ScrollDeltaY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
2025-06-19 15:45:09.714 1003-63748 ScriptRuntime org.autojs.autojs6 D on exit 2025-06-23 17:01:59.924 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.example.studyapp/com.example.studyapp.MainActivity com.example.studyapp/com.example.studyapp.MainActivity
2025-06-19 15:45:09.718 1003-63748 Loopers org.autojs.autojs6 D recycle 2025-06-23 17:02:05.235 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=6058, ts=1750669325040, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=6058, ts=1750669325040, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=6058, ts=1750669325040, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=206, time=19, total=6058, ts=1750669325040, pr=10, ni=-10, virt=14336, shr=114, s=S, cpu=104.0, mem=6.2, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=308, time=374, total=6058, ts=1750669325040, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.3, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6058, ts=1750669325040, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]
2025-06-19 15:45:09.722 1003-63748 RhinoJavaScriptEngine org.autojs.autojs6 D on destroy 2025-06-23 17:02:08.114 297-16062 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:09.723 1003-63748 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 0 2025-06-23 17:02:08.119 297-462 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:09.723 1003-63748 ContextFactory org.autojs.autojs6 D onContextReleased: count = 0 2025-06-23 17:02:08.365 297-11816 ClipboardService system_server E Denying clipboard access to org.autojs.autojs6, application is not in focus nor is it a system service for user 0
2025-06-19 15:45:15.862 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6568, ts=1750319115627, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6568, ts=1750319115627, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6568, ts=1750319115627, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6568, ts=1750319115627, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6568, ts=1750319115627, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6568, ts=1750319115627, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:09.928 1532-1532 NotificationObserver org.autojs.autojs6 D onNotification: [任务正在执行]; EventType: TYPE_NOTIFICATION_STATE_CHANGED; EventTime: 870599525; PackageName: com.example.studyapp; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.Toast; Text: [任务正在执行]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: false; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: 0; ScrollY: 0; MaxScrollX: 0; MaxScrollY: 0; ScrollDeltaX: -1; ScrollDeltaY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
2025-06-19 15:45:26.571 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6576, ts=1750319126211, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6576, ts=1750319126211, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6576, ts=1750319126211, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6576, ts=1750319126211, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6576, ts=1750319126211, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6576, ts=1750319126211, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.071 51143-51376 isAppInstalled com.example.studyapp D Checking if app is installed: org.autojs.autojs6
2025-06-19 15:45:37.139 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6582, ts=1750319136930, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6582, ts=1750319136930, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6582, ts=1750319136930, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6582, ts=1750319136930, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6582, ts=1750319136930, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6582, ts=1750319136930, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.075 51143-51376 ShellUtils com.example.studyapp D execRootCmdAndGetResult - Started execution for command: pm list packages | grep org.autojs.autojs6
2025-06-19 15:45:47.793 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6542, ts=1750319147469, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6542, ts=1750319147469, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6542, ts=1750319147469, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6542, ts=1750319147469, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6542, ts=1750319147469, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6542, ts=1750319147469, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.120 51143-51376 ShellUtils com.example.studyapp D Shell Output: package:org.autojs.autojs6
2025-06-19 15:45:58.305 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6556, ts=1750319158128, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6556, ts=1750319158128, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6556, ts=1750319158128, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6556, ts=1750319158128, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6556, ts=1750319158128, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6556, ts=1750319158128, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.223 51143-51376 isAppInstalled com.example.studyapp D App is installed: org.autojs.autojs6
2025-06-19 15:46:08.800 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6555, ts=1750319168646, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6555, ts=1750319168646, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6555, ts=1750319168646, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6555, ts=1750319168646, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6555, ts=1750319168646, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6555, ts=1750319168646, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.225 297-3145 ActivityTaskManager system_server I START u0 {flg=0x10000000 cmp=org.autojs.autojs6/org.autojs.autojs.external.open.RunIntentActivity (has extras)} from uid 10234
2025-06-19 15:46:19.422 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6560, ts=1750319179156, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6560, ts=1750319179156, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6560, ts=1750319179156, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6560, ts=1750319179156, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6560, ts=1750319179156, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6560, ts=1750319179156, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.240 1532-1532 App org.autojs.autojs6 D setCurrentActivity: org.autojs.autojs.external.open.RunIntentActivity@aad3ba2
2025-06-19 15:46:30.083 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6564, ts=1750319189782, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6564, ts=1750319189782, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6564, ts=1750319189782, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6564, ts=1750319189782, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6564, ts=1750319189782, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6564, ts=1750319189782, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.243 1532-1532 ScriptEngineService org.autojs.autojs6 D JavaScriptSource: true
2025-06-19 15:46:40.640 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6517, ts=1750319200432, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6517, ts=1750319200432, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6517, ts=1750319200432, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6517, ts=1750319200432, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6517, ts=1750319200432, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6517, ts=1750319200432, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.246 611-2827 TelephonyPermissions com.android.phone W reportAccessDeniedToReadIdentifiers:org.autojs.autojs6:getImeiForSlot:1
2025-06-19 15:46:51.238 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6521, ts=1750319210971, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6521, ts=1750319210971, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6521, ts=1750319210971, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6521, ts=1750319210971, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6521, ts=1750319210971, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6521, ts=1750319210971, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.249 297-6814 TelephonyPermissions system_server W reportAccessDeniedToReadIdentifiers:org.autojs.autojs6:getSerial:-1
2025-06-19 15:47:01.758 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6523, ts=1750319221588, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6523, ts=1750319221588, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6523, ts=1750319221588, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6523, ts=1750319221588, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6523, ts=1750319221588, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6523, ts=1750319221588, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.250 1532-51468 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 1
2025-06-19 15:47:12.365 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6529, ts=1750319232109, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6529, ts=1750319232109, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6529, ts=1750319232109, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6529, ts=1750319232109, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6529, ts=1750319232109, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6529, ts=1750319232109, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.250 1532-51468 ContextFactory org.autojs.autojs6 D onContextCreated: count = 1
2025-06-19 15:47:22.984 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=63183, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=1, total=6539, ts=1750319242700, pr=20, ni=0, virt=1228, shr=69, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=80, time=0, total=6539, ts=1750319242700, pr=20, ni=0, virt=1126, shr=42, s=S, cpu=0.0, mem=2.4, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=0, total=6539, ts=1750319242700, pr=20, ni=0, virt=703, shr=12, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=63432, user=u0_a113, name=Script helper, pkg=com.example.studyapp, res=200, time=22, total=6539, ts=1750319242700, pr=20, ni=0, virt=14336, shr=106, s=S, cpu=0.0, mem=6.1, args=com.example.studyapp), MemEntity(id=null, pid=1003, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=301, time=742, total=6539, ts=1750319242700, pr=20, ni=0, virt=33792, shr=130, s=S, cpu=0.0, mem=9.1, args=org.autojs.autojs6), MemEntity(id=null, pid=16171, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6539, ts=1750319242700, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)] 2025-06-23 17:02:12.294 1532-51468 ScriptEngineService org.autojs.autojs6 D onStart
2025-06-19 15:47:25.325 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.299 1532-51468 GlobalConsole org.autojs.autojs6 D 09:02:12.299/V: Running [$sdcard/script/main.js].
2025-06-19 15:47:25.325 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.307 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.example.studyapp/com.example.studyapp.MainActivity com.example.studyapp/com.example.studyapp.MainActivity
2025-06-19 15:47:25.326 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.307 1532-51469 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 2
2025-06-19 15:47:25.326 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.308 1532-51470 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 3
2025-06-19 15:47:25.326 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.308 1532-51470 ContextFactory org.autojs.autojs6 D onContextCreated: count = 3
2025-06-19 15:47:25.326 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.308 1532-51469 ContextFactory org.autojs.autojs6 D onContextCreated: count = 2
2025-06-19 15:47:25.326 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.309 1532-51471 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 4
2025-06-19 15:47:25.327 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.309 1532-51471 ContextFactory org.autojs.autojs6 D onContextCreated: count = 4
2025-06-19 15:47:25.327 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.313 1532-51469 App org.autojs.autojs6 D getCurrentActivity: org.autojs.autojs.external.open.RunIntentActivity@aad3ba2
2025-06-19 15:47:25.327 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.313 297-6814 ActivityTaskManager system_server I START u0 {flg=0x10000000 cmp=org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity (has extras)} from uid 10100
2025-06-19 15:47:25.327 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.314 297-6814 ActivityTaskManager system_server I Launching r: ActivityRecord{a98f3cd u0 org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity} from background: ActivityRecord{91ff715 u0 org.autojs.autojs6/org.autojs.autojs.external.open.RunIntentActivity} t9913 f}}. New task: true
2025-06-19 15:47:25.328 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.326 1532-1532 App org.autojs.autojs6 D setCurrentActivity: org.autojs.autojs.core.activity.StartForResultActivity@2e7ffe4
2025-06-19 15:47:25.328 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.336 1532-1532 App org.autojs.autojs6 D setCurrentActivity: org.autojs.autojs.core.activity.StartForResultActivity@2e7ffe4
2025-06-19 15:47:25.328 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.337 1532-55975 Parcel org.autojs.autojs6 W Expecting binder but got null!
2025-06-19 15:47:25.328 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.339 297-11816 CoreBackPreview system_server D Window{e9771a6 u0 org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity}: Setting back callback OnBackInvokedCallbackInfo{mCallback=android.window.IOnBackInvokedCallback$Stub$Proxy@1638f94, mPriority=0}
2025-06-19 15:47:25.329 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.340 1532-1532 App org.autojs.autojs6 D setCurrentActivity: null
2025-06-19 15:47:25.329 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.343 1532-51478 TrafficStats org.autojs.autojs6 D tagSocket(245) with statsTag=0x4d2, statsUid=-1
2025-06-19 15:47:25.329 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.343 1532-51478 TrafficStats org.autojs.autojs6 I tagSocketFd(245, 1234, -1) failed with errno-9
2025-06-19 15:47:25.329 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.348 1532-55975 OpenGLRenderer org.autojs.autojs6 E Unable to match the desired swap behavior.
2025-06-19 15:47:25.330 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.421 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.systemui/android.app.AlertDialog com.android.systemui/android.app.AlertDialog
2025-06-19 15:47:25.330 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.851 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity
2025-06-19 15:47:25.330 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:12.871 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.android.systemui/com.android.systemui.media.MediaProjectionPermissionActivity com.android.systemui/com.android.systemui.media.MediaProjectionPermissionActivity
2025-06-19 15:47:25.330 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:13.310 1532-51470 GlobalConsole org.autojs.autojs6 D 09:02:13.310/D: 计时线程: 0/600秒
2025-06-19 15:47:25.330 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:13.321 1532-1532 NotificationObserver org.autojs.autojs6 D onNotification: [计时线程: 0/600秒, AutoJs6]; EventType: TYPE_NOTIFICATION_STATE_CHANGED; EventTime: 870602921; PackageName: org.autojs.autojs6; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.Toast; Text: [计时线程: 0/600秒, AutoJs6]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: false; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: 0; ScrollY: 0; MaxScrollX: 0; MaxScrollY: 0; ScrollDeltaX: -1; ScrollDeltaY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
2025-06-19 15:47:25.331 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:13.827 1532-51471 GlobalConsole org.autojs.autojs6 D 09:02:13.827/D: 点击START NOW
2025-06-19 15:47:25.331 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:13.828 1532-51471 GlobalActionAutomator org.autojs.autojs6 D Path moved to (889.0, 1173.0)
2025-06-19 15:47:25.331 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:13.829 1532-51471 GlobalActionAutomator org.autojs.autojs6 D dispatchGesture: true
2025-06-19 15:47:25.331 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.058 297-3144 DisplayDeviceRepository system_server I Display device added: DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0}
2025-06-19 15:47:25.332 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.062 297-3144 LogicalDisplayMapper system_server I Adding new display: 14: DisplayInfo{"ScreenCapturer", displayId 14", displayGroupId -1, FLAG_PRIVATE, FLAG_PRESENTATION, real 1080 x 1920, largest app 1080 x 1920, smallest app 1080 x 1920, appVsyncOff 0, presDeadline 16666666, mode 14, defaultMode 14, modes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], hdrCapabilities null, userDisabledHdrTypes [], minimalPostProcessingSupported false, rotation 0, state ON, committedState UNKNOWN, type VIRTUAL, uniqueId "virtual:org.autojs.autojs6,10100,ScreenCapturer,0", app 1080 x 1920, density 320 (320.0 x 320.0) dpi, layerStack 14, colorMode 0, supportedColorModes [0], deviceProductInfo null, owner org.autojs.autojs6 (uid 10100), removeMode 1, refreshRateOverride 0.0, brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, installOrientation ROTATION_0}
2025-06-19 15:47:25.332 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.070 297-313 DisplayManagerService system_server W Display DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0} does not support input device matching.
2025-06-19 15:47:25.332 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.071 297-313 DisplayManagerService system_server W Display DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0} does not support input device matching.
2025-06-19 15:47:25.332 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.072 297-313 DisplayDevice system_server I [14] Layerstack set to 14 for virtual:org.autojs.autojs6,10100,ScreenCapturer,0
2025-06-19 15:47:25.333 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.073 297-313 DisplayManagerService system_server W Display DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0} does not support input device matching.
2025-06-19 15:47:25.333 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.075 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-19 15:47:25.333 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.075 1532-1532 ContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-19 15:47:25.333 297-375 AlarmManager system_server D setImplLocked() callingPackage=org.autojs.autojs6 2025-06-23 17:02:14.076 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.076 1532-1532 ContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.078 297-316 DisplayManagerService system_server W Display DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0} does not support input device matching.
2025-06-23 17:02:14.079 297-334 DisplayPow...roller[14] system_server I BrightnessEvent: disp=14, physDisp=virtual:org.autojs.autojs6,10100,ScreenCapturer,0, brt=0.035433073, initBrt=NaN, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=-1, powerFactor=1.0, thrmMax=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false
2025-06-23 17:02:14.079 297-334 DisplayPow...roller[14] system_server I BrightnessEvent: disp=14, physDisp=virtual:org.autojs.autojs6,10100,ScreenCapturer,0, brt=0.035433073, initBrt=0.035433073, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=-1, powerFactor=1.0, thrmMax=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false
2025-06-23 17:02:14.079 297-334 DisplayPow...roller[14] system_server I BrightnessEvent: disp=14, physDisp=virtual:org.autojs.autojs6,10100,ScreenCapturer,0, brt=0.035433073, initBrt=0.035433073, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=-1, powerFactor=1.0, thrmMax=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false
2025-06-23 17:02:14.079 297-334 DisplayPow...roller[14] system_server I BrightnessEvent: disp=14, physDisp=virtual:org.autojs.autojs6,10100,ScreenCapturer,0, brt=0.035433073, initBrt=0.035433073, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=-1, powerFactor=1.0, thrmMax=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false
2025-06-23 17:02:14.079 297-334 DisplayPow...roller[14] system_server I BrightnessEvent: disp=14, physDisp=virtual:org.autojs.autojs6,10100,ScreenCapturer,0, brt=0.035433073, initBrt=0.035433073, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=-1, powerFactor=1.0, thrmMax=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false
2025-06-23 17:02:14.080 297-3144 ActivityTaskManager system_server W Duplicate finish request for r=ActivityRecord{a98f3cd u0 org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity} t9914 f}}
2025-06-23 17:02:14.081 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-23 17:02:14.081 1532-1532 ContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-23 17:02:14.081 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.081 1532-1532 ContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.082 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-23 17:02:14.082 1532-1532 ContextFactory org.autojs.autojs6 D onContextCreated: count = 5
2025-06-23 17:02:14.082 1532-1532 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.082 1532-1532 ContextFactory org.autojs.autojs6 D onContextReleased: count = 4
2025-06-23 17:02:14.083 1532-51469 GlobalConsole org.autojs.autojs6 D 09:02:14.082/D: 首次 Threds errorFailed to invoke method app.viewFile. Cannot view /sdcard/script/launcher-release.apk as it doesn't exist (/storage/emulated/0/script/main.js#647)
2025-06-23 17:02:14.083 1532-51469 GlobalConsole org.autojs.autojs6 D 09:02:14.083/D: 首次 脚本线程 脚本catch结束
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W org.mozilla.javascript.WrappedException: Wrapped org.autojs.autojs.runtime.exception.ScriptInterruptedException (/storage/emulated/0/script/main.js#105)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.augmentFunctionsBy$lambda$24$lambda$23(Augmentable.kt:432)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.$r8$lambda$Fn1T-F1qaCuaZ27e1ntAmyEtA5M(Unknown Source:0)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$InternalBaseFunction.callFunc$app_appRelease(RhinoUtils.kt:877)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$newBaseFunction$5.call(RhinoUtils.kt:237)
2025-06-23 17:02:14.084 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.doCallByteCode(Interpreter.java:3019)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1973)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at script(/storage/emulated/0/script/main.js:105)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1161)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:347)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:4450)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction$lambda$7(RhinoUtils.kt:169)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.$r8$lambda$f8ShGIQnCN3BfY5ui2ZDzafysTo(Unknown Source:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.withRhinoContext(RhinoUtils.kt:754)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:164)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:153)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:141)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.coerceRunnable$lambda$26(RhinoUtils.kt:435)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.$r8$lambda$spHwZG5wVYypfhMmC-EzLoJxvzU(Unknown Source:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at android.os.Handler.handleCallback(Handler.java:942)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at android.os.Handler.dispatchMessage(Handler.java:99)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at android.os.Looper.loopOnce(Looper.java:201)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at android.os.Looper.loop(Looper.java:288)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.core.looper.TimerThread.run(TimerThread.kt:56)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W Caused by: org.autojs.autojs.runtime.exception.ScriptInterruptedException
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.ScriptRuntime.sleep(ScriptRuntime.kt:507)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.sleep$lambda$20(Global.kt:244)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.$r8$lambda$OWAsxQgJG0C1vfHeAuhT_906-VY(Unknown Source:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion$$ExternalSyntheticLambda19.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.extension.FlexibleArray$Companion.unwrapAndInvokeAll(FlexibleArray.kt:76)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.extension.FlexibleArray$Companion.ensureArgumentsLengthInRange(FlexibleArray.kt:56)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.sleep(Global.kt:224)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global.sleep(Unknown Source:2)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at java.lang.reflect.Method.invoke(Native Method)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.augmentFunctionsBy$lambda$24$lambda$23(Augmentable.kt:415)
2025-06-23 17:02:14.085 1532-51470 System.err org.autojs.autojs6 W ... 25 more
2025-06-23 17:02:14.085 1532-51470 Loopers org.autojs.autojs6 D notifyThreadExit: Thread[ScriptThread-8[/storage/emulated/0/script/main.js] (Spawn-1),5]
2025-06-23 17:02:14.085 1532-51470 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 3
2025-06-23 17:02:14.085 1532-51470 ContextFactory org.autojs.autojs6 D onContextReleased: count = 3
2025-06-23 17:02:14.085 1532-51469 Loopers org.autojs.autojs6 D notifyThreadExit: Thread[ScriptThread-8[/storage/emulated/0/script/main.js] (Spawn-0),5]
2025-06-23 17:02:14.085 1532-51469 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 2
2025-06-23 17:02:14.085 1532-51469 ContextFactory org.autojs.autojs6 D onContextReleased: count = 2
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W org.mozilla.javascript.WrappedException: Wrapped org.autojs.autojs.runtime.exception.ScriptInterruptedException (/storage/emulated/0/script/main.js#160)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.augmentFunctionsBy$lambda$24$lambda$23(Augmentable.kt:432)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.$r8$lambda$Fn1T-F1qaCuaZ27e1ntAmyEtA5M(Unknown Source:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$InternalBaseFunction.callFunc$app_appRelease(RhinoUtils.kt:877)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$newBaseFunction$5.call(RhinoUtils.kt:237)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.doCallByteCode(Interpreter.java:3019)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1973)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at script(/storage/emulated/0/script/main.js:160)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1161)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:347)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:4450)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction$lambda$7(RhinoUtils.kt:169)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.$r8$lambda$f8ShGIQnCN3BfY5ui2ZDzafysTo(Unknown Source:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.withRhinoContext(RhinoUtils.kt:754)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:164)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:153)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.callFunction(RhinoUtils.kt:141)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.coerceRunnable$lambda$26(RhinoUtils.kt:435)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils.$r8$lambda$spHwZG5wVYypfhMmC-EzLoJxvzU(Unknown Source:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.util.RhinoUtils$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at android.os.Handler.handleCallback(Handler.java:942)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at android.os.Handler.dispatchMessage(Handler.java:99)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at android.os.Looper.loopOnce(Looper.java:201)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at android.os.Looper.loop(Looper.java:288)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.core.looper.TimerThread.run(TimerThread.kt:56)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W Caused by: org.autojs.autojs.runtime.exception.ScriptInterruptedException
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.ScriptRuntime.sleep(ScriptRuntime.kt:507)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.sleep$lambda$20(Global.kt:244)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.$r8$lambda$OWAsxQgJG0C1vfHeAuhT_906-VY(Unknown Source:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion$$ExternalSyntheticLambda19.invoke(D8$$SyntheticClass:0)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.extension.FlexibleArray$Companion.unwrapAndInvokeAll(FlexibleArray.kt:76)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.extension.FlexibleArray$Companion.ensureArgumentsLengthInRange(FlexibleArray.kt:56)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global$Companion.sleep(Global.kt:224)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.global.Global.sleep(Unknown Source:2)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at java.lang.reflect.Method.invoke(Native Method)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W at org.autojs.autojs.runtime.api.augment.Augmentable.augmentFunctionsBy$lambda$24$lambda$23(Augmentable.kt:415)
2025-06-23 17:02:14.086 1532-51471 System.err org.autojs.autojs6 W ... 25 more
2025-06-23 17:02:14.086 1532-51471 Loopers org.autojs.autojs6 D notifyThreadExit: Thread[ScriptThread-8[/storage/emulated/0/script/main.js] (Spawn-2),5]
2025-06-23 17:02:14.086 1532-51471 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 1
2025-06-23 17:02:14.086 1532-51471 ContextFactory org.autojs.autojs6 D onContextReleased: count = 1
2025-06-23 17:02:14.087 1532-51468 GlobalConsole org.autojs.autojs6 D 09:02:14.087/V: [$sdcard/script/main.js] finished in 1.787 seconds.
2025-06-23 17:02:14.087 1532-51468 RunnableJSExecution org.autojs.autojs6 D Engine destroy
2025-06-23 17:02:14.087 1532-51468 ScriptRuntime org.autojs.autojs6 D on exit
2025-06-23 17:02:14.087 1532-51468 Loopers org.autojs.autojs6 D recycle
2025-06-23 17:02:14.089 297-3143 DisplayDeviceRepository system_server I Display device removed: DisplayDeviceInfo{"ScreenCapturer": uniqueId="virtual:org.autojs.autojs6,10100,ScreenCapturer,0", 1080 x 1920, modeId 14, defaultModeId 14, supportedModes [{id=14, width=1080, height=1920, fps=60.0, alternativeRefreshRates=[]}], colorMode 0, supportedColorModes [0], hdrCapabilities null, allmSupported false, gameContentTypeSupported false, density 320, 320.0 x 320.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, deviceProductInfo null, state ON, committedState UNKNOWN, owner org.autojs.autojs6 (uid 10100), frameRateOverride , brightnessMinimum 0.0, brightnessMaximum 0.0, brightnessDefault 0.0, FLAG_PRIVATE, FLAG_PRESENTATION, installOrientation 0}
2025-06-23 17:02:14.093 1532-51468 RhinoJavaScriptEngine org.autojs.autojs6 D on destroy
2025-06-23 17:02:14.093 1532-51468 AndroidContextFactory org.autojs.autojs6 D onContextReleased: count = 0
2025-06-23 17:02:14.093 1532-51468 ContextFactory org.autojs.autojs6 D onContextReleased: count = 0
2025-06-23 17:02:14.093 1532-5003 BufferQueueProducer org.autojs.autojs6 E [ImageReader-1080x1920f1m3-1532-8](id:5fc00000021,api:1,p:52,c:1532) dequeueBuffer: BufferQueue has been abandoned
2025-06-23 17:02:14.099 1532-1532 ActivityInfoProvider org.autojs.autojs6 D setLatestComponent: com.example.studyapp/com.example.studyapp.MainActivity com.example.studyapp/com.example.studyapp.MainActivity
2025-06-23 17:02:14.102 1532-5003 BpBinder org.autojs.autojs6 I onLastStrongRef automatically unlinking death recipients: <uncached descriptor>
2025-06-23 17:02:14.103 297-6815 CoreBackPreview system_server D Window{e9771a6 u0 org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity}: Setting back callback null
2025-06-23 17:02:14.104 297-6815 InputManager-JNI system_server W Input channel object 'e9771a6 org.autojs.autojs6/org.autojs.autojs.core.activity.StartForResultActivity (client)' was disposed without first being removed with the input manager!
2025-06-23 17:02:14.251 297-297 NotificationService system_server I Cannot find enqueued record for key: 0|org.autojs.autojs6|207|null|10100
2025-06-23 17:02:15.923 297-3145 NotificationService system_server W Toast already killed. pkg=org.autojs.autojs6 token=android.os.BinderProxy@fb6cbea
2025-06-23 17:02:15.934 1532-1532 NotificationObserver org.autojs.autojs6 D onNotification: [首次 Threds errorFailed to invoke method app.viewFile. Cannot view /sdcard/script/launcher-release.apk as it doesn't exist (/storage/emulated/0/script/main.js#647), AutoJs6]; EventType: TYPE_NOTIFICATION_STATE_CHANGED; EventTime: 870605533; PackageName: org.autojs.autojs6; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.Toast; Text: [首次 Threds errorFailed to invoke method app.viewFile. Cannot view /sdcard/script/launcher-release.apk as it doesn't exist (/storage/emulated/0/script/main.js#647), AutoJs6]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: false; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: 0; ScrollY: 0; MaxScrollX: 0; MaxScrollY: 0; ScrollDeltaX: -1; ScrollDeltaY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
2025-06-23 17:02:16.164 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=5956, ts=1750669335563, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=5956, ts=1750669335563, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=5956, ts=1750669335563, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=212, time=22, total=5956, ts=1750669335563, pr=10, ni=-10, virt=14336, shr=115, s=S, cpu=0.0, mem=6.4, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=314, time=374, total=5956, ts=1750669335563, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.5, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=5956, ts=1750669335563, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]
2025-06-23 17:02:18.505 297-3143 NotificationService system_server W Toast already killed. pkg=org.autojs.autojs6 token=android.os.BinderProxy@c258390
2025-06-23 17:02:18.517 1532-1532 NotificationObserver org.autojs.autojs6 D onNotification: [首次 脚本线程 脚本catch结束, AutoJs6]; EventType: TYPE_NOTIFICATION_STATE_CHANGED; EventTime: 870608116; PackageName: org.autojs.autojs6; MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [ ClassName: android.widget.Toast; Text: [首次 脚本线程 脚本catch结束, AutoJs6]; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; Enabled: false; Password: false; Checked: false; FullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: 0; ScrollY: 0; MaxScrollX: 0; MaxScrollY: 0; ScrollDeltaX: -1; ScrollDeltaY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0
2025-06-23 17:02:21.098 297-3143 NotificationService system_server W Toast already killed. pkg=org.autojs.autojs6 token=android.os.BinderProxy@afcbf66
2025-06-23 17:02:23.095 1532-51478 TrafficStats org.autojs.autojs6 D tagSocket(92) with statsTag=0x4d2, statsUid=-1
2025-06-23 17:02:23.095 1532-51478 TrafficStats org.autojs.autojs6 I tagSocketFd(92, 1234, -1) failed with errno-9
2025-06-23 17:02:24.589 1532-51478 TrafficStats org.autojs.autojs6 D tagSocket(92) with statsTag=0x4d2, statsUid=-1
2025-06-23 17:02:24.589 1532-51478 TrafficStats org.autojs.autojs6 I tagSocketFd(92, 1234, -1) failed with errno-9
2025-06-23 17:02:26.771 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=6027, ts=1750669346510, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=6027, ts=1750669346510, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=6027, ts=1750669346510, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=212, time=22, total=6027, ts=1750669346510, pr=10, ni=-10, virt=14336, shr=115, s=S, cpu=0.0, mem=6.4, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=315, time=374, total=6027, ts=1750669346510, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.6, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6027, ts=1750669346510, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]
2025-06-23 17:02:35.613 1532-51478 TrafficStats org.autojs.autojs6 D tagSocket(92) with statsTag=0x4d2, statsUid=-1
2025-06-23 17:02:35.613 1532-51478 TrafficStats org.autojs.autojs6 I tagSocketFd(92, 1234, -1) failed with errno-9
2025-06-23 17:02:36.534 1532-51478 TrafficStats org.autojs.autojs6 D tagSocket(92) with statsTag=0x4d2, statsUid=-1
2025-06-23 17:02:36.535 1532-51478 TrafficStats org.autojs.autojs6 I tagSocketFd(92, 1234, -1) failed with errno-9
2025-06-23 17:02:37.413 2002-2092 MemInfoService com.android.expansiontools D memScan: [MemEntity(id=null, pid=35830, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=139, time=2, total=6034, ts=1750669357102, pr=20, ni=0, virt=1228, shr=84, s=S, cpu=0.0, mem=4.2, args=com.github.kr328.clash), MemEntity(id=null, pid=63204, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=123, time=92, total=6034, ts=1750669357102, pr=20, ni=0, virt=1126, shr=38, s=S, cpu=0.0, mem=3.7, args=com.github.kr328.clash:core), MemEntity(id=null, pid=63228, user=u0_a104, name=Clash for Android, pkg=com.github.kr328.clash, res=25, time=259, total=6034, ts=1750669357102, pr=20, ni=0, virt=704, shr=10, s=S, cpu=0.0, mem=0.7, args=libclash.so), MemEntity(id=null, pid=51143, user=u0_a234, name=Script helper, pkg=com.example.studyapp, res=212, time=22, total=6034, ts=1750669357102, pr=10, ni=-10, virt=14336, shr=115, s=S, cpu=0.0, mem=6.4, args=com.example.studyapp), MemEntity(id=null, pid=1532, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=315, time=374, total=6034, ts=1750669357102, pr=20, ni=0, virt=33792, shr=179, s=S, cpu=0.0, mem=9.6, args=org.autojs.autojs6), MemEntity(id=null, pid=56880, user=u0_a100, name=AutoJs6, pkg=org.autojs.autojs6, res=0, time=0, total=6034, ts=1750669357102, pr=20, ni=0, virt=10240, shr=0, s=S, cpu=0.0, mem=0.0, args=sh)]

View File

@ -19,4 +19,4 @@ android.useAndroidX=true
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
org.gradle.java.home=C:/Program Files/Java/jdk-21 #org.gradle.java.home=C:/Program Files/Java/jdk-21