Fixed some static analysis issues
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.1.0'
|
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# This file is automatically generated by Android Tools.
|
|
||||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
||||||
#
|
|
||||||
# This file must be checked in Version Control Systems.
|
|
||||||
#
|
|
||||||
# To customize properties used by the Ant build system edit
|
|
||||||
# "ant.properties", and override values to adapt the script to your
|
|
||||||
# project structure.
|
|
||||||
#
|
|
||||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
|
||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
|
||||||
|
|
||||||
# Project target.
|
|
||||||
target=android-19
|
|
||||||
android.library=true
|
|
||||||
@@ -12,7 +12,6 @@ import android.os.Parcelable;
|
|||||||
* Expanded by Alexandros Schillings
|
* Expanded by Alexandros Schillings
|
||||||
*/
|
*/
|
||||||
public final class AdRecord implements Parcelable{
|
public final class AdRecord implements Parcelable{
|
||||||
|
|
||||||
// 02 # Number of bytes that follow in first AD structure
|
// 02 # Number of bytes that follow in first AD structure
|
||||||
// 01 # Flags AD type
|
// 01 # Flags AD type
|
||||||
// 1A # Flags value 0x1A = 000011010
|
// 1A # Flags value 0x1A = 000011010
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ public final class IBeaconManufacturerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String calculateUUIDString(final byte[] uuid){
|
private static String calculateUUIDString(final byte[] uuid){
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for(int i = 0 ; i< uuid.length; i++){
|
for(int i = 0 ; i< uuid.length; i++){
|
||||||
if(i == 4){sb.append('-');}
|
if(i == 4){sb.append('-');}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import android.util.SparseArray;
|
|||||||
public class AdRecordUtils {
|
public class AdRecordUtils {
|
||||||
|
|
||||||
public static String getRecordDataAsString(final AdRecord nameRecord) {
|
public static String getRecordDataAsString(final AdRecord nameRecord) {
|
||||||
if(nameRecord == null){return new String();}
|
if(nameRecord == null){return "";}
|
||||||
return new String(nameRecord.getData());
|
return new String(nameRecord.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ByteUtils {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String byteArrayToHexString(final byte[] array){
|
public static String byteArrayToHexString(final byte[] array){
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuilder sb = new StringBuilder();
|
||||||
boolean firstEntry = true;
|
boolean firstEntry = true;
|
||||||
sb.append('[');
|
sb.append('[');
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class IBeaconUtils {
|
|||||||
* Ascertains whether a Manufacturer Data byte array belongs to an iBeacon;
|
* Ascertains whether a Manufacturer Data byte array belongs to an iBeacon;
|
||||||
*
|
*
|
||||||
* @param manufacturerData a Bluetooth LE device's raw manufacturerData.
|
* @param manufacturerData a Bluetooth LE device's raw manufacturerData.
|
||||||
* @return
|
* @return true if the manufacturer data belong to an iBeacon
|
||||||
*/
|
*/
|
||||||
public static boolean isThisAnIBeacon(final byte[] manufacturerData){
|
public static boolean isThisAnIBeacon(final byte[] manufacturerData){
|
||||||
if(manufacturerData == null){return false;}
|
if(manufacturerData == null){return false;}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# This file is automatically generated by Android Tools.
|
|
||||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
||||||
#
|
|
||||||
# This file must be checked in Version Control Systems.
|
|
||||||
#
|
|
||||||
# To customize properties used by the Ant build system edit
|
|
||||||
# "ant.properties", and override values to adapt the script to your
|
|
||||||
# project structure.
|
|
||||||
#
|
|
||||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
|
||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
|
||||||
|
|
||||||
# Project target.
|
|
||||||
target=Google Inc.:Google APIs:19
|
|
||||||
android.library.reference.1=../library
|
|
||||||
+3
-4
@@ -76,7 +76,6 @@ public class DeviceControlActivity extends Activity {
|
|||||||
|
|
||||||
private boolean mConnected = false;
|
private boolean mConnected = false;
|
||||||
private String mExportString;
|
private String mExportString;
|
||||||
private BluetoothLeDevice mDevice;
|
|
||||||
|
|
||||||
// Code to manage Service lifecycle.
|
// Code to manage Service lifecycle.
|
||||||
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
@@ -280,9 +279,9 @@ public class DeviceControlActivity extends Activity {
|
|||||||
setContentView(R.layout.activity_gatt_services);
|
setContentView(R.layout.activity_gatt_services);
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
mDevice = intent.getParcelableExtra(EXTRA_DEVICE);
|
final BluetoothLeDevice device = intent.getParcelableExtra(EXTRA_DEVICE);
|
||||||
mDeviceName = mDevice.getName();
|
mDeviceName = device.getName();
|
||||||
mDeviceAddress = mDevice.getAddress();
|
mDeviceAddress = device.getAddress();
|
||||||
|
|
||||||
ButterKnife.inject(this);
|
ButterKnife.inject(this);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ public class DeviceDetailsActivity extends ListActivity{
|
|||||||
CompanyIdentifierResolver.getCompanyName(iBeaconData.getCompanyIdentifier(), getString(R.string.unknown))
|
CompanyIdentifierResolver.getCompanyName(iBeaconData.getCompanyIdentifier(), getString(R.string.unknown))
|
||||||
+ " (" + hexEncode(iBeaconData.getCompanyIdentifier()) + ")");
|
+ " (" + hexEncode(iBeaconData.getCompanyIdentifier()) + ")");
|
||||||
tvAdvert.setText(iBeaconData.getIBeaconAdvertisement() + " (" + hexEncode( iBeaconData.getIBeaconAdvertisement() ) + ")");
|
tvAdvert.setText(iBeaconData.getIBeaconAdvertisement() + " (" + hexEncode( iBeaconData.getIBeaconAdvertisement() ) + ")");
|
||||||
tvUUID.setText(iBeaconData.getUUID().toString());
|
tvUUID.setText(iBeaconData.getUUID());
|
||||||
tvMajor.setText(iBeaconData.getMajor() + " (" + hexEncode( iBeaconData.getMajor() ) + ")");
|
tvMajor.setText(iBeaconData.getMajor() + " (" + hexEncode( iBeaconData.getMajor() ) + ")");
|
||||||
tvMinor.setText(iBeaconData.getMinor() + " (" + hexEncode( iBeaconData.getMinor() ) + ")");
|
tvMinor.setText(iBeaconData.getMinor() + " (" + hexEncode( iBeaconData.getMinor() ) + ")");
|
||||||
tvTxPower.setText(iBeaconData.getCalibratedTxPower() + " (" + hexEncode( iBeaconData.getCalibratedTxPower() ) + ")");
|
tvTxPower.setText(iBeaconData.getCalibratedTxPower() + " (" + hexEncode( iBeaconData.getCalibratedTxPower() ) + ")");
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class MainActivity extends ListActivity {
|
|||||||
private LeDeviceListAdapter mLeDeviceListAdapter;
|
private LeDeviceListAdapter mLeDeviceListAdapter;
|
||||||
private BluetoothLeDeviceStore mDeviceStore;
|
private BluetoothLeDeviceStore mDeviceStore;
|
||||||
|
|
||||||
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
|
private final BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
|
public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
|
||||||
|
|
||||||
@@ -121,10 +121,9 @@ public class MainActivity extends ListActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(final ListView l, final View v, final int position, final long id) {
|
protected void onListItemClick(final ListView l, final View v, final int position, final long id) {
|
||||||
final BluetoothLeDevice device = (BluetoothLeDevice) mLeDeviceListAdapter.getItem(position);
|
final BluetoothLeDevice device = mLeDeviceListAdapter.getItem(position);
|
||||||
if (device == null) return;
|
if (device == null) return;
|
||||||
|
|
||||||
|
|
||||||
final Intent intent = new Intent(this, DeviceDetailsActivity.class);
|
final Intent intent = new Intent(this, DeviceDetailsActivity.class);
|
||||||
intent.putExtra(DeviceDetailsActivity.EXTRA_DEVICE, device);
|
intent.putExtra(DeviceDetailsActivity.EXTRA_DEVICE, device);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class LeDeviceListAdapter extends SimpleCursorAdapter {
|
|||||||
viewHolder.ibeaconDistance = (TextView) view.findViewById(R.id.ibeacon_distance);
|
viewHolder.ibeaconDistance = (TextView) view.findViewById(R.id.ibeacon_distance);
|
||||||
viewHolder.ibeaconUUID = (TextView) view.findViewById(R.id.ibeacon_uuid);
|
viewHolder.ibeaconUUID = (TextView) view.findViewById(R.id.ibeacon_uuid);
|
||||||
viewHolder.ibeaconTxPower = (TextView) view.findViewById(R.id.ibeacon_tx_power);
|
viewHolder.ibeaconTxPower = (TextView) view.findViewById(R.id.ibeacon_tx_power);
|
||||||
viewHolder.ibeaconSection = (View) view.findViewById(R.id.ibeacon_section);
|
viewHolder.ibeaconSection = view.findViewById(R.id.ibeacon_section);
|
||||||
viewHolder.ibeaconDistanceDescriptor = (TextView) view.findViewById(R.id.ibeacon_distance_descriptor);
|
viewHolder.ibeaconDistanceDescriptor = (TextView) view.findViewById(R.id.ibeacon_distance_descriptor);
|
||||||
view.setTag(viewHolder);
|
view.setTag(viewHolder);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ public class BluetoothLeDeviceStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private FileWriter generateFile(final File file, final String contents){
|
private static FileWriter generateFile(final File file, final String contents){
|
||||||
FileWriter writer = null;
|
FileWriter writer = null;
|
||||||
try {
|
try {
|
||||||
writer = new FileWriter(file);
|
writer = new FileWriter(file);
|
||||||
|
|||||||
@@ -10,14 +10,13 @@ import android.content.pm.PackageManager;
|
|||||||
public final class BluetoothUtils {
|
public final class BluetoothUtils {
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private final BluetoothAdapter mBluetoothAdapter;
|
private final BluetoothAdapter mBluetoothAdapter;
|
||||||
private final BluetoothManager mBluetoothManager;
|
|
||||||
|
|
||||||
public final static int REQUEST_ENABLE_BT = 2001;
|
public final static int REQUEST_ENABLE_BT = 2001;
|
||||||
|
|
||||||
public BluetoothUtils(final Activity activity){
|
public BluetoothUtils(final Activity activity){
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mBluetoothManager = (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE);
|
final BluetoothManager btManager = (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||||
mBluetoothAdapter = mBluetoothManager.getAdapter();
|
mBluetoothAdapter = btManager.getAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void askUserToEnableBluetoothIfNeeded(){
|
public void askUserToEnableBluetoothIfNeeded(){
|
||||||
|
|||||||
Reference in New Issue
Block a user