title: MediaProjection service type not recognized in android Q
body: <p>With the new privacy changes in effect with Android Q, it is now mandatory for any app using <code>MediaProjection</code> api to specify <a href="https://developer.android.com/reference/android/R.attr.html#foregroundServiceType" rel="noreferrer">android:foregroundServiceType</a> attribute in the service tag under manifest.</p>
  
  <p>But recently, I noticed that though I set the <code>android:foregroundServiceType="mediaprojection"</code> there is a security exception thrown. Does anybody have any idea what I'm doing wrong?</p>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;service
              android:name=".services.MediaProjectionService"
              android:enabled="true"
              android:exported="false"
              android:foregroundServiceType="mediaProjection" /&gt;
  </code></pre>
  
  <p>Exception thrown:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start service com.package.app.services.MediaProjectionService@6d0fed2 with Intent { act=com.package.app.services.action.startrecording cmp=com.package.app/.services.MediaProjectionService(has extras) }: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
          at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4103)
          at android.app.ActivityThread.access$1800(ActivityThread.java:219)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
          at android.os.Handler.dispatchMessage(Handler.java:107)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7343)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)
       Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
          at android.os.Parcel.createException(Parcel.java:2071)
          at android.os.Parcel.readException(Parcel.java:2039)
          at android.os.Parcel.readException(Parcel.java:1987)
          at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
          at android.media.projection.MediaProjection.&lt;init&gt;(MediaProjection.java:58)
          at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104)
          at com.package.app.services.MediaProjectionService.startRecording(MediaProjectionService.java:190)
          at com.package.app.services.MediaProjectionService.onStartCommand(MediaProjectionService.java:142)
          at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4085)
          at android.app.ActivityThread.access$1800(ActivityThread.java:219) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891) 
          at android.os.Handler.dispatchMessage(Handler.java:107) 
          at android.os.Looper.loop(Looper.java:214) 
          at android.app.ActivityThread.main(ActivityThread.java:7343) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933) 
       Caused by: android.os.RemoteException: Remote stack trace:
          at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:476)
          at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135)
          at android.os.Binder.execTransactInternal(Binder.java:1021)
          at android.os.Binder.execTransact(Binder.java:994)
  </code></pre>
  
  <p>P.S: This is experienced on Android Q DP5 GSI with target SDK 29. The app works fine with target sdk 28 without any changes.</p>