OSDN Git Service

Use readUnsignedByte.
authorWink Saville <wink@google.com>
Wed, 9 Jan 2013 18:53:51 +0000 (10:53 -0800)
committerWink Saville <wink@google.com>
Wed, 9 Jan 2013 18:53:51 +0000 (10:53 -0800)
To remove any doubt about how java is doing its byte/integer arithmetic
use readUnsignedByte instead of readByte.

Change-Id: I5bdc200ed0cda51ad739804ac1d8d13c043424ec

wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceResponse.java

index ac31663..194c982 100644 (file)
@@ -222,10 +222,10 @@ public class WifiP2pServiceResponse implements Parcelable {
                  */
                 // The length equals to 3 plus the number of octets in the vendor
                 // specific content field. And this is little endian.
-                int length = ((dis.readByte() & 0xff) +
-                        ((dis.readByte() & 0xff) << 8)) - 3;
+                int length = (dis.readUnsignedByte() +
+                        (dis.readUnsignedByte() << 8)) - 3;
                 int type = dis.readUnsignedByte();
-                byte transId = dis.readByte();
+                int transId = dis.readUnsignedByte();
                 int status = dis.readUnsignedByte();
                 if (length < 0) {
                     return null;