Prevent NullPointerException in getStringValue if no value is set

Bug: 18686365
Change-Id: I5f5d07ef49500e0d8118ba04aaf373ae4514f034
This commit is contained in:
Andre Eisenbach
2014-12-09 16:42:14 -08:00
parent c6de3212c2
commit 0fd06a19bd

View File

@@ -502,7 +502,7 @@ public class BluetoothGattCharacteristic {
* @return Cached value of the characteristic
*/
public String getStringValue(int offset) {
if (offset > mValue.length) return null;
if (mValue == null || offset > mValue.length) return null;
byte[] strBytes = new byte[mValue.length - offset];
for (int i=0; i != (mValue.length-offset); ++i) strBytes[i] = mValue[offset+i];
return new String(strBytes);