Documentation
¶
Index ¶
- Variables
- func DetectAPILevel() int
- type APIRevisions
- type MultiVersionTable
- type Option
- type Options
- type Revision
- type Transport
- func (t *Transport) AcquireHandle(ctx context.Context, handle uint32) error
- func (t *Transport) ClearDeathNotification(ctx context.Context, handle uint32, recipient binder.DeathRecipient) error
- func (t *Transport) Close(ctx context.Context) error
- func (t *Transport) MergeTable(extra VersionTable)
- func (t *Transport) RegisterReceiver(ctx context.Context, receiver binder.TransactionReceiver) uintptr
- func (t *Transport) ReleaseHandle(ctx context.Context, handle uint32) error
- func (t *Transport) RequestDeathNotification(ctx context.Context, handle uint32, recipient binder.DeathRecipient) error
- func (t *Transport) ResolveCode(ctx context.Context, descriptor string, method string) (binder.TransactionCode, error)
- func (t *Transport) Transact(ctx context.Context, handle uint32, code binder.TransactionCode, ...) (*parcel.Parcel, error)
- type VersionTable
Constants ¶
This section is empty.
Variables ¶
var DefaultAPILevel int
DefaultAPILevel is the API level that the compiled proxy code was generated against. Set by generated code (codes_gen.go).
var Revisions = APIRevisions{}
Revisions maps API level -> list of version IDs (latest first). Populated by generated code (codes_gen.go).
var Tables = MultiVersionTable{}
Tables holds multi-version transaction code tables. Populated by generated code (codes_gen.go).
Functions ¶
func DetectAPILevel ¶
func DetectAPILevel() int
DetectAPILevel returns the Android API level of the running device. Reads /etc/build_flags.json (no fork, no binder dependency). Returns 0 if detection fails.
Types ¶
type APIRevisions ¶
APIRevisions maps API level -> list of Revisions (for probing order). Within an API level, later revisions are listed first (more likely match).
type MultiVersionTable ¶
type MultiVersionTable map[Revision]VersionTable
MultiVersionTable maps Revision -> VersionTable. Revisions are like "34.r1", "35.r1", "36.r1", "36.r3", "36.r4".
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a version-aware Transport.
func OptionCachePath ¶
OptionCachePath sets the file path for caching the resolved transaction code table. The cache includes a fingerprint so it is automatically invalidated when the OS is updated.
Default: /tmp/.binder_cache/codes.gob Pass empty string to disable caching.
type Transport ¶
type Transport struct {
// Revision is the detected AOSP firmware revision (e.g. "36.r4").
// Set during NewTransport when libbinder.so symbol inspection
// narrows the candidates to exactly one. Empty if ambiguous.
Revision Revision
// ScannedJARs tracks which framework JARs have been fully scanned
// for $Stub classes. Keyed by JAR filename (e.g. "framework.jar").
// Persisted in the cache to avoid re-scanning across runs.
ScannedJARs map[string]bool
// contains filtered or unexported fields
}
Transport wraps a binder.Transport and adds version-aware transaction code resolution via ResolveCode.
All version detection (API level + revision probing) happens eagerly in NewTransport. If the device version cannot be determined or is unsupported, NewTransport returns an error.
func NewTransport ¶
func NewTransport( ctx context.Context, inner binder.Transport, targetAPI int, opts ...Option, ) (*Transport, error)
NewTransport creates a version-aware Transport wrapping inner.
targetAPI is the Android API level (e.g., 36). If 0, auto-detects from /etc/build_flags.json.
Returns an error if:
- the API level cannot be detected (targetAPI==0 and detection fails)
- the API level has no compiled version tables
- revision probing fails (when multiple revisions exist)
If multiple AOSP revisions exist for the API level, NewTransport probes the device via binder transactions to determine which revision matches. This requires the binder driver to be open.
func (*Transport) AcquireHandle ¶
func (*Transport) ClearDeathNotification ¶
func (*Transport) MergeTable ¶
func (t *Transport) MergeTable( extra VersionTable, )
MergeTable adds entries from extra into the transport's version table. Existing entries are not overwritten. This is useful for registering stable AIDL HAL interfaces whose transaction codes are not extracted from framework JARs.
func (*Transport) RegisterReceiver ¶
func (*Transport) ReleaseHandle ¶
func (*Transport) RequestDeathNotification ¶
func (*Transport) ResolveCode ¶
func (t *Transport) ResolveCode( ctx context.Context, descriptor string, method string, ) (binder.TransactionCode, error)
ResolveCode resolves an AIDL method name to the correct transaction code for the detected device version.
If the descriptor is not in the pre-loaded table, ResolveCode attempts on-demand extraction from the device's framework JARs. This handles cases where the cache is stale or a new interface is needed that wasn't in the initial extraction.
Returns an error if the method is not found in the version table (e.g., calling a method that does not exist on the device's API level).
type VersionTable ¶
type VersionTable map[string]map[string]binder.TransactionCode
VersionTable maps descriptor -> methodName -> transaction code.
func (VersionTable) Resolve ¶
func (t VersionTable) Resolve( descriptor string, method string, ) binder.TransactionCode
Resolve looks up the transaction code for a method. Returns 0 if not found.