问题
I have three android devices, a Samsung Galaxy Note 10 an HTC Desire C and a Sony Xperia E. As well i have a service that listens on a specific TCP port on these devices. The WIFI policy is set to "Always on" in all of my devices as well my service acquires a WIFI_MODE_FULL and a PARTIAL_WAKE_LOCK so the CPU and WIFI are always there. After some time when i want to connect to these devices from the server something bad happens.
- The Samsung Galaxy Note device always behaves correctly.
- HTC Desire becomes unreachable
- The Sony device is also unreachable
I Pinged these devices to see if they are there or not. The results is:
- The Samsung device always responds to ping requests immediately and normally.
- HTC and Sony device are unreachable for sometime and sometimes they respond but with a very long latency even when their screen is on (time column of ping is sometimes about 5000ms).
I know that there are some issues with the WIFI policy:
- https://code.google.com/p/android/issues/detail?id=9781
- https://code.google.com/p/android/issues/detail?id=6611
But why the ping time is like this?? Even when the screen is on?? As well i know that the CPU clock decreases when screen goes off, even if you hold a wake lock. Can this cause problems in the Service code that handles TCP connections??
回答1:
Manufacturers want to be able to brag about having the longest battery life. To that end, they'll shave existing features to their very bone to deliver on that battery life.
And yes, it can cause problems and it does cause problems, but that's one of the many reasons you should be programming defensively. In other words, make sure your application is prepared to deal with dropped packets and possible longer delays.
Hopefully, your questions weren't entirely rhetorical and you actually wanted an answer.
来源:https://stackoverflow.com/questions/17523493/android-strange-cross-device-behaviour