← 返回 Skills 市场
githubzyq

Android Stack Analyzer

作者 zyq · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
39
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install android-stack-analyzer
功能描述
Quickly view and analyze Android device page stacks including current page, Activity history, Fragments, and monitor page switches via ADB commands.
使用说明 (SKILL.md)

Android Stack Analyzer - 安卓页面栈分析工具

简介

这个技能让你通过ADB命令快速查看安卓设备的页面栈信息,包括当前页面、Activity历史、Fragment等。适用于Android开发者、测试人员和逆向工程师。

功能特点

  • 查看当前最上层页面
  • 分析完整Activity页面栈
  • 查看Fragment页面栈
  • 监控页面切换
  • 支持不同Android版本的命令兼容性

使用方法

1. 查看当前最上层页面

Windows:

adb shell "dumpsys window | findstr mCurrentFocus"

Linux/macOS:

adb shell "dumpsys window | grep mCurrentFocus"

输出示例:

mCurrentFocus=Window{... u0 com.example.app/com.example.app.MainActivity}

2. 查看完整Activity页面栈

Windows:

adb shell "dumpsys activity activities | findstr /R "Hist\|ResumedActivity\|mFocusedActivity"

Linux/macOS:

adb shell "dumpsys activity activities | grep -E 'Hist|ResumedActivity|mFocusedActivity'"

输出示例:

* Hist #3: ActivityRecord{... u0 com.example.app/.activity.MainActivity t533}
* Hist #2: ActivityRecord{... u0 com.example.app/.activity.SettingsActivity t533}
ResumedActivity: ActivityRecord{... u0 com.example.app/.activity.MainActivity t533}

3. 查看页面栈中的Fragment

Windows:

adb shell "dumpsys activity \x3C包名>"

示例:查看com.example.app的Fragment信息

adb shell "dumpsys activity com.example.app"

Linux/macOS:

adb shell "dumpsys activity \x3C包名>"

示例:查看com.example.app的Fragment信息

adb shell "dumpsys activity com.example.app"

4. 查看Activity任务栈树形结构

Windows:

adb shell "dumpsys activity activities | findstr /R "TaskRecord\|ActivityRecord"

Linux/macOS:

adb shell "dumpsys activity activities | grep -E 'TaskRecord|ActivityRecord'"

5. 查看最近任务列表

Windows:

adb shell "dumpsys activity recents"

Linux/macOS:

adb shell "dumpsys activity recents"

6. 实时监控当前页面切换

Windows:

adb shell "while /l %%i in () do @echo [%time%] & adb shell "dumpsys window | findstr mCurrentFocus" & timeout /t 1 > nul"

Linux/macOS:

adb shell "while true; do echo "[$(date '+%H:%M:%S')] $(adb shell 'dumpsys window | grep mCurrentFocus')"; sleep 1; done"

7. 查看Activity生命周期状态

Windows:

adb shell "dumpsys activity activities | findstr state="

Linux/macOS:

adb shell "dumpsys activity activities | grep 'state='"

高级用法

查看特定包名的详细Activity信息

Windows:

adb shell "dumpsys activity a \x3C包名>"

Linux/macOS:

adb shell "dumpsys activity a \x3C包名>"

查看所有运行中的进程及对应的Activity

Windows:

adb shell "dumpsys activity processes"

Linux/macOS:

adb shell "dumpsys activity processes"

查看Back Stack详细信息

Windows:

adb shell "dumpsys activity activities | findstr /R "mResumedActivity\|mFocusedActivity"

Linux/macOS:

adb shell "dumpsys activity activities | grep -E 'mResumedActivity|mFocusedActivity'"

输出解析

mCurrentFocus字段

  • u0 - 用户应用(User app)
  • s0 - 系统应用(System app)
  • com.example.app - 包名
  • com.example.app.MainActivity - Activity类名

Activity历史栈

  • * Hist #3 - 历史记录中的第3个Activity(数字越大越新)
  • u0 - 用户应用
  • t533 - 任务ID
  • inHistory=true - 在历史栈中
  • mStartingWindowState=STARTING_WINDOW_NOT_SHOWN - 启动窗口状态

Activity状态

  • INITIALIZING - 初始化中
  • RESUMED - 前台可见
  • PAUSED - 暂停
  • STOPPED - 停止
  • DESTROYED - 已销毁

兼容性说明

Windows平台

  • 使用 adb 而不是 adb.exe(通常PATH中已配置)
  • 使用 findstr 而不是 grep
  • 使用 findstr /R 进行正则匹配
  • 命令示例:
