diff options
author | Jack He <siyuanh@google.com> | 2017-08-22 16:06:54 -0700 |
---|---|---|
committer | Jack He <siyuanh@google.com> | 2017-08-24 19:09:48 +0000 |
commit | 910201beb0bde1dcf6b33e4ec5d1eb60042419d8 (patch) | |
tree | 9e7b8aa471daaed62a7e16a6b8cbd10a0a533e8a /framework/java/android/bluetooth/BluetoothGattCharacteristic.java | |
parent | 931010f176faa894f06051c57290f7723dfbcd49 (diff) |
Fix checkstyle errors (1/2)
* Automatic style corrections through IDE
Bug: 63596319
Test: make checkbuild, no manual changes, no functional changes
Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothGattCharacteristic.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothGattCharacteristic.java | 132 |
1 files changed, 71 insertions, 61 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java index 1cc2270be5..4816804652 100644 --- a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java +++ b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java @@ -16,8 +16,9 @@ package android.bluetooth; import android.os.Parcel; -import android.os.Parcelable; import android.os.ParcelUuid; +import android.os.Parcelable; + import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -171,30 +172,35 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * The UUID of this characteristic. + * * @hide */ protected UUID mUuid; /** * Instance ID for this characteristic. + * * @hide */ protected int mInstance; /** * Characteristic properties. + * * @hide */ protected int mProperties; /** * Characteristic permissions. + * * @hide */ protected int mPermissions; /** * Key size (default = 16). + * * @hide */ protected int mKeySize = 16; @@ -202,18 +208,21 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Write type for this characteristic. * See WRITE_TYPE_* constants. + * * @hide */ protected int mWriteType; /** * Back-reference to the service this characteristic belongs to. + * * @hide */ protected BluetoothGattService mService; /** * The cached value of this characteristic. + * * @hide */ protected byte[] mValue; @@ -237,26 +246,28 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Create a new BluetoothGattCharacteristic + * * @hide */ /*package*/ BluetoothGattCharacteristic(BluetoothGattService service, - UUID uuid, int instanceId, - int properties, int permissions) { + UUID uuid, int instanceId, + int properties, int permissions) { initCharacteristic(service, uuid, instanceId, properties, permissions); } /** * Create a new BluetoothGattCharacteristic + * * @hide */ public BluetoothGattCharacteristic(UUID uuid, int instanceId, - int properties, int permissions) { + int properties, int permissions) { initCharacteristic(null, uuid, instanceId, properties, permissions); } private void initCharacteristic(BluetoothGattService service, - UUID uuid, int instanceId, - int properties, int permissions) { + UUID uuid, int instanceId, + int properties, int permissions) { mUuid = uuid; mInstance = instanceId; mProperties = properties; @@ -301,7 +312,7 @@ public class BluetoothGattCharacteristic implements Parcelable { }; private BluetoothGattCharacteristic(Parcel in) { - mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid(); + mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid(); mInstance = in.readInt(); mProperties = in.readInt(); mPermissions = in.readInt(); @@ -313,7 +324,7 @@ public class BluetoothGattCharacteristic implements Parcelable { ArrayList<BluetoothGattDescriptor> descs = in.createTypedArrayList(BluetoothGattDescriptor.CREATOR); if (descs != null) { - for (BluetoothGattDescriptor desc: descs) { + for (BluetoothGattDescriptor desc : descs) { desc.setCharacteristic(this); mDescriptors.add(desc); } @@ -322,6 +333,7 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Returns the desired key size. + * * @hide */ public int getKeySize() { @@ -343,12 +355,13 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Get a descriptor by UUID and isntance id. + * * @hide */ /*package*/ BluetoothGattDescriptor getDescriptor(UUID uuid, int instanceId) { - for(BluetoothGattDescriptor descriptor : mDescriptors) { + for (BluetoothGattDescriptor descriptor : mDescriptors) { if (descriptor.getUuid().equals(uuid) - && descriptor.getInstanceId() == instanceId) { + && descriptor.getInstanceId() == instanceId) { return descriptor; } } @@ -357,6 +370,7 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Returns the service this characteristic belongs to. + * * @return The asscociated service */ public BluetoothGattService getService() { @@ -365,6 +379,7 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Sets the service associated with this device. + * * @hide */ /*package*/ void setService(BluetoothGattService service) { @@ -394,6 +409,7 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Force the instance ID. + * * @hide */ public void setInstanceId(int instanceId) { @@ -437,11 +453,8 @@ public class BluetoothGattCharacteristic implements Parcelable { * {@link BluetoothGatt#writeCharacteristic} function write this * characteristic. * - * @param writeType The write type to for this characteristic. Can be one - * of: - * {@link #WRITE_TYPE_DEFAULT}, - * {@link #WRITE_TYPE_NO_RESPONSE} or - * {@link #WRITE_TYPE_SIGNED}. + * @param writeType The write type to for this characteristic. Can be one of: {@link + * #WRITE_TYPE_DEFAULT}, {@link #WRITE_TYPE_NO_RESPONSE} or {@link #WRITE_TYPE_SIGNED}. */ public void setWriteType(int writeType) { mWriteType = writeType; @@ -449,6 +462,7 @@ public class BluetoothGattCharacteristic implements Parcelable { /** * Set the desired key size. + * * @hide */ public void setKeySize(int keySize) { @@ -468,11 +482,10 @@ public class BluetoothGattCharacteristic implements Parcelable { * Returns a descriptor with a given UUID out of the list of * descriptors for this characteristic. * - * @return GATT descriptor object or null if no descriptor with the - * given UUID was found. + * @return GATT descriptor object or null if no descriptor with the given UUID was found. */ public BluetoothGattDescriptor getDescriptor(UUID uuid) { - for(BluetoothGattDescriptor descriptor : mDescriptors) { + for (BluetoothGattDescriptor descriptor : mDescriptors) { if (descriptor.getUuid().equals(uuid)) { return descriptor; } @@ -503,11 +516,9 @@ public class BluetoothGattCharacteristic implements Parcelable { * characteristic value at the given offset are interpreted to generate the * return value. * - * @param formatType The format type used to interpret the characteristic - * value. + * @param formatType The format type used to interpret the characteristic value. * @param offset Offset at which the integer value can be found. - * @return Cached value of the characteristic or null of offset exceeds - * value size. + * @return Cached value of the characteristic or null of offset exceeds value size. */ public Integer getIntValue(int formatType, int offset) { if ((offset + getTypeLen(formatType)) > mValue.length) return null; @@ -517,21 +528,21 @@ public class BluetoothGattCharacteristic implements Parcelable { return unsignedByteToInt(mValue[offset]); case FORMAT_UINT16: - return unsignedBytesToInt(mValue[offset], mValue[offset+1]); + return unsignedBytesToInt(mValue[offset], mValue[offset + 1]); case FORMAT_UINT32: - return unsignedBytesToInt(mValue[offset], mValue[offset+1], - mValue[offset+2], mValue[offset+3]); + return unsignedBytesToInt(mValue[offset], mValue[offset + 1], + mValue[offset + 2], mValue[offset + 3]); case FORMAT_SINT8: return unsignedToSigned(unsignedByteToInt(mValue[offset]), 8); case FORMAT_SINT16: return unsignedToSigned(unsignedBytesToInt(mValue[offset], - mValue[offset+1]), 16); + mValue[offset + 1]), 16); case FORMAT_SINT32: return unsignedToSigned(unsignedBytesToInt(mValue[offset], - mValue[offset+1], mValue[offset+2], mValue[offset+3]), 32); + mValue[offset + 1], mValue[offset + 2], mValue[offset + 3]), 32); } return null; @@ -541,22 +552,21 @@ public class BluetoothGattCharacteristic implements Parcelable { * Return the stored value of this characteristic. * <p>See {@link #getValue} for details. * - * @param formatType The format type used to interpret the characteristic - * value. + * @param formatType The format type used to interpret the characteristic value. * @param offset Offset at which the float value can be found. - * @return Cached value of the characteristic at a given offset or null - * if the requested offset exceeds the value size. + * @return Cached value of the characteristic at a given offset or null if the requested offset + * exceeds the value size. */ public Float getFloatValue(int formatType, int offset) { if ((offset + getTypeLen(formatType)) > mValue.length) return null; switch (formatType) { case FORMAT_SFLOAT: - return bytesToFloat(mValue[offset], mValue[offset+1]); + return bytesToFloat(mValue[offset], mValue[offset + 1]); case FORMAT_FLOAT: - return bytesToFloat(mValue[offset], mValue[offset+1], - mValue[offset+2], mValue[offset+3]); + return bytesToFloat(mValue[offset], mValue[offset + 1], + mValue[offset + 2], mValue[offset + 3]); } return null; @@ -572,7 +582,7 @@ public class BluetoothGattCharacteristic implements Parcelable { public String getStringValue(int offset) { 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]; + for (int i = 0; i != (mValue.length - offset); ++i) strBytes[i] = mValue[offset + i]; return new String(strBytes); } @@ -585,8 +595,8 @@ public class BluetoothGattCharacteristic implements Parcelable { * remote device. * * @param value New value for this characteristic - * @return true if the locally stored value has been set, false if the - * requested value could not be stored locally. + * @return true if the locally stored value has been set, false if the requested value could not + * be stored locally. */ public boolean setValue(byte[] value) { mValue = value; @@ -612,25 +622,25 @@ public class BluetoothGattCharacteristic implements Parcelable { value = intToSignedBits(value, 8); // Fall-through intended case FORMAT_UINT8: - mValue[offset] = (byte)(value & 0xFF); + mValue[offset] = (byte) (value & 0xFF); break; case FORMAT_SINT16: value = intToSignedBits(value, 16); // Fall-through intended case FORMAT_UINT16: - mValue[offset++] = (byte)(value & 0xFF); - mValue[offset] = (byte)((value >> 8) & 0xFF); + mValue[offset++] = (byte) (value & 0xFF); + mValue[offset] = (byte) ((value >> 8) & 0xFF); break; case FORMAT_SINT32: value = intToSignedBits(value, 32); // Fall-through intended case FORMAT_UINT32: - mValue[offset++] = (byte)(value & 0xFF); - mValue[offset++] = (byte)((value >> 8) & 0xFF); - mValue[offset++] = (byte)((value >> 16) & 0xFF); - mValue[offset] = (byte)((value >> 24) & 0xFF); + mValue[offset++] = (byte) (value & 0xFF); + mValue[offset++] = (byte) ((value >> 8) & 0xFF); + mValue[offset++] = (byte) ((value >> 16) & 0xFF); + mValue[offset] = (byte) ((value >> 24) & 0xFF); break; default: @@ -644,7 +654,7 @@ public class BluetoothGattCharacteristic implements Parcelable { * <p>See {@link #setValue(byte[])} for details. * * @param mantissa Mantissa for this characteristic - * @param exponent exponent value for this characteristic + * @param exponent exponent value for this characteristic * @param formatType Float format type used to transform the value parameter * @param offset Offset at which the value should be placed * @return true if the locally stored value has been set @@ -658,18 +668,18 @@ public class BluetoothGattCharacteristic implements Parcelable { case FORMAT_SFLOAT: mantissa = intToSignedBits(mantissa, 12); exponent = intToSignedBits(exponent, 4); - mValue[offset++] = (byte)(mantissa & 0xFF); - mValue[offset] = (byte)((mantissa >> 8) & 0x0F); - mValue[offset] += (byte)((exponent & 0x0F) << 4); + mValue[offset++] = (byte) (mantissa & 0xFF); + mValue[offset] = (byte) ((mantissa >> 8) & 0x0F); + mValue[offset] += (byte) ((exponent & 0x0F) << 4); break; case FORMAT_FLOAT: mantissa = intToSignedBits(mantissa, 24); exponent = intToSignedBits(exponent, 8); - mValue[offset++] = (byte)(mantissa & 0xFF); - mValue[offset++] = (byte)((mantissa >> 8) & 0xFF); - mValue[offset++] = (byte)((mantissa >> 16) & 0xFF); - mValue[offset] += (byte)(exponent & 0xFF); + mValue[offset++] = (byte) (mantissa & 0xFF); + mValue[offset++] = (byte) ((mantissa >> 8) & 0xFF); + mValue[offset++] = (byte) ((mantissa >> 16) & 0xFF); + mValue[offset] += (byte) (exponent & 0xFF); break; default: @@ -717,7 +727,7 @@ public class BluetoothGattCharacteristic implements Parcelable { */ private int unsignedBytesToInt(byte b0, byte b1, byte b2, byte b3) { return (unsignedByteToInt(b0) + (unsignedByteToInt(b1) << 8)) - + (unsignedByteToInt(b2) << 16) + (unsignedByteToInt(b3) << 24); + + (unsignedByteToInt(b2) << 16) + (unsignedByteToInt(b3) << 24); } /** @@ -725,9 +735,9 @@ public class BluetoothGattCharacteristic implements Parcelable { */ private float bytesToFloat(byte b0, byte b1) { int mantissa = unsignedToSigned(unsignedByteToInt(b0) - + ((unsignedByteToInt(b1) & 0x0F) << 8), 12); + + ((unsignedByteToInt(b1) & 0x0F) << 8), 12); int exponent = unsignedToSigned(unsignedByteToInt(b1) >> 4, 4); - return (float)(mantissa * Math.pow(10, exponent)); + return (float) (mantissa * Math.pow(10, exponent)); } /** @@ -735,9 +745,9 @@ public class BluetoothGattCharacteristic implements Parcelable { */ private float bytesToFloat(byte b0, byte b1, byte b2, byte b3) { int mantissa = unsignedToSigned(unsignedByteToInt(b0) - + (unsignedByteToInt(b1) << 8) - + (unsignedByteToInt(b2) << 16), 24); - return (float)(mantissa * Math.pow(10, b3)); + + (unsignedByteToInt(b1) << 8) + + (unsignedByteToInt(b2) << 16), 24); + return (float) (mantissa * Math.pow(10, b3)); } /** @@ -745,8 +755,8 @@ public class BluetoothGattCharacteristic implements Parcelable { * signed value. */ private int unsignedToSigned(int unsigned, int size) { - if ((unsigned & (1 << size-1)) != 0) { - unsigned = -1 * ((1 << size-1) - (unsigned & ((1 << size-1) - 1))); + if ((unsigned & (1 << size - 1)) != 0) { + unsigned = -1 * ((1 << size - 1) - (unsigned & ((1 << size - 1) - 1))); } return unsigned; } @@ -756,7 +766,7 @@ public class BluetoothGattCharacteristic implements Parcelable { */ private int intToSignedBits(int i, int size) { if (i < 0) { - i = (1 << size-1) + (i & ((1 << size-1) - 1)); + i = (1 << size - 1) + (i & ((1 << size - 1) - 1)); } return i; } |