title: How to include prebuilt APK into AOSP with platform privileges
body: <p>I'm building a version of the AOSP for custom hardware and I'd like to use some root permissions (INJECT_EVENTS, UPDATE_DEVICE_STATS, CONNECTIVITY_INTERNAL).</p>
  
  <p>For rev control, it would be ideal to use an APK-based distribution. As such, I'd like to include the APK in the build instead of building the source every time. The program gets successfully included, but the system privileges are ignored.</p>
  
  <p>Is there a way to include this program such that it receives the necessary privileges? I'm hoping there is some connection that either LOCAL_CERTIFICATE, LOCAL_MODULE_CLASS or BUILD_PREBUILT in Android.mk can achieve.</p>
  
  <p>EDIT:
  The solution was to first determine the signatures that were being used to build the Android system. They existed in /build/target/product/security/platform inside the AOSP. Once I had these signatures, I could then create a new keystore. I then imported the keys into the new keystore using the tool keytool-importkeypair found here.</p>
  
  <p><a href="https://github.com/getfatday/keytool-importkeypair" rel="nofollow">https://github.com/getfatday/keytool-importkeypair</a></p>
  
  <p>Once that was done, I could select the keystore inside Android Studio and correctly install and debug the program that had the necessary permissions.</p>