adb shell "dumpsys window | findstr mCurrentFocus"

Linux/macOS平台

  • 使用 adb 命令
  • 使用 grep 命令
  • 支持正则表达式匹配
  • 命令示例:
adb shell "dumpsys window | grep mCurrentFocus"

Android版本差异

  • Android 13+ 部分 dumpsys 输出格式有变化
  • 如果命令不生效,可以先查看原始输出确认字段名
  • 某些设备可能需要root权限才能获取完整信息

常见问题

1. findstr/grep命令不可用

某些设备上可能没有这些命令,可以:

  • 使用 adb shell dumpsys window 然后手动查找
  • 使用 adb shell dumpsys activity activities 然后手动查找

2. 输出太多信息

可以使用包名过滤:

adb shell "dumpsys activity activities | grep com.example.app"

3. 系统应用信息被隐藏

某些设备可能需要开启开发者选项中的"显示系统级应用"

4. 页面栈不准确

  • 可能是WebView或Dialog/PopupWindow遮挡
  • 可以使用 dumpsys activity activities | grep ResumedActivity 确认

实用脚本

自动化脚本示例

#!/bin/bash
# 获取当前页面
echo "=== 当前页面 ==="
adb shell "dumpsys window | grep mCurrentFocus"

# 获取页面栈
echo -e "\
=== 页面栈 ==="
adb shell "dumpsys activity activities | grep -E 'Hist|ResumedActivity'"

# 获取最近任务
echo -e "\
=== 最近任务 ==="
adb shell "dumpsys activity recents"

批量检查多个应用

#!/bin/bash
apps=("com.example.app1" "com.example.app2" "com.example.app3")

for app in "${apps[@]}"; do
    echo "=== 检查 $app ==="
    adb shell "dumpsys activity activities | grep $app"
    echo ""
done

注意事项

  1. 确保设备已开启USB调试模式
  2. 某些设备可能需要授权ADB连接
  3. 系统应用信息可能需要root权限
  4. 不同Android版本输出格式可能不同
  5. 部分设备可能禁用了某些dumpsys命令

更新日志

  • v1.0.0 - 初始版本,支持基本页面栈分析功能
  • v1.1.0 - 添加Fragment查看功能
  • v1.2.0 - 添加实时监控功能
  • v1.3.0 - 添加跨平台兼容性支持
安全使用建议
Install only if you intend to use ADB on devices you own or are authorized to debug. Treat dumpsys, getprop, and logcat output as potentially sensitive, redact package names or logs before sharing, and run real-time monitoring only when you explicitly need it.
能力评估
Purpose & Capability
The stated purpose is Android page-stack analysis, and the artifacts consistently provide ADB dumpsys commands and small helper scripts for current Activity, history, recents, fragments, and monitoring.
Instruction Scope
Some activation phrases such as "adb 命令" and "当前页面" are broad, but the runtime behavior remains aligned with Android debugging and requires an attached, ADB-authorized device or explicit script execution.
Install Mechanism
Installation is manual copying into a LobsterAI skills directory, plus optional chmod/PATH setup for ADB; there is no hidden installer, dependency fetch, network setup, or automatic execution.
Credentials
ADB commands like dumpsys, getprop, and logcat can expose device, app, task, and log information, but that access is expected for this debugging purpose and is disclosed through the command examples.
Persistence & Privilege
The skill does not create background services or persistent privileged hooks; monitoring scripts run only when invoked and stop with Ctrl+C.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install android-stack-analyzer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /android-stack-analyzer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Android Stack Analyzer 1.0.0 - Initial release with core page stack analysis tools for Android devices - Supports viewing the current foreground Activity, complete Activity back stack, and Fragment stack - Includes commands for real-time page switch monitoring and recent tasks - Provides cross-platform compatibility (Windows, Linux, macOS) - Offers detailed command examples and practical usage scripts
元数据
Slug android-stack-analyzer
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Android Stack Analyzer 是什么?

Quickly view and analyze Android device page stacks including current page, Activity history, Fragments, and monitor page switches via ADB commands. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 39 次。

如何安装 Android Stack Analyzer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install android-stack-analyzer」即可一键安装,无需额外配置。

Android Stack Analyzer 是免费的吗?

是的,Android Stack Analyzer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Android Stack Analyzer 支持哪些平台?

Android Stack Analyzer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Android Stack Analyzer?

由 zyq(@githubzyq)开发并维护,当前版本 v1.0.0。

💬 留言讨论