title: One-time permissions causing background scheduled jobs and alarms to be cancelled
body: <p>We develop an Android SDK and, while testing the Android 11 Beta, we found a problem that does not seem to be reported yet.</p>
  <p>In Android 11, new one-time permissions have been introduced for Location, Microphone and Camera permissions. With this option, as soon as the user leaves the application, the permission is revoked (more details can be found <a href="https://developer.android.com/preview/privacy/permissions#one-time" rel="noreferrer">here</a>).</p>
  <p>The problem is that after a short amount of time when the app is no longer in the foreground (it is not necessary to kill the app, just minimizing is enough), all future scheduled alarms or jobs are removed, as if the app was force killed.
  This only happens with this level of permission.
  Denying or providing other levels keep the previously scheduled alarms or jobs, as expected.
  We have reproduced this in the Beta 3 build, in a Pixel 2 emulator with the RPB3.200720.005 build number. In this <a href="https://github.com/larissanpa/permissions-app" rel="noreferrer">repo</a> you can find a sample app for reproducing the bug.</p>
  <p>This single activity app schedules an alarm to ring in the next five minutes, as well as a job to trigger in between 5-6 minutes.
  The screen has three buttons, each triggering the corresponding permission request.
  The JobService and BroadcastReceiver classes only log that they have been triggered.
  The situation can be reproduced after the following steps:</p>
  <ol>
  <li>Whenever the app is started, it is possible to run both <code>adb shell dumpsys alarm | grep com.example.permissions.app</code> and <code>adb shell dumpsys jobscheduler | grep com.example.permissions.app</code> to see that both the alarm and the job are scheduled;</li>
  <li>Click in any of the buttons and grant the one-time permission level;</li>
  <li>Minimize the app (you can go to the home screen or open other app);</li>
  <li>After around a minute, run both <code>adb shell dumpsys alarm | grep com.example.permissions.app</code> and <code>adb shell dumpsys jobscheduler | grep com.example.permissions.app</code>. The alarm and job will no longer appear;</li>
  <li>Waiting the original scheduled times for both job and alarm (with lenience for system delays) will show that they won't be triggered.</li>
  </ol>
  <p>Have any of you encountered a similar situation? Our hunch is that to revoke the one-time permissions, the app process is being killed in some way that is causing these side effects.
  We also submitted an issue on <a href="https://issuetracker.google.com/issues/165787618" rel="noreferrer">Android Issue Tracker</a>, and we will keep this post updated if Google answers it.</p>