NetD Destroys Sockets When Device Is Not Connected To Charger
Solution 1:
I believe the issue comes from the new Doze
feature that was introduced in Android 6.0 API Level 23, enhanced in Android 7.0.
Doze improves battery life by deferring CPU and network activities when a user leaves a device unplugged, stationary, and with the screen turned off. Android 7.0 brings further enhancements to Doze by applying a subset of CPU and network restrictions while the device is unplugged with the screen turned off, but not necessarily stationary, for example, when a handset is traveling in a user’s pocket.
Doze restrictions
The following restrictions apply to your apps while in Doze:
- Network access is suspended.
- The system ignores wake locks.
- Standard AlarmManager alarms (including setExact() and setWindow()) are deferred to the next maintenance window.
- If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle().
- Alarms set with setAlarmClock() continue to fire normally — the system exits Doze shortly before those alarms fire.
- The system does not perform Wi-Fi scans.
- The system does not allow sync adapters to run.
- The system does not allow JobScheduler to run
With that said, you technically have two options - embrace Doze, fight it.
Embracing Doze
Go over Optimizing for Doze and App Standby
Fighting Doze
A combination of dumpsys deviceidle disable
, setting idle_to
and max_idle_to
to 1 sec (and associated scaling factors to 1) will help in disabling it. Refer to this xda-developers post.
Post a Comment for "NetD Destroys Sockets When Device Is Not Connected To Charger"