Creating ashmem using the binder

In this lab, you’ll create a service to allocate and manage shared memory (ashmem)

  1. Create an empty android application with C++ support – the service application
  2. Add an android library module
    1. Create a new aidl file – IShmService
    2. Declare an interface with the following functions:

Service Application

Implement the above interface using native code. To create an ashmem object use the following IOCTLs (taken from the kernel code)

you can include the file from the kernel (~/kernel3.4/goldfish)

In the service implementation java code create and return ParcelFileDescriptor (using the file descriptor number returning from the native library)

Client Application 

Add a client application:

  1. Bind to the service
  2. Use the service to create and memory region
  3. Use native code to mmap the region and test your work