echo" 2. Check device connection: hdc list targets"
echo" 3. Manually launch app to verify it runs"
exit 1
fi
"$HDC_BIN"-t"$TARGET_ID" shell aa attach -b"$BUNDLE_NAME"
# Step 3: Start lldb-server and attach to process
echo" -> Starting lldb-server and attaching to process (PID: $APP_PID)..."
"$HDC_BIN"-t"$TARGET_ID" shell aa process -a"$ABILITY_NAME"-b"$BUNDLE_NAME"-D"/data/local/tmp/debugserver/lldb-server platform --listen unix-abstract:///lldb-server/platform.sock"
for /f "tokens=1" %%i in ('"%HDC_BIN%" -t %TARGET_ID% shell pidof %BUNDLE_NAME% 2^>nul') do set "APP_PID=%%i"
if not "%APP_PID%"=="" goto got_pid
timeout /t 1 /nobreak >nul
set /a COUNT+=1
if %COUNT% lss 25 goto wait_pid
echo Error: App did not start within expected time
exit /b 1
:got_pid
echo App started (PID: %APP_PID%)
"%HDC_BIN%" -t %TARGET_ID% shell aa attach -b %BUNDLE_NAME%
"%HDC_BIN%" -t %TARGET_ID% shell aa process -a %ABILITY_NAME% -b %BUNDLE_NAME% -D "/data/local/tmp/debugserver/lldb-server platform --listen unix-abstract:///lldb-server/platform.sock"