henrichg / PhoneProfilesPlus

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

Volume values don't adjust in the background #54

Closed Dre-OS closed 4 years ago

Dre-OS commented 4 years ago

I recently switched from PhoneProfiles to PhoneProfilesPlus. but there is a problem, the volume (any volume including Media, Alarm, Ring, etc.) can't adjust in the background, It only adjusts in manual activation through activator and not through an event. I have exempted PhoneProfilesPlus from battery optimization but that does not make a difference.

Using Realme 5 running RealmeUI (Android 10)

henrichg commented 4 years ago

Hm, not good. The same profile used for manual profile activation working but not working when is activated by event? Please send me your PPP data and which profile not working. Use in Editor menu "Backup/Restore"/"Backup and e-mail settings". Send data to my e-mail: henrich.gron@gmail.com. Thank you.

Dre-OS commented 4 years ago

The problem also persist when "close after activation" in activator settings is enabled. I guess volumes only adjust when I'm on PPP Activator/Editor

henrichg commented 4 years ago

Hm, then problem is with background changes? Question: PPP notification about activated profile is displayed? PPP uses "foreground" service. This service must be running all the time. Each "foreground" service has it's notification. Maybe your device kills all applications running in background. Check in Settings for battery optimization and remove PPP from this. Maybe is possible to add application into whitelist. Also look at: https://dontkillmyapp.com/.

Dre-OS commented 4 years ago

Hm, not good. The same profile used for manual profile activation working but not working when is activated by event? Please send me your PPP data and which profile not working. Use in Editor menu "Backup/Restore"/"Backup and e-mail settings". Send data to my e-mail: henrich.gron@gmail.com. Thank you.

All profiles with volume adjustments are not working

henrichg commented 4 years ago

Only volumes? Write me, how is configured this not-working profile.

Dre-OS commented 4 years ago

Only volumes? Write me, how is configured this not-working profile.

Yes, all other setting changes are working (Radios, brightness, Sound profiles, etc.) And all that is left is volume which is untouched when I'm not in Editor/activator

henrichg commented 4 years ago

Please write me profile configuration, ALL. I will testing it, or send me all PPP data. How, is also writed by me.

henrichg commented 4 years ago

Please, wrire me your PPP version.

Dre-OS commented 4 years ago

Files are now sent

Dre-OS commented 4 years ago

4.1.10.2 (6100)

henrichg commented 4 years ago

Thank you, your data restroed in my Pixel 3a. Which profile not working?

Dre-OS commented 4 years ago

Home and media mode are my most used profiles but are not adjusting volumes when put in events, let's test those

henrichg commented 4 years ago

Not working all volumes? In "Home" profile is ringing, notification, media, alarm volume. In "Media mode" profile is only media volume.

Dre-OS commented 4 years ago

Hmn... It seems like the media volume is the problem, the ringtone volume adjusted after I activated an event, I just tested right now

henrichg commented 4 years ago

OK, then only media volume not working. You are not only one to write me about this problem. Not good.

Please, if you want, test this beta version. In it is more, and more changes and some additions. Maybe media volume is also fixed. Maybe. In beta is added also logging of calls (my big call test). Logs are also saved into log.txt. For this, ignore battery consumption. Is increased. After tests by you, I will send you version with disabled logging. https://drive.google.com/file/d/1KMasYeFp47knvOJkmQyvuXbcFPNwyF43/view?usp=drivesdk

henrichg commented 4 years ago

Question: You have granted (G1) permission? Maybe for your device it is required. For media channel PPP test it, when system returns SecurityException. Test also this. How to grant (G1) permission is in "Important information" (question-mark icon in Editor top bar). Thank you. PPP set "audio_safe_volume_state"=2 when SecurityException is returned.

Dre-OS commented 4 years ago

I'll try that soon, thanks for great work

Dre-OS commented 4 years ago

OK, then only media volume not working. You are not only one to write me about this problem. Not good.

