You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Put app into temporary whitelist when high priority gcm received #338
On android M and above and google's implementation, apps will be woken up and put into temporary whitelist by gcm priority message. This is done by addPowerSaveTempWhitelistApp() in IDeviceIdleController.aidl. But in microG there is no such setting, so it leads to some delay in notification. I've experience 30 minutes delay in whatsapp message even microG received from google server on time .
changed the title [-]Put app into temporary whitelist when high priority gcm received[/-][+]Put app into temporary whitelist when high priority gcm received [$5][/+]on Apr 2, 2017
@Catfriend1 This is definitely because of this issue.
I have a working commit to solve this, but it uses private api, and needs microg to be priv-app. In addition a seperate file need to be placed into /system/etc/permissions. So it is unlikely to be accepted by microg
@ale5000-git My code is out of sync with the github one, and not easy to get sync. There are more parts need to be done, including adding a new aidl and manually convert to java stub. I have not touch the code for quite long time, and got a bit rusty.
For the xml in /etc/permissions, you need to grep "com.android.providers.download", and give microg the same treatment as that package.
If you know how to code, perhaps we can chat in email so you could help me to get this upstream.
@ale5000-git Your commit 67de6f4 is basically what I previously did. It should be able to put other apps into temporary whitelist, together with a new permission file /system/etc/permissions/microg.xml:
(There is also equivalent /system/etc/sysconfig/microg-a5k.xml with <config/> syntax)
You can use adb shell dumpsys deviceidle whitelist and adb shell dumpsys deviceidle tempwhitelist to test&verify.
In the AIDL file IDeviceIdleController.aidl, the method addPowerSaveTempWhitelistApp need a userID argument, it will usually be zero for normal apps, but none-zero for managed-profile apps or apps installed by non-primary users. I did not know how to get the userID of the target app, so I always use 0, but it is problematic in multi-user or managed-profile scenario. In fact this is the major reason why I did not push my work upstream. @ale5000-git@mar-v-in Do you know how to solve this?
I think I may have fixed a bug that caused mDeviceIdleController to remain null. The Context.DEVICE_IDLE_CONTROLLER field is hidden and wasn't properly being passed.
Using the command adb shell dumpsys deviceidle, an app that receives a push notification now appears in the temp whitelist for 10 seconds! The branch is available here. I also have a compiled binary here for testing purposes. (These will be deleted once merged upstream.)
In the AIDL file IDeviceIdleController.aidl, the method addPowerSaveTempWhitelistApp need a userID argument, it will usually be zero for normal apps, but none-zero for managed-profile apps or apps installed by non-primary users. I did not know how to get the userID of the target app, so I always use 0, but it is problematic in multi-user or managed-profile scenario.
Does the userID need to be the UID of the receiving app or the UID of microG? I tried modifying the code to use the UID of the receiving app, but in the logcat the ActivityManager said it expected a 0. I'm not running in a multi-user or managed profile setting, so I didn't test those configurations, but using 0 seemed to work for me (once I fixed the bug mentioned above).
Hopefully someone can test this out to confirm it works. Testing in a multi-user and managed profile environment would be great too. I'd love to see this get merged in before the next microG release since this likely affects nearly all users. If this looks good, let me know if you'd like me to open a PR.
I think I solved the multi-user problem too. It required some ugly reflection, due to more hidden APIs, but it seems to work. I am unable to test this for managed profiles, however. Since this seems to me like it's now working, I've opened a PR #732.
@ale5000-git It looks like you were involved in this one too.
I just did some general refactoring and code maintenance for the most part. I fixed a couple bugs and figured out how to get the userID, but this isn't really a significant contribution. One of you two should claim it. 🎉
changed the title [-]Put app into temporary whitelist when high priority gcm received [$5][/-][+]Put app into temporary whitelist when high priority gcm received[/+]on Aug 5, 2025
Activity
[-]Put app into temporary whitelist when high priority gcm received[/-][+]Put app into temporary whitelist when high priority gcm received [$5][/+]EinsteinXXL commentedon Jun 20, 2017
I offer 75$!!
ale5000-git commentedon Jan 27, 2018
@Catfriend1: I think it is unrelated, this one is related to Doze / energy saving that cause delayed messages.
ccaapton commentedon Jan 28, 2018
@Catfriend1 This is definitely because of this issue.
I have a working commit to solve this, but it uses private api, and needs microg to be priv-app. In addition a seperate file need to be placed into /system/etc/permissions. So it is unlikely to be accepted by microg
ale5000-git commentedon Jan 28, 2018
@ccaapton: Could you please explain in details your fix and post a link?
ale5000-git commentedon Jan 29, 2018
@ccaapton
I just found your code.
What about the file in /system/etc/permissions ?
ccaapton commentedon Jan 29, 2018
@ale5000-git My code is out of sync with the github one, and not easy to get sync. There are more parts need to be done, including adding a new aidl and manually convert to java stub. I have not touch the code for quite long time, and got a bit rusty.
For the xml in /etc/permissions, you need to grep "com.android.providers.download", and give microg the same treatment as that package.
If you know how to code, perhaps we can chat in email so you could help me to get this upstream.
ale5000-git commentedon Jun 20, 2018
@ccaapton: I have made it compile successfully as Travis CI reported but I haven't tested it.
Merge pull request #1 from ale5000-git/master
ccaapton commentedon Jun 21, 2018
@ale5000-git Your commit 67de6f4 is basically what I previously did. It should be able to put other apps into temporary whitelist, together with a new permission file /system/etc/permissions/microg.xml:
(There is also equivalent /system/etc/sysconfig/microg-a5k.xml with
<config/>syntax)You can use
adb shell dumpsys deviceidle whitelistandadb shell dumpsys deviceidle tempwhitelistto test&verify.In the AIDL file
IDeviceIdleController.aidl, the methodaddPowerSaveTempWhitelistAppneed auserIDargument, it will usually be zero for normal apps, but none-zero for managed-profile apps or apps installed by non-primary users. I did not know how to get the userID of the target app, so I always use 0, but it is problematic in multi-user or managed-profile scenario. In fact this is the major reason why I did not push my work upstream. @ale5000-git @mar-v-in Do you know how to solve this?nicman23 commentedon Jan 5, 2019
Any progress on this?
voidstarstar commentedon Feb 28, 2019
Related to #650
voidstarstar commentedon Mar 17, 2019
@ccaapton @ale5000-git
I think I may have fixed a bug that caused
mDeviceIdleControllerto remain null. TheContext.DEVICE_IDLE_CONTROLLERfield is hidden and wasn't properly being passed.Using the command
adb shell dumpsys deviceidle, an app that receives a push notification now appears in the temp whitelist for 10 seconds! The branch is available here. I also have a compiled binary here for testing purposes. (These will be deleted once merged upstream.)Does the
userIDneed to be the UID of the receiving app or the UID of microG? I tried modifying the code to use the UID of the receiving app, but in the logcat theActivityManagersaid it expected a 0. I'm not running in a multi-user or managed profile setting, so I didn't test those configurations, but using 0 seemed to work for me (once I fixed the bug mentioned above).Hopefully someone can test this out to confirm it works. Testing in a multi-user and managed profile environment would be great too. I'd love to see this get merged in before the next microG release since this likely affects nearly all users. If this looks good, let me know if you'd like me to open a PR.
voidstarstar commentedon Mar 18, 2019
I think I solved the multi-user problem too. It required some ugly reflection, due to more hidden APIs, but it seems to work. I am unable to test this for managed profiles, however. Since this seems to me like it's now working, I've opened a PR #732.
Temporary whitelist support for Doze (#732)
voidstarstar commentedon Jun 2, 2019
@ale5000-git It looks like you were involved in this one too.
I just did some general refactoring and code maintenance for the most part. I fixed a couple bugs and figured out how to get the userID, but this isn't really a significant contribution. One of you two should claim it. 🎉
ale5000-git commentedon Jun 2, 2019
My contribution was minimal in this issue, maybe it should be left to @ccaapton that was the original creator.
[-]Put app into temporary whitelist when high priority gcm received [$5][/-][+]Put app into temporary whitelist when high priority gcm received[/+]