henrichg / PhoneProfilesPlus

Profile manager for Android - event triggered
Apache License 2.0
423 stars 32 forks source link

Use of "Display over other apps" permission #115

Closed DavisNT closed 1 year ago

DavisNT commented 1 year ago

After upgrading to PhoneProfilesPlus 6.2 it always requests "Display over other apps" permission and doesn't allow to switch profiles without it, however PhoneProfilesPlus 4.2.0.3 was successfully working on the same Android 13 phone, with the same profiles, and without "Display over other apps" permission (it displayed a notification about missing "Display over other apps" permission, but was usable without the permission).

Could it be possible to introduce a setting that would prevent PhoneProfilesPlus from requiring this permission (any warnings inside profile editor could still be displayed, but it would be possible to use PhoneProfilesPlus without granting this permission)?

henrichg commented 1 year ago

Required is for Android 10+ for all these functions:

It is also required to run background activities (workers, executors, ...). And PPP must start background activities (empty activities that perform the required actions). Why? Ask Google. :-)

henrichg commented 1 year ago

Since Android 10, Google ads more and more restrictions. And most of them requires permission SYSTEM_ALERT_WINDOW. And this permission must be granted by user as "Display over other apps".

DavisNT commented 1 year ago

And still there are many things that can be done without creating activities. Also there are cases when activity creation can happen without SYSTEM_ALERT_WINDOW permission.

I had never granted it to PhoneProfilesPlus 4.2.0.3 and I don't remember having any issues. The main reason why I upgraded (and broke my installation) was because I wanted to see whether there are more vibration settings now available.

I am not saying that "Display over other apps" is not needed, I am saying it would be good to have an option (likely buried deep into settings) that would just disable the block-screens demanding the permission (non-intrusive red messages in the profile editor, of course, do not need to be affected by the setting).

P.S. I assume I don't need to explain why one might not want to grant the "Display over other apps" permission.

henrichg commented 1 year ago

Read this: https://developer.android.com/guide/components/activities/background-starts

PPP uses often background activities.

Examples:

Because in many different situations SYSTEM_ALERT_WINDOW permisison is necessary, in my opinion it is better to ask it immediately at PPP start and set is as required.

DavisNT commented 1 year ago

I have read that article. Thank you!

I suspect that in my case PPP 4.2.0.3 might be working so well, because I have PPP home screen widget (I suspect it might also influence whether the app is allowed to start activities).

For me also, for example, events are working (just tested that profiles get switched with an event that has 5 minutes delay). So there definitely are cases when PPP works properly without "Display over other apps" permission.

henrichg commented 1 year ago

4.2.0.3 is very old version. Maybe in it SYSTEM_ALERT_WIDOW is not needed.

Min sdk, target sdk, compile sdk, build gradle, all is changed after that version.

Is problem, by you, grant this permission? If yes, use 4.2.0.3. But in 6.2 is more, more, more new fuctionality added. ;-)

DavisNT commented 1 year ago

@henrichg Sorry for the late reply! If I would build and test the current version of PPP (~with~ without the code that blocks functionality if "Display over other apps" permission is not granted) and it will work without the "Display over other apps" permission, in that case will you be open to a PR with setting that allows to use PPP without the Display over other apps" permission?

henrichg commented 1 year ago

This permission is needed for basic functionality of PPP.

PPP must open non-visible (empty) activities in background and for this situations is this permission required.

Again: https://developer.android.com/guide/components/activities/background-starts

Without this permission, PPP do not working correctly.

DavisNT commented 1 year ago

Is the answer "no" (regardless of any testing results)?

henrichg commented 1 year ago

PPP is open source under the Apache license. It's up to you to fork it and change it. Then the answer is yes, you can.

But again: permission is required for ALL activities that PPP starts in the background.

If PPP needs to start activity from background and permisison is not granted, how do I notify the user about it? With notification? And user must click and grant "Draw over other apps"? And after grant, how to repeat start of activity? It would be complicated.

DavisNT commented 1 year ago

Sorry - two comments back I accidentally wrote "with" instead of "without" (I have fixed it only now).

My question was whether you would accept a pull request that introduces an option to allow PPP to run without the "Display over other apps" permission, if it would turn out that in some cases current version of PPP works on Android 13 without the "Display over other apps" permission?

henrichg commented 1 year ago

Make pull request and I will looking into it. :-)

DavisNT commented 1 year ago

Thank you!

I will likely do the testing no sooner than in a few weeks. I will write here about the testing results.

henrichg commented 1 year ago

Look at this screenahot from frst start of Tasker. Also requires "Draw over other apps". Screenshot_20231022_231919_Tasker