Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto grant screen mirroring permission? #18

Open
galenzhao opened this issue Aug 29, 2023 · 4 comments
Open

auto grant screen mirroring permission? #18

galenzhao opened this issue Aug 29, 2023 · 4 comments

Comments

@galenzhao
Copy link

galenzhao commented Aug 29, 2023

Hi,

We could add OP_PROJECT_MEDIA AppOps to the app to make click grant permission without popup an alert.
like: adb shell cmd appops set <pkg> PROJECT_MEDIA allow

so is there a way we can auto-grant it on the car without opening the app and clicking the button?

or how can I change the code to call this func https://github.com/BimmerGestalt/IDriveConnectAddons/blob/main/screen_mirror/src/main/java/io/bimmergestalt/idriveconnectaddons/screenmirror/MainController.kt#L7C17-L7C17

automatically when opening the screen-mirroring menu on the car.

hufman added a commit that referenced this issue Aug 29, 2023
hufman added a commit that referenced this issue Aug 29, 2023
@hufman
Copy link
Collaborator

hufman commented Aug 29, 2023

I tried adding code to check for the appops grant and automatically request the mirroring permission, but because it requires startActivity it only works if AAIdrive and thus Screen Mirror are in the foreground. Otherwise, the appops grant merely removes the second click after clicking the notification.

@galenzhao
Copy link
Author

I tried adding code to check for the appops grant and automatically request the mirroring permission, but because it requires startActivity it only works if AAIdrive and thus Screen Mirror are in the foreground. Otherwise, the appops grant merely removes the second click after clicking the notification.

It seems the iOS BMW app can open itself automatically when connected to the car's Bluetooth.
Is there a way to open our app also?

@hufman
Copy link
Collaborator

hufman commented Aug 29, 2023

iOS is not at all related to Android, and so iOS behavior should not be considered.
Android restricts activity launches from the background except for a few exceptions. The iOS BMW behavior would be able to have similar behavior on Android by registering as a CompanionDeviceManager as of API33, but neither AAIdrive nor ScreenMirror are directly connected to the car over Bluetooth so I don't think this option is available.

I posted the branch of code for you to experiment with, I don't know enough Android internals to explore this further.

galenzhao pushed a commit to galenzhao/IDriveConnectAddons that referenced this issue Aug 31, 2023
@galenzhao
Copy link
Author

by adding permission we can start an activity from backgrand.

https://github.com/galenzhao/IDriveConnectAddons/blob/35050e969d3b8a2846c9e0eaccacb23b763d62fe/screen_mirror/src/main/AndroidManifest.xml#L12


    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

https://github.com/galenzhao/IDriveConnectAddons/blob/35050e969d3b8a2846c9e0eaccacb23b763d62fe/screen_mirror/src/main/java/io/bimmergestalt/idriveconnectaddons/screenmirror/MainActivity.kt#L113-L117


        val uri = Uri.parse("package:$packageName")
        val intent = Intent(ACTION_MANAGE_OVERLAY_PERMISSION, uri)
        startActivityForResult(intent, REQUEST_PERMISSION_CODE)

but I didn't find a perfect timeframe to call our RequestActivity

galenzhao pushed a commit to galenzhao/IDriveConnectAddons that referenced this issue Jun 20, 2024
galenzhao pushed a commit to galenzhao/IDriveConnectAddons that referenced this issue Jun 20, 2024
galenzhao pushed a commit to galenzhao/IDriveConnectAddons that referenced this issue Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants