Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release, bukan aosp-main, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Binder adalah sistem untuk komunikasi antarproses yang memungkinkan dua proses di perangkat berdaya Android berkomunikasi. Binder menyediakan cara untuk mengeksekusi panggilan fungsi dalam proses lain yang sepenuhnya transparan bagi pemanggil.
Dalam istilah binder, proses panggilan dianggap sebagai klien dan
endpoint-nya disebut proxy binder atau proxy. Sebaliknya,
proses yang dipanggil adalah server dan endpointnya disebut
node binder atau node.
Setiap node dapat mengekspos dan mengimplementasikan antarmukanya sendiri. Selain itu, dengan menggunakan proxy, klien dapat mengeksekusi metode pada antarmuka node seolah-olah pemanggilan adalah panggilan fungsi lokal. Contoh berikut menunjukkan metode yang dipanggil:
int result = someNodeInterface.foo(a, b); // someNodeInterface is a proxy object
Asumsikan bahwa klien yang memanggil foo() berjalan dalam proses A dan server yang menerapkan foo() berjalan dalam proses B. Gambar 1 menunjukkan cara panggilan ini
dieksekusi:
Gambar 1. Eksekusi panggilan Binder.
Untuk mengeksekusi metode dalam proses lain, seperti yang ditunjukkan pada gambar 1,
hal berikut akan terjadi:
Kode klien dalam proses A memanggil kode proxy dalam proses A. Kode
proxy dalam proses A membuat transaksi yang berisi item berikut:
ID untuk node
ID untuk metode foo() pada node
Buffer yang berisi salinan argumen a dan b
Transaksi dikirimkan ke driver kernel binder.
Driver kernel binder menentukan bahwa proses B menghosting node.
Kernel menyalin seluruh transaksi ke ruang alamat proses B.
Kernel menemukan thread dalam proses B untuk menangani transaksi dan meneruskan
transaksi tersebut ke thread.
Thread membongkar transaksi, menemukan node, dan mengirim transaksi ke objek node.
Objek node mendapatkan ID fungsi dari transaksi, mengekstrak a dan b dari buffer transaksi, serta menyimpan a dan b dalam variabel lokal.
Objek node memanggil foo(a, b) pada kode server dalam proses B.
Hasil panggilan ditampilkan dalam transaksi balasan, yang diteruskan
ke driver kernel, lalu kembali ke proxy panggilan dalam proses A.
Proxy menampilkan hasil tersebut ke pemanggil dalam proses A.
Kasus penggunaan Binder
Binder dapat digunakan dalam berbagai skenario saat komunikasi antara software dalam proses yang berbeda harus terjadi. Contoh:
Aplikasi kamera menggunakan binder untuk berkomunikasi dengan server kamera dalam
proses lain. Server kamera kemudian menggunakan binder untuk berkomunikasi dengan
HAL kamera dalam proses lain.
Aplikasi menggunakan binder untuk berkomunikasi dengan server sistem dalam proses lain. Server
sistem menggunakan binder untuk berkomunikasi dengan HAL dalam proses lain.
Aplikasi dalam satu proses menggunakan binder untuk berkomunikasi dengan aplikasi lain dalam proses yang berbeda.
Daemon sistem yang bertanggung jawab untuk menginstal, mengupdate, dan menghapus
aplikasi (installd) menggunakan binder untuk berkomunikasi dengan daemon runtime Android ('artd') untuk mengompilasi aplikasi.
AIDL dan binder
Gunakan Android Interface Design Language (AIDL) untuk menentukan antarmuka pemrograman yang menggunakan binder untuk IPC. Untuk mengetahui informasi lebih lanjut, lihat
ringkasan AIDL.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-05 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-05 UTC."],[],[],null,["# Binder overview\n\n*Binder* is a system for interprocess\ncommunication that lets two processes on an Android-powered device\ncommunicate. Binder provides a means to execute function calls in another\nprocess that is completely transparent to the caller.\n\nIn binder terms, the calling process is considered the *client* and its\nendpoint is called the *binder proxy* or *proxy* . Conversely,\nthe process being called is the *server* and its endpoint is called the\n*binder node* or *node*.\n\nEach node can expose and implement its own interface. And, using a proxy, the\nclient can execute methods on a node interface as though invocation was a\nlocal function call. The following example shows a method being invoked: \n\n int result = someNodeInterface.foo(a, b); // someNodeInterface is a proxy object\n\nAssume that the client calling `foo()` is running in process A and the server\nimplementing `foo()` is running in process B. Figure 1 shows how this call is\nexecuted:\n\n**Figure 1.** Binder call execution.\n\nTo execute a method in another process, as shown in figure 1,\nthe following occurs:\n\n1. The client code in process A invokes the proxy code in process A. The proxy code in process A creates a transaction containing the following items:\n - An identifier for the node\n - An identifier for the `foo()` method on the node\n - A buffer containing a copy of the arguments `a` and `b`\n2. The transaction is submitted to the binder kernel driver.\n3. The binder kernel driver determines that process B hosts the node.\n4. The kernel copies the entire transaction into process B's address space.\n5. The kernel finds a thread in process B to handle the transaction and passes the transaction to it.\n6. The thread unpacks the transaction, finds the node, and sends the transaction to the node object.\n7. The node object obtains the function identifier from the transaction, unpacks `a` and `b` from the transaction buffer, and stores `a` and `b` in local variables.\n8. The node object calls `foo(a, b)` on the server code in process B.\n9. The result of the call is returned in a reply transaction, which is passed to the kernel driver and then back to the calling proxy in process A.\n10. The proxy returns that result to the caller in process A.\n\nBinder use cases\n----------------\n\nBinder can be used in a variety of scenarios where communication between\nsoftware in different processes must occur. For example:\n\n- A camera app uses binder to communicate with the camera server in\n another process. The camera server then uses binder to communicate with the\n camera HAL in another process.\n\n- An app uses binder to communicate with a system server in another process. The\n system server uses binder to talk to HALs in other processes.\n\n- An app in one process uses binder to communicate with a different app in\n another process.\n\n- The system daemon responsible for installing, updating, and removing\n apps (`installd`) uses binder to communicate with the Android\n runtime daemon ('artd') to compile apps.\n\nAIDL and binder\n---------------\n\nUse the Android Interface Design Language (AIDL) to define programming\ninterfaces that use binder for IPC. For further information, see the\n[AIDL overview](/docs/core/architecture/aidl).\n| **Note:** HIDL is deprecated; only AIDL is recommended for new implementations."]]