title: how to start android-TREBLE compatible vendor java service from /vendor/app
body: <p>In my Android-O device, below two background services communicating each other though AIDL.</p>
  
  <ol>
  <li><p>Native/c++ android service</p>
  
  <ul>
  <li>Starts through init rc</li>
  <li>Runs with system linux-user</li>
  <li>Deployed in /system partition, <code>eg, /system/bin/nat</code> binary.</li>
  </ul></li>
  <li><p>Java Service from apk</p>
  
  <ul>
  <li>Starts through bootcomplete receiver registered in AndroidManifest.</li>
  <li>Service class also specified in AndroidManifest and export:enabled is set.</li>
  <li>Runs system system linux user, signed with platform certficate.</li>
  <li>Deployed in system partition. <code>eg /system/app/jav/jav.apk</code></li>
  </ul></li>
  </ol>
  
  <p>So far no issues. Both above services are registered with <code>ServiceManager</code>. Both services were able to call each other through /dev/binder., Both start with Android boot and continue to run indefinitely.</p>
  
  <p><strong>Treble brings Trouble here:</strong></p>
  
  <p>As per Treble requirements, both above should be moved to /vendor partition with proper SEPolicies in place., so that, both java and c++ services can call each other through <code>/dev/vndbinder</code>., i.e by registering themselves with <code>VendorServiceManager</code>.</p>
  
  <p>Referring documentation, <a href="https://source.android.com/devices/architecture/hidl/binder-ipc" rel="noreferrer">https://source.android.com/devices/architecture/hidl/binder-ipc</a> i am able to start the native c++ service from <code>/vendor/bin/nat</code> which  registers with <code>VenorServiceManager(/dev/vndbinder)</code> successfully.</p>
  
  <p>Now I am able to call aidl interface functions through <code>vndservice call com.yyy.zzz.Myservice 0</code>
  But, failed to start JAVA vendor service deployed as <code>/vendor/app/jav/jav.apk.</code> </p>
  
  <p>Looks like always <code>ServiceManager</code> handles all 'service' entries in AndroidManifest, instead of <code>VendorServiceManager</code> even for /vendor parition apps.
  Can't i register with VendorServiceManager through AndroidManifest?
  If yes, is there any sample app/code that i can refer?</p>
  
  <p>Also,Android throws error saying background services cannot be started.
  Is there a way to have a background JAVA services from /vendor partition app, even if its started by system linux user and signed with platform certificate?</p>
  
  <p>I don't want to have 'Job scheduler' kind of deferred handlers, as the communication and responses expected to be in realtime and the service is expected to be running indefinitely from boot time.</p>
  
  <p>Please help with your suggestions.</p>