OwnDroid 中文文档 下载 App

ADB Shell 与 Kotlin 调用示例

ADB Shell 调用

电脑通过 USB 连接设备,用 adb shell 的 am broadcast 命令发送 Intent 广播:

# 隐藏指定包名的应用
am broadcast -a com.bintianqi.owndroid.action.HIDE ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY ^
  --es package com.example.app

# 挂起应用(Android 7+)
am broadcast -a com.bintianqi.owndroid.action.SUSPEND ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY ^
  --es package com.game.app

# 禁用摄像头
am broadcast -a com.bintianqi.owndroid.action.SET_CAMERA_DISABLED ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY

# 禁止截屏录屏
am broadcast -a com.bintianqi.owndroid.action.SET_SCREEN_CAPTURE_DISABLED ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY

# 清除应用存储(Android 9+)
am broadcast -a com.bintianqi.owndroid.action.CLEAR_APP_STORAGE ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY ^
  --es package com.example.app

# 批量隐藏多个应用(多个 --es package 参数)
am broadcast -a com.bintianqi.owndroid.action.HIDE ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY ^
  --es package com.game.app ^
  --es package com.social.app ^
  --es package com.shopping.app

# 开启禁止安装任何应用用户限制
am broadcast -a com.bintianqi.owndroid.action.ADD_USER_RESTRICTION ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY ^
  --es restriction no_install_apps

# 设备锁屏
am broadcast -a com.bintianqi.owndroid.action.LOCK ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY

# 设备重启(Android 7+)
am broadcast -a com.bintianqi.owndroid.action.REBOOT ^
  -n com.bintianqi.owndroid/.ApiReceiver ^
  --es key YOUR_API_KEY

Windows PowerShell 里可以用 ^ 换行,或者写成单行。

Kotlin 调用

从任何 Android App 内部发送广播:

// 挂起 com.game.app
val intent = Intent("com.bintianqi.owndroid.action.SUSPEND")
    .setComponent(ComponentName(
        "com.bintianqi.owndroid",
        "com.bintianqi.owndroid.ApiReceiver"
    ))
    .putExtra("key", "YOUR_API_KEY")
    .putExtra("package", "com.game.app")
context.sendBroadcast(intent)

// 授予权限
val grantIntent = Intent("com.bintianqi.owndroid.action.SET_PERMISSION_GRANTED")
    .setComponent(ComponentName("com.bintianqi.owndroid", "com.bintianqi.owndroid.ApiReceiver"))
    .putExtra("key", "YOUR_API_KEY")
    .putExtra("package", "com.camera.app")
    .putExtra("permission", "android.permission.CAMERA")
context.sendBroadcast(grantIntent)

// 禁用摄像头
val cameraIntent = Intent("com.bintianqi.owndroid.action.SET_CAMERA_DISABLED")
    .setComponent(ComponentName("com.bintianqi.owndroid", "com.bintianqi.owndroid.ApiReceiver"))
    .putExtra("key", "YOUR_API_KEY")
context.sendBroadcast(cameraIntent)

Tasker / Automate 集成

Tasker 和 Automate 这类自动化工具可以发送自定义 Intent 广播——填入 OwnDroid 的 Action、Component、Extras 即可实现自动化触发。比如 Tasker 里创建一个 Profile:

效果:每天晚上 10 点自动挂起游戏,防止睡前熬夜打游戏。第二天早上 7 点自动 UNSUSPEND。

常见问题