Skip to content

Implement installed-package listing through ADB #32

Description

@SamratB8

Summary

Add an ADB service for retrieving the list of installed Android application packages from a selected device or emulator.

The first version should run the appropriate package-manager command, parse package identifiers, and return a structured result.

This issue covers the service and parsing layer only. Displaying packages in WinUI should be handled separately.

Background

Listing installed packages is the first step toward application management in WinDroid Studio.

Future features such as launching applications, uninstalling packages, clearing application data, and displaying app details will depend on a reliable package-listing service.

Dependencies

This issue depends on:

A target device serial number must be supplied explicitly.

ADB Command

The basic command is:

adb -s <device-serial> shell pm list packages

The implementation must pass arguments safely and must not construct an unescaped shell command string.

Proposed Service API

Task<AdbPackageListResult> GetInstalledPackagesAsync(
    string deviceSerial,
    CancellationToken cancellationToken = default);

Possible result information:

Success
Packages
ExitCode
StandardOutput
StandardError
ErrorMessage

Parsing Requirements

Typical output:

package:com.android.settings
package:com.example.application
package:org.fdroid.fdroid

The parser should:

  • Remove the package: prefix
  • Ignore empty lines
  • Trim surrounding whitespace
  • Return package identifiers as structured values
  • Avoid returning duplicate package identifiers where practical
  • Preserve deterministic ordering
  • Ignore or safely handle unexpected lines
  • Avoid throwing for malformed output

Validation Requirements

Before running the command:

  • Device serial must not be null
  • Device serial must not be empty
  • Device serial must not contain unsupported control characters
  • ADB path must be available
  • Normal invalid input should return a structured failure

The process runner should receive the device serial as an argument, not as part of a manually quoted command string.

Tasks

  • Create an installed-package model if required
  • Create a package-list result model
  • Add a package-list service method
  • Run the command against an explicitly selected device
  • Parse package output
  • Return structured success and failure results
  • Add cancellation support
  • Add parser unit tests
  • Add command-construction tests where practical
  • Document the service behavior

Required Tests

Add tests for:

  • One package
  • Multiple packages
  • Empty output
  • Blank lines
  • Duplicate package lines
  • Whitespace around values
  • Unexpected output lines
  • Non-zero command exit code
  • Empty device serial
  • Cancellation
  • Package identifiers containing dots and underscores

Tests for parsing should not require a physical Android device.

Out of Scope

This issue does not need to:

  • Display packages in WinUI
  • Resolve human-readable app names
  • Retrieve icons
  • Retrieve version numbers
  • Retrieve package sizes
  • Launch packages
  • Uninstall packages
  • Clear package data
  • Distinguish system apps from user apps
  • Use Google Play metadata

Acceptance Criteria

  • The service can request installed packages from a selected device.
  • The command includes an explicit target-device serial.
  • Package output is converted into structured package identifiers.
  • Empty output returns an empty collection.
  • Unexpected lines do not crash the parser.
  • Invalid device serial input produces a structured failure.
  • Standard output, standard error, and exit code are available.
  • Cancellation is handled safely.
  • Parser tests do not require local ADB.
  • The implementation remains outside the WinUI project.
  • The full solution builds successfully in Debug and Release configurations.
  • No new compiler warnings are introduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adbWork involving Android Debug Bridge integration, device communication, commands, and diagnostics.apk managementInstalled app listing, launching, uninstalling, and Android package workflows.enhancementNew feature or requesthelp wantedExtra attention is neededphase-2Work planned for the second development phase after the initial foundation is complete.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions