title: How to get system app permission on Android 9.0
body: <p><strong>I want to grant my application with system permission "INJECT_EVENTS" on Android 9.0 device, but I can't.</strong></p>
  
  <ul>
  <li>device is rooted </li>
  <li>apk is signed with certs from AOSP repository </li>
  <li>apk is installed in /system/app/ by copying apk there and rebooting</li>
  <li>manifest of apk contains:</li>
  </ul>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INJECT_EVENTS"
                       android:protectionLevel="signature"
                       tools:ignore="ProtectedPermissions" /&gt;
  </code></pre>
  
  <p>Also I've read <a href="https://source.android.com/devices/tech/config/perms-whitelist" rel="nofollow noreferrer">https://source.android.com/devices/tech/config/perms-whitelist</a> article and moved apk to /system/priv-app, and then tried to whitelist my apk with inject_events permission in next places:</p>
  
  <p><em>First try:</em></p>
  
  <ul>
  <li>apk: /system/priv-app</li>
  <li>edited: /system/etc/permissions/priv-app.com.my.apk.xml
  (no reboot)</li>
  </ul>
  
  <p><em>Second try:</em></p>
  
  <ul>
  <li>apk: /system/priv-app</li>
  <li>edited: /etc/permissions/priv-app.com.my.apk.xml
   /etc/permissions/privapp-permissions-platform.xml 
  (reboot and still no profit)</li>
  </ul>
  
  <p><strong>This is how my whitelist edits look like in both files:</strong></p>
  
  <pre><code>    &lt;privapp-permissions package="com.my.apk"&gt;
         &lt;permission name="android.permission.INJECT_EVENTS"/&gt;
      &lt;/privapp-permissions&gt;
     &lt;/permissions&gt;
  </code></pre>
  
  <p>*I tried to debug this by grep'ing logcat with "PackageManager", but nothing useful. Also <code>adb shell dumpsys package myapk | grep permission</code> shows that <code>permission.INJECT_EVENTS</code> is not granted. </p>
  
  <p><strong>important: apk is granted  <code>inject_events</code> while running on android 8.1. No whitelisting was used.</strong></p>
  
  <p>After everything done It was expected that <code>inject_events</code> will be granted, but no. </p>