2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
바인더 개요
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
바인더는 Android 기반 기기에서 두 프로세스가 통신할 수 있도록 하는 프로세스 간 통신 시스템입니다. 바인더는 호출자에게 완전히 투명한 다른 프로세스에서 함수 호출을 실행하는 수단을 제공합니다.
바인더 용어로 호출 프로세스는 클라이언트로 간주되고 엔드포인트는 바인더 프록시 또는 프록시라고 합니다. 반대로 호출되는 프로세스는 서버이고 엔드포인트는 바인더 노드 또는 노드라고 합니다.
각 노드는 자체 인터페이스를 노출하고 구현할 수 있습니다. 또한 프록시를 사용하여 클라이언트는 호출이 로컬 함수 호출인 것처럼 노드 인터페이스에서 메서드를 실행할 수 있습니다. 다음 예에서는 메서드가 호출되는 것을 보여줍니다.
int result = someNodeInterface.foo(a, b); // someNodeInterface is a proxy object
foo()
를 호출하는 클라이언트는 프로세스 A에서 실행되고 foo()
를 구현하는 서버는 프로세스 B에서 실행된다고 가정합니다. 그림 1은 이 호출이 실행되는 방식을 보여줍니다.
그림 1. 바인더 호출 실행
그림 1과 같이 다른 프로세스에서 메서드를 실행하려면 다음이 발생합니다.
- 프로세스 A의 클라이언트 코드가 프로세스 A의 프록시 코드를 호출합니다. 프로세스 A의 프록시 코드는 다음 항목을 포함하는 트랜잭션을 만듭니다.
- 노드의 식별자
- 노드의
foo()
메서드 식별자
a
및 b
인수의 복사본이 포함된 버퍼
- 트랜잭션이 바인더 커널 드라이버에 제출됩니다.
- 바인더 커널 드라이버는 프로세스 B가 노드를 호스팅한다고 판단합니다.
- 커널은 전체 트랜잭션을 프로세스 B의 주소 공간에 복사합니다.
- 커널은 트랜잭션을 처리할 프로세스 B의 스레드를 찾아 트랜잭션을 전달합니다.
- 스레드는 트랜잭션을 압축 해제하고 노드를 찾아 노드 객체에 트랜잭션을 전송합니다.
- 노드 객체는 트랜잭션에서 함수 식별자를 가져오고, 트랜잭션 버퍼에서
a
및 b
를 압축 해제하고, a
및 b
를 로컬 변수에 저장합니다.
- 노드 객체는 프로세스 B의 서버 코드에서
foo(a, b)
를 호출합니다.
- 호출 결과는 응답 트랜잭션으로 반환되며, 이 트랜잭션은 커널 드라이버로 전달된 후 프로세스 A의 호출 프록시로 다시 전달됩니다.
- 프록시는 프로세스 A의 호출자에게 결과를 반환합니다.
바인더 사용 사례
바인더는 서로 다른 프로세스의 소프트웨어 간에 통신이 발생해야 하는 다양한 시나리오에서 사용할 수 있습니다. 예를 들면 다음과 같습니다.
카메라 앱은 바인더를 사용하여 다른 프로세스의 카메라 서버와 통신합니다. 그러면 카메라 서버는 바인더를 사용하여 다른 프로세스의 카메라 HAL과 통신합니다.
앱은 바인더를 사용하여 다른 프로세스의 시스템 서버와 통신합니다. 시스템 서버는 바인더를 사용하여 다른 프로세스의 HAL과 통신합니다.
한 프로세스의 앱이 바인더를 사용하여 다른 프로세스의 다른 앱과 통신합니다.
앱을 설치, 업데이트, 삭제하는 시스템 데몬 (installd
)은 바인더를 사용하여 Android 런타임 데몬 ('artd')과 통신하여 앱을 컴파일합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-11(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-11(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."]]