echo-e" If device screen is locked, please unlock it manually"
echo""
echo-e"\033[36mSuggested actions:\033[0m"
echo" 1. Ensure device screen is unlocked"
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"
echo-e"\n\033[31mFailed: App did not start within expected time!\033[0m"
exit 1
fi
"$HDC_BIN"-t"$TARGET_ID" shell aa attach -b"$BUNDLE_NAME"
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
:wait_pid_dbg
set "APP_PID="
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_dbg
timeout /t 1 /nobreak >nul
set /a COUNT+=1
if %COUNT% lss 25 goto wait_pid
if !COUNT! lss 25 goto wait_pid_dbg
echo Error: App did not start within expected time
exit /b 1
:got_pid
:got_pid_dbg
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"
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"