Status Update
Comments
ak...@google.com <ak...@google.com>
ak...@google.com <ak...@google.com> #2
Could you please provide the bugreport immediately after the issue is reproduced?
Android bug report (to be captured after reproducing the issue)
For steps to capture a bug report, please refer:
Alternate method:
Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
ak...@google.com <ak...@google.com> #4
We have passed this to the development team and will update this issue with more information as it becomes available.
ak...@google.com <ak...@google.com> #5 Restricted
he...@google.com <he...@google.com> #6
Media projection is noramlly used for wireless content streaming (casting, screensharing) or for screen recordings. It is not meant for mirroring content for connected devices. If DisplayLink would like to use media projection for their use case they would need to use something like the wakelock workaround in a foreground service (see
pe...@synaptics.com <pe...@synaptics.com> #7
Your previous comment (#5, now deleted) referred to "Better Together". As far as we can see, the only screen sharing mechanism there is Googlecast, which is not compatible with our USB devices.
What we are trying to do, of course, is to provide a user experience that is a close as possible to having a device driver built into the system. Each monitor needs to be represented by an Android display. Using a privileged app, we are able to achieve that since it can create virtual displays directly. But for an unprivileged app on the Play Store, the only way we can create virtual displays is by using Media Projection.
Our app has been on the Play Store since 2016 and we have been using Media Projection from Android 5 to Android 15. But since Android 13, you have been making our life increasing difficult by imposing new restrictions on Media Projection and changing the way mirroring is implemented. (See for example
pe...@synaptics.com <pe...@synaptics.com> #8
Regarding possible workarounds:
-
Can we use a wakelock to prevent device locking without using a deprecated API?
-
Is there any way we can obtain the user's permission to re-start projection after the device has been unlocked? Owing to the strange nature of the MediaProjection API, we are obliged to launch an activity in order to obtain screen capture permission. But we are unable to launch such an activity due to the restrictions on starting activities from the background that have existed since Android 10. If you can advise us of any workaround that would allow our service to re-request capture permission when the device is unlocked then that would be better than nothing (though creating a new display isn't ideal as I've already explained above).
ca...@google.com <ca...@google.com> #9
-
The wake lock still seems to be a valid use case in your scenario. It is deprecated but still supported from what I can tell.
-
we are unable to launch such an activity due to the restrictions on starting activities from the background
Don't take this a solution, but more as some kind a investigation direction: according to
https://developer.android.com/guide/components/activities/background-starts#exceptions , if you hold theSYSTEM_ALERT_WINDOW
permission, you are able to launch background activities. In my opinion, this fits your scenario since you can inform the user that your application is currently sharing the screen to an external monitor.
pe...@synaptics.com <pe...@synaptics.com> #10
Regarding SYSTEM_ALERT_WINDOW permission, the documentation says that "Very few apps should use this permission; these windows are intended for system-level interaction with the user." If we added this permission to our Play Store app, would it be accepted by any review that is triggered when the app is updated?
It seems that SYSTEM_ALERT_WINDOW is automatically granted to an app that is capturing the screen via MediaProjection - but only while capture is in effect! This is unhelpful, since of course we would want to launch an activity (to obtain capture permission) AFTER a MediaProjection session had ended. Thus, we would have to ask the user to grant SYSTEM_ALERT_WINDOW permission by sending Settings.ACTION_MANAGE_OVERLAY_PERMISSION, which is a somewhat convoluted process.
ca...@google.com <ca...@google.com> #11
Regarding SYSTEM_ALERT_WINDOW permission, the documentation says that "Very few apps should use this permission; these windows are intended for system-level interaction with the user." If we added this permission to our Play Store app, would it be accepted by any review that is triggered when the app is updated?
That's not something know but feel free to link to this issue if you encounter issues when uploading the play store.
pe...@synaptics.com <pe...@synaptics.com> #12
Thanks for your suggestions.
I would also like to comment on the red status bar "chip" that now appears when media projection is in progress. Although having this on the device screen is not too bad, it is of course mirrored to the captured image as well. In the case of the DisplayLink Presenter app, the chip therefore appears (much larger) on the monitor that is connected to the dock. I feel that this does detract from the user experience, especially since the chip contains a continuously changing counter, which is distracting!
Since mirroring during Media Projection is now implemented by the Window Server, there is presumably some control of which windows/layers/surfaces are included in the mirror. So perhaps you could omit the chip from the captured image?
The chip must surely affect video conferencing apps as well, since these typically have an option to share the user's screen. It will mean that the experience of everyone in a video conference will be worse if the presenter is using an Android device compared to that when the presenter is using a desktop operating system.
Description
Android developer: Y
Android beta build: AP41.240925.009
Device: Pixel 8
Regression from Android 15: Y
App package name: com.displaylink.presenter
We are seriously impacted by the change in Android 15 QPR1 beta that stops Media Projection when the device is locked.
Steps to reproduce:
Expected behaviour: mirroring to the monitor resumes.
Actual behaviour: on Android 15 QPR1, mirroring does not resume.
This completely breaks our app, since users expect mirroring to continue after device sleep or lock+unlock. It is inevitable that the device will sleep periodically when a user is working intermittently.
Analysis
Our app receives the MediaProjection callback onStop() when the device is locked and thus releases the virtual display. Even if we don't release the display ourselves, the system does so forcibly. So no more pixels are received from the display and the monitor goes blank.
There isn't any good workaround that we can add to the app, since recovery would mean creating a new virtual display, which needs a new MediaProjection session, which in turn needs permission from the user. Obtaining such permission falls foul of the restrictions on starting an activity from the background! (Only a foreground service is running at this point, no activities.) Creating a new display is highly undesirable anyway, since any content on the previous display (such as Presentations) would be lost.
Suggestions
Media projection could be paused while the device is locked and then resume again when the device is unlocked. However, we prefer to see a lock screen on the monitor when the device wakes up and is still locked, which is what happens in the released version of Android 15 or earlier. Please revert this change and think again.