Device Info ContentProvider

Expose device information via ADB using a ContentProvider, allowing external tools to retrieve data without network requests.

Feature Overview

We have implemented a ContentProvider in the Pulse MDM Service to expose device information via ADB. This allows external tools (via ADB) to retrieve the same rich device data that is available through the local HTTP /infos endpoint, without needing to make a network request.

Technical Details

  • Component: DeviceInfosContentProvider

  • Authority: com.pulse.mdm.service.device

  • Path: /infos

  • Output Format: JSON

Key Files & Changes

1. AndroidManifest.xml

Registered the provider with the authority com.pulse.mdm.service.device.

<provider
    android:name=".provider.DeviceInfosContentProvider"
    android:authorities="${applicationId}.device"
    android:exported="true" />

2. DeviceInfosContentProvider.kt

Handles the incoming ADB requests. Supports two modes:

  • query(): Standard cursor return (legacy support).

  • openFile(): Returns a raw file descriptor pipe for streaming JSON directly (easier parsing).

Logic:

  • Checks if the URI path suffix is infos.

  • Retrieves device data using DeviceHelper.getDeviceResponse(context, androidId).

  • Serializes data to JSON using Gson.

3. DeviceHelper.kt

Contains the reused logic getDeviceResponse to aggregate data from various sources (Battery, Storage, Volume, Installed Apps, etc.).

4. DeviceResponseModel.kt

Shared data models (DeviceResponse, Model, Settings, Contents) used by both the ContentProvider and the HTTP Server.

Usage Commands

Standard Query (Debug)

Returns a cursor row.

Raw Stream (Scripts/Parsing)

Returns only the JSON string.

Mis à jour