title: Confused about application area of Android bundled tool "aidl-cpp"
body: <p>I am a novice in Android IPC (actually I used Unix domain sockets for communication long ago circa, 2014) and now it would seem that I need to learn AIDL/HIDL to understand the &quot;recommended&quot; IPC mechanisms.</p>
  <p>Now, coming to my doubt, I have a simple requirement (more like a pet project, an academic one, so to say) to teach myself how IPC works in Android 10 and up.</p>
  <p>I want to build a native service (c++) which will be started from say, adb shell. [SELinux and other security implications can be ruled out]</p>
  <p>Next, I want to Make a simple Java App which will have a Native library (via JNI).</p>
  <p>This native lib, when signaled from App, will spawn a new thread, which will then attempt to communicate with Native service and fetch some data to be displayed on the App.</p>
  <p>In a nutshell, the following is what I want to make to teach myself</p>
  <ul>
  <li>Android App dev</li>
  <li>Android JNI, Native interface</li>
  <li>POSIX threading in Android native code</li>
  <li>Android IPC [binder]</li>
  <li>Developing an Android native service as well.</li>
  </ul>
  <p>A rough sketch would be something like:</p>
  <p>App &lt;--&gt; JNI &lt;--&gt; Native lib &lt;--spawns-thread--&gt; Native Client &lt;--IPC--&gt; Native service</p>
  <p>The IPC would be via binder and for which I want to learn and understand the basics of AIDL.</p>
  <p>I have gone through the link: <a href="https://android.googlesource.com/platform/system/tools/aidl/+/refs/heads/android11-dev/docs/aidl-cpp.md" rel="nofollow noreferrer">https://android.googlesource.com/platform/system/tools/aidl/+/refs/heads/android11-dev/docs/aidl-cpp.md</a></p>
  <p>However I am confused in multiple areas such as:</p>
  <ol>
  <li><p>When to use &quot;aidl-cpp&quot; to generate the Bn/Bp interfaces? Can I simply allow soong build system to generate the required files?</p>
  </li>
  <li><p>If #1 is not necessary then how am I supposed to write the Native service code without Bn interface generated in first hand?</p>
  </li>
  <li><p>How can I tell &quot;aidl-cpp&quot; to compile multiple .aidl files?</p>
  </li>
  </ol>
  <p>I have also gone through another link: <a href="https://github.com/airgreen/nativeservice-app-aidl" rel="nofollow noreferrer">https://github.com/airgreen/nativeservice-app-aidl</a>
  It is very well written but does not exactly answer my questions</p>
  <p>Any help on the above topics would be very helpful.</p>
  <p>Thanks.</p>