[NAN] Fix assumption about Strings containing single-byte characters.

Code assumed that each character was represented by a single byte.

Change-Id: I92ea63f7273379ed1035f10c207d41e3e352bf38
This commit is contained in:
Etan Cohen
2016-06-27 17:25:29 -07:00
parent 15849dc463
commit 9a6161c61c
3 changed files with 4 additions and 3 deletions

View File

@@ -380,8 +380,8 @@ public class PublishConfig implements Parcelable {
* {@code builder.setXXX(..).setXXX(..)}.
*/
public Builder setServiceSpecificInfo(@NonNull String serviceSpecificInfoStr) {
mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
mServiceSpecificInfoLength = mServiceSpecificInfo.length;
return this;
}

View File

@@ -413,8 +413,8 @@ public class SubscribeConfig implements Parcelable {
* {@code builder.setXXX(..).setXXX(..)}.
*/
public Builder setServiceSpecificInfo(@NonNull String serviceSpecificInfoStr) {
mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
mServiceSpecificInfoLength = mServiceSpecificInfo.length;
return this;
}

View File

@@ -224,7 +224,8 @@ public class TlvBufferUtils {
* {@code ctr.putXXX(..).putXXX(..)}.
*/
public TlvConstructor putString(int type, String data) {
return putByteArray(type, data.getBytes(), 0, data.length());
byte[] bytes = data.getBytes();
return putByteArray(type, bytes, 0, bytes.length);
}
/**