HDC screenshots reuse and leak the remote temp file

Author: XalzerophCreated Sep 23, 2026Updated Sep 23, 2026

phone_agent/hdc/screenshot.py always writes captures to /data/local/tmp/tmp_screenshot.jpeg.

That creates two problems:

  • overlapping screenshot calls on the same device can overwrite each other's remote file before hdc file recv completes;
  • the remote file is never removed, and the local temp file is only deleted on the success path.

A screenshot capture should use a unique remote path per call and clean both remote and local temporary files on every exit path. Remote cleanup should be best-effort so a cleanup failure does not replace the original screenshot result.