title: Intent permissions and JobIntentService
body: <p>I've got an app A that sends an intent to app B. App A has a file provider and share a file to B. It add the grants to the intent and it starts a service on B. B has an IntentService and process the intent. Now I want to change B to use a JobIntentService  according to the new Android O policy. However I can't call startService from A, so I modified my code to send an explicit broadcast instead. I added the uri in the clipdata. However when I receive the intent on app B, I've got a security exception.</p>
  
  <p>App A:</p>
  
  <pre><code>Uri contentUri = FileProvider.getUriForFile(this, "com.myotherapp.fileprovider",
                              newFile);
  Intent i = new Intent(INTENT_UPDATE);
  ClipData clipData = ClipData.newRawUri(at.name(), contentUri);
  i.setClipData(clipData);
  i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
  i.setPackage("com.myapp");
  sendBroadcast(i);
  </code></pre>
  
  <p>App B:</p>
  
  <pre><code>@Override
  public void onReceive(Context arg0, Intent arg1) {
      if (MyService.INTENT_UPDATE.equals(arg1.getAction())) {
          MyService.enqueueWork(arg0, arg1);
      }
  }
  </code></pre>
  
  <p>Stack:</p>
  
  <pre><code>Process: com.myapp, PID: 7690
  java.lang.RuntimeException: Unable to start receiver com.myapp.MyReceiver: java.lang.SecurityException: UID 10083 does not have permission to content://com.myotherapp.fileprovider/files/Q3hnMrF8BsOJeznpVLizkTB4H6LkI90T.csv [user 0]
      at android.app.ActivityThread.handleReceiver(ActivityThread.java:3259)
      at android.app.ActivityThread.-wrap17(Unknown Source:0)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
      at android.os.Handler.dispatchMessage(Handler.java:105)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6540)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
  Caused by: java.lang.SecurityException: UID 10083 does not have permission to content://com.myotherapp.fileprovider/files/Q3hnMrF8BsOJeznpVLizkTB4H6LkI90T.csv [user 0]
      at android.os.Parcel.readException(Parcel.java:1948)
      at android.os.Parcel.readException(Parcel.java:1894)
      at android.app.job.IJobScheduler$Stub$Proxy.enqueue(IJobScheduler.java:211)
      at android.app.JobSchedulerImpl.enqueue(JobSchedulerImpl.java:53)
      at android.support.v4.app.JobIntentService$JobWorkEnqueuer.enqueueWork(JobIntentService.java:314)
      at android.support.v4.app.JobIntentService.enqueueWork(JobIntentService.java:472)
      at com.myapp.MyService.enqueueWork(MyService.java:41)
      at com.myapp.myrec.onReceive(UpdateReceiver.java:21)
      at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
      at android.app.ActivityThread.-wrap17(Unknown Source:0) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677) 
      at android.os.Handler.dispatchMessage(Handler.java:105) 
      at android.os.Looper.loop(Looper.java:164) 
      at android.app.ActivityThread.main(ActivityThread.java:6540) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
  </code></pre>
  
  <p><strong>Edit:</strong> I tried using a JobService using setClipData on a JobInfo. It doesn't work at all anyway.</p>