File Descriptor Diagnostics

Inspect process-level Android file descriptor counts, limits, utilization, and open descriptor metadata through read-scoped remote tools.

The Android file-descriptor suite helps diagnose leaked files, sockets, pipes, and other process resources. It is included in the all-in-one ai.ansight:ansight-android package and can also be installed independently.

Published artifact: ai.ansight:ansight-tools-filedescriptordiagnostics-android.

Register the Suite

import ai.ansight.runtime.AnsightOptions
import ai.ansight.tools.filedescriptordiagnostics.withFileDescriptorDiagnosticsTools

val options = AnsightOptions.createBuilder()
    .withFileDescriptorDiagnosticsTools {
        includeTargets(false)
        maximumReturnedDescriptors(256)
    }
    .withReadOnlyToolAccess()
    .build()

includeTargets(false) suppresses resolved file paths and socket metadata. maximumReturnedDescriptors(...) limits how many matching records list_open returns; it does not change the open-descriptor count.

Tool Reference

ToolTool idScopeResultSecurity
List Open Descriptorsfile_descriptors.list_openReadFilterable descriptor records with kind, flags, position, inode, and optional target.High
Count Open Descriptorsfile_descriptors.count_openReadOnly { "count": number }; it does not resolve targets or collect descriptor details.Medium
Inspect Descriptorfile_descriptors.inspectReadOne descriptor record by non-negative descriptor number.High
Get Descriptor Usagefile_descriptors.get_usageReadOpen count, process limits, remaining capacity, and utilization.Medium

file_descriptors.list_open accepts:

  • kind: optional resource-kind filter
  • targetContains: optional case-insensitive target substring
  • maxEntries: maximum records to return after filtering

Snapshot results indicate whether collection was complete, the scanned descriptor limit, and the capture time.

Security

All four tools are read-scoped, but listing and inspection can disclose file paths and socket metadata. Prefer count and usage for routine leak detection, disable targets when paths are unnecessary, and keep the suite limited to controlled development or QA builds.