Please, if you want, test this beta version. In it is more, and more changes and some additions. Maybe media volume is also fixed. Maybe. In beta is added also logging of calls (my big call test). Logs are also saved into log.txt. For this, ignore battery consumption. Is increased. After tests by you, I will send you version with disabled logging. https://drive.google.com/file/d/1KMasYeFp47knvOJkmQyvuXbcFPNwyF43/view?usp=drivesdk

I don't have to send the log?

henrichg commented 4 years ago

Yes it is possible, In Editor menu is "Support"/"E-mail debug log files to author".

Dre-OS commented 4 years ago

OK, then only media volume not working. You are not only one to write me about this problem. Not good.

Please, if you want, test this beta version. In it is more, and more changes and some additions. Maybe media volume is also fixed. Maybe. In beta is added also logging of calls (my big call test). Logs are also saved into log.txt. For this, ignore battery consumption. Is increased. After tests by you, I will send you version with disabled logging. https://drive.google.com/file/d/1KMasYeFp47knvOJkmQyvuXbcFPNwyF43/view?usp=drivesdk

Is call logging allowed by google play? There might be a possibility of that not going through their security, brother...

henrichg commented 4 years ago

But SecurityException for media volume is not logged. :-( I can send you new version with this enabled.

henrichg commented 4 years ago

Not, call logging is completely disabled in Google Play version.

Dre-OS commented 4 years ago

But SecurityException for media volume is not logged. :-( I can send you new version with this enabled.

Call logging is disabled in that version? I'm so sorry but I can't test the one with it enabled, this device is my daily use phone, i truly apologize

henrichg commented 4 years ago

In beta (4.1.11b) is enabled. In Google Play version (4.1.10.2) is disabled. I'm using beta version all the time in my Galaxy S10. Consumption is 0,30. But if you want, I can disable logging for you.

Dre-OS commented 4 years ago

Yes please, but I hope you find a beta tester that is comfortable in testing it

henrichg commented 4 years ago

Version with logging disabled: https://drive.google.com/file/d/1KMasYeFp47knvOJkmQyvuXbcFPNwyF43/view?usp=drivesdk Thank for testing. ;-)

Dre-OS commented 4 years ago

Ok, so i updated to Google play version 4.1.11 (the link wasn't working, I'm sorry) and i noticed that only my default profile (Home) changed media volume but the event-activated profile (Media mode) did not...

henrichg commented 4 years ago

Again question: You have granted (G1) permission? Maybe for your device it is required. For media channel PPP test it, when system returns SecurityException. Test also this. How to grant (G1) permission is in "Important information" (question-mark icon in Editor top bar). Thank you. PPP set "audio_safe_volume_state"=2 when SecurityException is returned.

henrichg commented 4 years ago

For which application is started event? In your data are two events: Playing video, Playing Music. Maybe is not possible to change media volume when media application is running. You do not use in these two events delay start. Configure and test it again. For example delay=5 seconds.

Dre-OS commented 4 years ago

Those events trigger through opening an app/detecting notification so it occurs before the media plays, theres another event there "offline gaming" wherein it supposed to adjust media volume= 3 but it doesn't do it and there aren't media playing

henrichg commented 4 years ago

OK, then, I can add logging about this. When event was started, all other volumes from events are changed, and only problem is with media volume, then I must add logging, when and how is changed media volume. Is possible by you, to install test version with logging?

Dre-OS commented 4 years ago

Sure, if it's logging volumes only then I'm in

Dre-OS commented 4 years ago

Ok, so I granted G1 permission but the bug still is present

Dre-OS commented 4 years ago

For which application is started event? In your data are two events: Playing video, Playing Music. Maybe is not possible to change media volume when media application is running. You do not use in these two events delay start. Configure and test it again. For example delay=5 seconds.

I added delays ranging from 1 to 5 seconds but it still doesn't adjust the volume

henrichg commented 4 years ago

I'm tested your event "Play video" event with YouTube Music. When YouTube Music starts, event "Play video" also starts, media volume was changed by profile "Media mode". But when YouTube Music gets in background or closed, event "Play video" gets also paused and "Home" profile was activated. This also change media volume. Warning: Application sensor check if application is in FOREGROUND. Foreground = its gui is diplayed (not only notification because notification is in system level, not application level). For this, better is using Notification sensor. Because notification is displayed (if applicaiton display it) even when application is in background.

Dre-OS commented 4 years ago

Could it be a vendor-specific issue? Because the Media mode profile cannot modify volume regardless of the app triggering the events being in the foreground ("play video" event) or in the background ("play music" event). Only the Home profile (Default, no triggered event) can modify the media volume on my Realme 5

Dre-OS commented 4 years ago

Could it be a vendor-specific issue? Because the Media mode profile cannot modify volume regardless of the app triggering the events being in the foreground ("play video" event) or in the background ("play music" event). Only the Home profile (Default, no triggered event) can modify the media volume on my Realme 5

To add to this, the Home profile just occasionally modifies the volume when no events are running. I suspect a vendor-specific issue in my opinion because OPPO phones (similar origin as Realme but separated years ago and running ColorOS) has a real aggressive battery optimization even with an app whitelisted from it. Have you encountered this kind of issue on Non-ColorOS devices?

henrichg commented 4 years ago

If it is probem wirh battery oprimizations then read dontkillmyapp.com and configure devices by this. This is also in PPP in Settings/System.

Dre-OS commented 4 years ago

Hmn.. I have done what i can do there, the battery saver is integrated into ColorOS so i can't uninstall it. that's the only thing i can't do, but the PPP Service is still affected by it by not running properly. Guess i have tough luck

henrichg commented 4 years ago

And this not helps? https://dontkillmyapp.com/oppo

pin your app to the recent apps screen enable your app in the app list inside the security app’s “startup manager” and “floating app list” (com.coloros.safecenter / com.coloros.safecenter.permission.Permission) turn off battery optimizations give the service a persistent notification to remain in the foreground

Dre-OS commented 4 years ago

Yes, I did all of those

henrichg commented 4 years ago

Dre-OS, please test this version. In it is log about chage of media volume from PPP and also from outside of PPP. Is based from version 4.1.11. https://drive.google.com/file/d/1KMasYeFp47knvOJkmQyvuXbcFPNwyF43/view?usp=drivesdk After tests, send me log.txt. Thank you.

Dre-OS commented 4 years ago

I can't access the file :) kindly authorize my email adress, thank you

henrichg commented 4 years ago

And currently? I'm grant it for you.

Dre-OS commented 4 years ago

Ok, i got it and tested it, check your email 😁

henrichg commented 4 years ago

Hm, this is not good: It is Realme: 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------deviceIsRealme=true 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------manufacturer=realme 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------model=RMX1911 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------display=RMX1911EX_11_C.49 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------brand=realme 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------fingerprint=realme/RMX1911/RMX1911:10/QKQ1.200209.002/1590818789:user/release-keys 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------type=user 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------modVersion=Unknown 5.08.20 22:29:38:2--E-----##### PPApplication.onCreate------osVersion=4.14.117-perf+ 5.08.20 22:29:38:3--E-----##### PPApplication.onCreate------deviceName=null 5.08.20 22:29:38:3--E-----##### PPApplication.onCreate------release=10 5.08.20 22:29:38:3--E-----##### PPApplication.onCreate------board=trinket 5.08.20 22:29:38:3--E-----##### PPApplication.onCreate------product=RMX1911 ... 5.08.20 22:29:38:3--E-----$$$ PhoneProfilesService.onCreate------android.os.Build.VERSION.SDK_INT=29 (Android 10) ...

  1. profile activation - media change=true, volume=6 5.08.20 22:29:44:6--E-----PhoneProfilesService.isServiceRunning------service.foreground=true 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaChange()=true 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaValue()=6 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmChange()=true 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmValue()=16 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceChange()=false 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceValue()=-1 5.08.20 22:29:44:9--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOChange()=false 5.08.20 22:29:45:0--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOValue()=-1 ... set of media volume - used is AudioManager 5.08.20 22:29:45:0--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------value=6 5.08.20 22:29:45:0--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------set media volume (1) ...
  2. profile activation - media change=true, volume=9 5.08.20 22:29:45:8--E-----PhoneProfilesService.isServiceRunning------service.foreground=true 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaChange()=true 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaValue()=9 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmChange()=false 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmValue()=-1 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceChange()=false 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceValue()=-1 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOChange()=false 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOValue()=-1 ... set of media volume - used is AudioManager 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------value=9 5.08.20 22:29:53:4--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------set media volume (1) ...

??? where is change of media volume ???

5.08.20 22:29:54:6--E-----[OBSERVER CALL] SettingsContentObserver.onChange------uri=content://settings/system/accelerometer_rotation

??? media volume is 10, not 9 (read from AudioManager) ??? 5.08.20 22:29:54:6--E-----[TEST MEDIA VOLUME] SettingsContentObserver.onChange------STREAM_MUSIC=10

5.08.20 22:30:01:3--E-----[OBSERVER CALL] SettingsContentObserver.onChange------uri=content://settings/system/accelerometer_rotation

??? media volume is 10, not 9 (read from AudioManager) ??? 5.08.20 22:30:01:3--E-----[TEST MEDIA VOLUME] SettingsContentObserver.onChange------STREAM_MUSIC=10

...

  1. profile activation - media change=true, volume=6 5.08.20 22:29:54:4--E-----PhoneProfilesService.isServiceRunning------service.foreground=true 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaChange()=true 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeMediaValue()=6 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmChange()=true 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeAlarmValue()=16 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceChange()=false 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeVoiceValue()=-1 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOChange()=false 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes------profile.getVolumeBluetoothSCOValue()=-1 ... set of media volume - used is AudioManager 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------value=6 5.08.20 22:30:01:5--E-----[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume------set media volume (1)
henrichg commented 4 years ago

This is from Pixel 3a: 2020-08-05 20:25:21.724 25559-25670/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] SettingsContentObserver.onChange: STREAM_MUSIC=9

2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeMediaChange()=true 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeMediaValue()=14 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeAlarmChange()=false 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeAlarmValue()=0 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeVoiceChange()=false 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeVoiceValue()=-1 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeBluetoothSCOChange()=false 2020-08-05 20:25:22.367 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setVolumes: profile.getVolumeBluetoothSCOValue()=-1

2020-08-05 20:25:22.368 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume: value=14 2020-08-05 20:25:22.368 25559-25677/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] ActivateProfileHelper.setMediaVolume: set media volume (1)

2020-08-05 20:25:22.498 25559-25696/sk.henrichg.phoneprofilesplus E/PhoneProfilesService.isServiceRunning: service.foreground=true

In your log is not this (and also AudioManager do not change this channel): 2020-08-05 20:25:22.897 25559-25670/sk.henrichg.phoneprofilesplus E/[OBSERVER CALL] SettingsContentObserver.onChange: uri=content://settings/system/volume_music_speaker 2020-08-05 20:25:22.899 25559-25670/sk.henrichg.phoneprofilesplus E/[TEST MEDIA VOLUME] SettingsContentObserver.onChange: STREAM_MUSIC=14

Not good, not good. :-(

henrichg commented 4 years ago

Is possible to configure your Realme to use standard AudioManager for volume change?

Dre-OS commented 4 years ago

SettingsContentObserver.onChange------uri=content://settings/system/accelerometer_rotation

I do not know how or why my Realme does media volume change with the accelerometer but it did not succeed in doing so when i was doing the test, media volume never changed

henrichg commented 4 years ago

No, no. no. :-D This uri is returned by system, but is not used for get media volume from AudioManager. Ignore it. Problem is with uri=content://settings/system/volume_music_speaker. Is never returned by system in your device. This problem is also in another user with the same Realme device. This uri is never returned and volume is not changed in AudioManager. This is big problem. :-(