Android remote test tools with LLM - Kotlin (Ktor + Adam) implementation
이 프로젝트는 Kotlin, Ktor 웹 프레임워크, 그리고 Adam 라이브러리를 사용하여 Android 디바이스를 원격으로 제어하고 모니터링할 수 있는 서버입니다.
This project is a server built with Kotlin, Ktor web framework, and the Adam library for remote control and monitoring of Android devices.
- 연결된 Android 디바이스 목록 조회
- 디바이스 속성 및 정보 확인
- 실시간 Logcat 스트리밍: WebSocket을 통한 실시간 로그 수집
- 최근 로그 조회: HTTP API를 통한 최근 로그 가져오기
- 로그 초기화: Logcat 버퍼 비우기
- Shell 명령 실행: 임의의 ADB shell 명령 실행
- 앱 설치/제거: APK 설치 및 패키지 제거
- 입력 제어:
- 텍스트 입력
- 화면 터치 (tap)
- 스와이프 동작
- 키 이벤트 전송
- 시스템 제어:
- 디바이스 재부팅
- 화면 정보 조회
- Kotlin: JVM 기반 현대적인 프로그래밍 언어
- Ktor: 경량 비동기 웹 프레임워크
- Adam: Android Debug Bridge (ADB) 클라이언트 라이브러리
- Kotlinx Coroutines: 비동기 프로그래밍 및 Flow API
- Kotlinx Serialization: JSON 직렬화/역직렬화
- JDK 17 이상
- Android Debug Bridge (ADB) 설치 및 실행 중
- 연결된 Android 디바이스 또는 에뮬레이터
- 기본적으로 서버는
0.0.0.0:8080에 바인딩되어 네트워크에서 접근 가능합니다 - 프로덕션 환경에서는 인증 메커니즘을 추가하거나 방화벽으로 보호해야 합니다
- 로컬 개발 전용으로 사용하려면 Application.kt에서
host = "127.0.0.1"로 변경하세요 - CORS는 localhost와 127.0.0.1로만 제한되어 있습니다
- By default, the server binds to
0.0.0.0:8080and is accessible from the network - For production use, add authentication mechanisms or protect with a firewall
- For local development only, change to
host = "127.0.0.1"in Application.kt - CORS is restricted to localhost and 127.0.0.1 only
./gradlew build./gradlew run서버는 기본적으로 http://0.0.0.0:8080에서 실행됩니다.
adb start-serverGET http://localhost:8080/devices응답 예시:
[
{
"serial": "emulator-5554",
"state": "DEVICE",
"model": null,
"product": null,
"device": null,
"transportId": null
}
]const ws = new WebSocket('ws://localhost:8080/logcat/emulator-5554');
ws.onmessage = (event) => {
console.log('Log:', event.data);
};GET http://localhost:8080/logcat/{serial}/recent?lines=100POST http://localhost:8080/logcat/{serial}/clearPOST http://localhost:8080/command/{serial}
Content-Type: application/json
{
"command": "pm list packages"
}응답 예시:
{
"success": true,
"output": "package:com.android.chrome\npackage:com.android.settings\n...",
"error": null
}POST http://localhost:8080/command/{serial}/input
Content-Type: application/x-www-form-urlencoded
text=Hello WorldPOST http://localhost:8080/command/{serial}/tap
Content-Type: application/x-www-form-urlencoded
x=500&y=1000POST http://localhost:8080/command/{serial}/swipe
Content-Type: application/x-www-form-urlencoded
x1=500&y1=1000&x2=500&y2=500&duration=300POST http://localhost:8080/command/{serial}/keyevent
Content-Type: application/x-www-form-urlencoded
keycode=4 # Back button일반적인 키코드:
- 3: HOME
- 4: BACK
- 26: POWER
- 82: MENU
GET http://localhost:8080/devices/{serial}/propertiesdroid_remote_test/
├── build.gradle.kts # Gradle 빌드 설정
├── settings.gradle.kts # Gradle 프로젝트 설정
├── gradle.properties # Gradle 속성
└── src/main/
├── kotlin/com/hundong2/droid/
│ ├── Application.kt # 메인 애플리케이션 및 Ktor 설정
│ ├── DeviceManager.kt # Adam을 사용한 디바이스 관리
│ ├── DeviceRoutes.kt # 디바이스 관련 API 엔드포인트
│ ├── LogcatRoutes.kt # Logcat 관련 API 엔드포인트
│ └── CommandRoutes.kt # 명령 실행 API 엔드포인트
└── resources/
└── logback.xml # 로깅 설정
- Group: com.hundong2.droid
- Version: 1.0.0
- Kotlin Version: 1.9.22
- Ktor Version: 2.3.7
- Adam Version: 0.5.4
이 프로젝트의 라이선스는 LICENSE 파일을 참조하세요.
이슈 제출 및 Pull Request는 언제든지 환영합니다!