【问题标题】:Configure launchd to run shell script when Android device is connected配置 launchd 以在连接 Android 设备时运行 shell 脚本
【发布时间】:2017-06-06 20:10:28
【问题描述】:

当特定的 Android 设备连接到我的运行 macOS 的计算机时,我想在我的计算机上启动一个程序。我知道这是可能的,因为当我插入 Android 设备时。我以this 回答为例

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.example.program</string>
    <key>ProgramArguments</key>
    <array>
    <string>/path/to/program</string>
    </array>
    <key>LaunchEvents</key>
    <dict>
            <key>com.apple.iokit.matching</key>
            <dict>
                    <key>com.apple.device-attach</key>
                    <dict>
                            <key>idProduct</key>
                            <integer>1234</integer>
                            <key>idVendor</key>
                            <integer>1337</integer>
                            <key>IOProviderClass</key>
                            <string>IOUSBDevice</string>
                            <key>IOMatchLaunchStream</key>
                            <true/>
                    </dict>
            </dict>
    </dict>
</dict>
</plist>

我希望它在具有特定 IMEI 号码的 Android 设备连接到我的计算机时启动,而不是 Apple 设备。

【问题讨论】:

  • 不知道mac,但是adb shell getprop会列出imei

标签: android macos adb launchd


【解决方案1】:

可以通过匹配 android 设备 ID、供应商 ID 并进一步添加 adb getprop 命令并读取有关 imei 的特定结果,其他内容。我对 mac 不了解,但同样可以在 linux 中使用 init bg 脚本完成。你acn进一步窥视这个应用程序源https://github.com/mortenjust/androidtool-mac

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-20
    • 1970-01-01
    • 1970-01-01
    • 2015-04-30
    • 2015-03-29
    • 2012-05-03
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多