Display a warning if the active connection is metered. Find a proper MAC address for pairing (might require re-pair). Fix a possible infinite loop in the NvControl code.

This commit is contained in:
Cameron Gutman
2013-11-11 18:42:07 -05:00
parent 83ad55e436
commit 77786f9693
3 changed files with 71 additions and 21 deletions
+18 -2
View File
@@ -327,9 +327,17 @@ public class NvControl {
int offset = 0;
do
{
offset = in.read(header, offset, header.length - offset);
int bytesRead = in.read(header, offset, header.length - offset);
if (bytesRead < 0) {
break;
}
offset += bytesRead;
} while (offset != header.length);
if (offset != header.length) {
throw new IOException("Socket closed prematurely");
}
ByteBuffer bb = ByteBuffer.wrap(header).order(ByteOrder.LITTLE_ENDIAN);
type = bb.getShort();
@@ -342,8 +350,16 @@ public class NvControl {
offset = 0;
do
{
offset = in.read(payload, offset, payload.length - offset);
int bytesRead = in.read(payload, offset, payload.length - offset);
if (bytesRead < 0) {
break;
}
offset += bytesRead;
} while (offset != payload.length);
if (offset != payload.length) {
throw new IOException("Socket closed prematurely");
}
}
}