本人所在团队开发了一个即时通讯(类似企业微信)的工具,但在华为Mate8上使用的时候,当手机处于灭屏的状态下,无法接收到信息。
在手机上已经设置了该应用为受保护的应用,也在任务栏下拉将其程序后台锁定,基本上可设置的都设置了。(在荣耀7的手机上也无法接收信息,进行这些设置后就可以正常接收了)
查看了一下华为的log,Mate8(Android6.0)的电源管理清理能力比较强大,无视是否为受保护的应用。但设置为受保护的应用后,进程不会被杀死,只会挂起。
// 使用阿里巴巴的钉钉软件为例,log上显示所有的程序都会被proxy
05-27 16:45:57.250 I/PGManagerAdapter( 3994): [proxy] -> [ pid = 13860 uid = 10069]
05-27 16:45:57.250 I/ash ( 3994): Proxy wakelock uid = 10069 pid = 13860
05-27 16:45:57.250 I/ash ( 3994): No wakelock need to release, app : com.huawei.android.totemweather
05-27 16:45:57.270 I/ash ( 3994): com.alibaba.android.rimet { doze duration=172818 } transition to: hibernation, reason:null
05-27 16:45:57.270 I/ash ( 3994): clear doze actions!
05-27 16:45:57.270 I/ash ( 3994): removePeriodAdjustAlarms >> com.alibaba.android.rimet
05-27 16:45:57.270 I/ash ( 3994): perform hibernation actions!
05-27 16:45:57.270 I/ash ( 3994): periodAdjustAlarms >> com.alibaba.android.rimet interval : 300000
05-27 16:45:57.270 I/PGManagerService( 3411): proxyBroadcast:[com.alibaba.android.rimet] proxy:true
05-27 16:45:57.270 I/PGManagerAdapter( 3994): [proxy] -> [[com.alibaba.android.rimet]][0]
05-27 16:45:57.270 I/ash ( 3994): proxy com.alibaba.android.rimet broadcast OK !
05-27 16:45:57.270 I/ash ( 3994): delay perform hibernation actions!
05-27 16:45:57.270 I/ash ( 3994): proxy app:com.alibaba.android.rimet,result:true
05-27 16:45:57.280 I/PgedBinderAdapter( 3994): doFreezeProcess [action:1] -> [[7009, 7136]]
05-27 16:45:57.280 I/PgedBinderAdapter( 3994): doFreezeProcess ok, action:1
05-27 16:45:57.290 I/ash ( 3994): Freeze com.alibaba.android.rimet OK !
但钉钉被proxy之后,会发一个net packet将其 unFreeze
05-27 16:47:40.040 I/PgedBinderListener( 3994): net callback uids list:[10251]
05-27 16:47:40.140 I/ash ( 3994): net packet app = com.alibaba.android.rimet
05-27 16:47:40.140 I/ash ( 3994): com.alibaba.android.rimet net packet, H to R!
05-27 16:47:40.140 I/ash ( 3994): com.alibaba.android.rimet { hibernation duration=102870 } transition to: running, reason:net_packet F 0
05-27 16:47:40.140 I/ash ( 3994): clear hibernation actions!
05-27 16:47:40.140 I/ash ( 3994): No need to restore wakelock, app : com.alibaba.android.rimet
05-27 16:47:40.140 I/PGManagerService( 3411): proxyWakeLockByPidUid, pid: 7009, uid: 10251, proxy: false
05-27 16:47:40.140 I/PGManagerAdapter( 3994): [unproxy] -> [ pid = 7009 uid = 10251]
05-27 16:47:40.140 I/ash ( 3994): Unproxy wakelock uid = 10251 pid = 7009
05-27 16:47:40.140 I/PGManagerService( 3411): proxyWakeLockByPidUid, pid: 7136, uid: 10251, proxy: false
我们自己的程序也有建立socket从后台每隔4s发送一个心跳,但这个socket同样在灭屏的时候也会被挂起,不知道其他应用都是怎么做到unFreeze的,有大神麻烦指点一下么?
只有华为的Android6.0以上的手机才存在这样的问题,咨询过华为的客服,说了一堆设置,但没效果。