Summary
Add app management APIs to Xamarin.Android.Tools.AdbRunner so the MAUI DevTools CLI can install, uninstall, launch, and force-stop Android apps on devices/emulators without consumers shelling out to adb install / pm / am.
Context
AdbRunner already exposes ListDevicesAsync, WaitForDeviceAsync, StopEmulatorAsync, GetShellPropertyAsync, RunShellCommandAsync, and (via dotnet/android-tools#305) reverse-port management. The next gap is the app lifecycle, which both the VS Code MAUI extension's ServiceHub and the MAUI DevTools CLI currently implement independently. See maui-labs#197 for the full audit.
Proposed API
namespaceXamarin.Android.Tools;publicpartialclassAdbRunner{/// adb -s <serial> install [-r] [-g] <apk>publicvirtualTask<AdbAppInstallResult>InstallPackageAsync(stringserial,stringapkPath,boolreplaceExisting=true,boolgrantRuntimePermissions=false,CancellationTokencancellationToken=default);/// adb -s <serial> uninstall [-k] <package>publicvirtualTask<AdbAppOperationResult>UninstallPackageAsync(stringserial,stringpackageName,boolkeepData=false,CancellationTokencancellationToken=default);/// adb -s <serial> shell am start -n <package>/<activity>/// If activity is null, resolves the launcher activity via cmd package resolve-activity.publicvirtualTask<AdbAppOperationResult>LaunchAppAsync(stringserial,stringpackageName,string?activity=null,IReadOnlyDictionary<string,string>?extras=null,CancellationTokencancellationToken=default);/// adb -s <serial> shell am force-stop <package>publicvirtualTask<AdbAppOperationResult>ForceStopAsync(stringserial,stringpackageName,CancellationTokencancellationToken=default);/// adb -s <serial> shell pm list packages [-3] [-s] [filter]publicvirtualTask<IReadOnlyList<string>>ListPackagesAsync(stringserial,PackageFilterfilter=PackageFilter.All,string?namePattern=null,CancellationTokencancellationToken=default);}publicrecordAdbAppInstallResult(boolSuccess,string?PackageName,string?ErrorCode,// INSTALL_FAILED_VERSION_DOWNGRADE etc.stringStdout,stringStderr);publicrecordAdbAppOperationResult(boolSuccess,stringStdout,stringStderr);publicenumPackageFilter{All,ThirdParty,System,Disabled,Enabled}Notes:
InstallPackageAsync should parse the INSTALL_FAILED_* error codes that pm install returns and surface them in ErrorCode so callers can map to typed errors (the MAUI DevTools CLI maps these to E2xxx codes).LaunchAppAsync activity resolution: when activity == null, run cmd package resolve-activity --components <package> and use the name=... line.
Consumer
- MAUI DevTools CLI (dotnet/maui-labs) — new subcommands under
maui android device: install, uninstall, launch, stop, list. See maui-labs#197 audit (these replace raw adb install / am start / am force-stop fallbacks in the DevFlow skills). - VS Code MAUI extension ServiceHub → CLI migration. Today
MauiAndroidPlatform.ts calls AndroidDeviceManager.installApp() / launchApp() / forceStopApp(). - DevFlow integration tests that boot an emulator, install the sample APK, launch, and tear down.
Related
Summary
Add app management APIs to
Xamarin.Android.Tools.AdbRunnerso the MAUI DevTools CLI can install, uninstall, launch, and force-stop Android apps on devices/emulators without consumers shelling out toadb install/pm/am.Context
AdbRunneralready exposesListDevicesAsync,WaitForDeviceAsync,StopEmulatorAsync,GetShellPropertyAsync,RunShellCommandAsync, and (via dotnet/android-tools#305) reverse-port management. The next gap is the app lifecycle, which both the VS Code MAUI extension's ServiceHub and the MAUI DevTools CLI currently implement independently. See maui-labs#197 for the full audit.Proposed API
Notes:
InstallPackageAsyncshould parse theINSTALL_FAILED_*error codes thatpm installreturns and surface them inErrorCodeso callers can map to typed errors (the MAUI DevTools CLI maps these toE2xxxcodes).LaunchAppAsyncactivity resolution: whenactivity == null, runcmd package resolve-activity --components <package>and use thename=...line.Consumer
maui android device:install,uninstall,launch,stop,list. See maui-labs#197 audit (these replace rawadb install/am start/am force-stopfallbacks in the DevFlow skills).MauiAndroidPlatform.tscallsAndroidDeviceManager.installApp()/launchApp()/forceStopApp().Related
AdbRunner)