Файли
openidea/plugins/official/android-devices/devices/list.sh
T
Alexandro Trevisanтаl0ng-ai 579ce3f731 feat(run): choose the run device from plugin device providers (#7822)
* feat(run): choose the run device from plugin device providers

Plugins can declare device providers (`[[contributes.devices]]`): a program
that lists simulators, emulators or phones as JSON, the run configurations
it applies to, and how a chosen device reaches the run (extra arguments,
environment, an optional prepare step that boots it). The title bar shows a
device chooser for the selected configuration; Run and Debug prepare the
chosen device first. Before-launch and build-on-update runs skip the device.

* feat(plugins): document run devices and require plugin API 1.21

`[[contributes.devices]]` now needs `engines.openidea = "^1.21"` and uses
camelCase fields (`appliesTo`, `runArgs`) like the other run contribution
points. The plugin README, the manifest reference and the API versions page
(en/zh) describe it, and `plugins/official/android-devices` is a small
example that lists the devices adb sees for Gradle install tasks.

* fix(plugins): harden device runner process handling, guard refresh races, verbatim headers, and add en.json entries

* fix(plugins): use portable process:sh capability in android-devices example and README

---------

Co-authored-by: l0ng-ai <[email protected]>
2026-12-05 09:34:41 +08:00

18 рядки
760 B
Bash

# Prints the devices `adb devices -l` reports as the JSON array OpenIDEA reads:
# [{"id": "emulator-5554", "name": "Pixel 8", "group": "Emulators", "running": true}, ...]
if ! command -v adb >/dev/null 2>&1; then
echo "adb not found on PATH: install the Android SDK platform tools" >&2
exit 1
fi
adb devices -l | awk '
BEGIN { printf "["; n = 0 }
NR > 1 && $2 == "device" {
id = $1; name = id
for (i = 3; i <= NF; i++) if ($i ~ /^model:/) { name = substr($i, 7); gsub("_", " ", name) }
gsub(/["\\]/, "", id); gsub(/["\\]/, "", name)
group = id ~ /^emulator-/ ? "Emulators" : "Physical Devices"
printf "%s{\"id\":\"%s\",\"name\":\"%s\",\"group\":\"%s\",\"running\":true}", (n++ ? "," : ""), id, name, group
}
END { print "]" }
'