Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Use linkToDeath for PackageManager resilience#29

Merged
beakthoven merged 1 commit into
beakthoven:mainfrom
JingMatrix:main
Aug 29, 2025
Merged

Use linkToDeath for PackageManager resilience#29
beakthoven merged 1 commit into
beakthoven:mainfrom
JingMatrix:main

Conversation

@JingMatrix
Copy link
Copy Markdown
Contributor

The previous implementation used pingBinder() to check the liveness of the PackageManager service on every call to getPm(). This polling approach introduces an unnecessary IPC round-trip overhead for every access.

This commit refactors the logic to use the canonical, event-driven pattern for handling remote service death by implementing linkToDeath.

A DeathRecipient is now registered with the binder upon the first connection. If the service process (system_server) dies for any reason, the binderDied() callback is automatically invoked by the system. This callback proactively clears the cached service instance, ensuring that the next call to getPm() will transparently re-establish a valid connection.

The previous implementation used `pingBinder()` to check the liveness of the PackageManager service on every call to `getPm()`. This polling approach introduces an unnecessary IPC round-trip overhead for every access.

This commit refactors the logic to use the canonical, event-driven pattern for handling remote service death by implementing `linkToDeath`.

A `DeathRecipient` is now registered with the binder upon the first connection. If the service process (`system_server`) dies for any reason, the `binderDied()` callback is automatically invoked by the system. This callback proactively clears the cached service instance, ensuring that the next call to `getPm()` will transparently re-establish a valid connection.
@beakthoven beakthoven merged commit b13663e into beakthoven:main Aug 29, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants