diff --git a/src/main/java/org/altbeacon/beacon/Beacon.java b/src/main/java/org/altbeacon/beacon/Beacon.java index 6d4dc3ce4..c5294d613 100644 --- a/src/main/java/org/altbeacon/beacon/Beacon.java +++ b/src/main/java/org/altbeacon/beacon/Beacon.java @@ -43,7 +43,7 @@ *
A Beacon is identified by a unique multi-part identifier, with the first of the ordered * identifiers being more significant for the purposes of grouping beacons. * - * An Beacon sends a Bluetooth Low Energy (BLE) advertisement that contains these + * A Beacon sends a Bluetooth Low Energy (BLE) advertisement that contains these * three identifiers, along with the calibrated tx power (in RSSI) of the * Beacon's Bluetooth transmitter. * diff --git a/src/main/java/org/altbeacon/beacon/BeaconManager.java b/src/main/java/org/altbeacon/beacon/BeaconManager.java index 69e789ee3..fbf32d302 100644 --- a/src/main/java/org/altbeacon/beacon/BeaconManager.java +++ b/src/main/java/org/altbeacon/beacon/BeaconManager.java @@ -219,13 +219,20 @@ public static BeaconManager getInstanceForApplication(Context context) { return client; } - /** + protected BeaconManager(Context context) { + mContext = context; + if (!sManifestCheckingDisabled) { + verifyServiceDeclaration(); + } + this.beaconParsers.add(new AltBeaconParser()); + } + + /** * Gets a list of the active beaconParsers. This list may only be modified before any consumers * are bound to the beacon service * * @return list of active BeaconParsers */ - public ListgetBeaconParsers() { if (isAnyConsumerBound()) { return Collections.unmodifiableList(beaconParsers); @@ -233,14 +240,6 @@ public List getBeaconParsers() { return beaconParsers; } - protected BeaconManager(Context context) { - mContext = context; - if (!sManifestCheckingDisabled) { - verifyServiceDeclaration(); - } - this.beaconParsers.add(new AltBeaconParser()); - } - /** * Check if Bluetooth LE is supported by this Android device, and if so, make sure it is enabled. * diff --git a/src/main/java/org/altbeacon/beacon/distance/ModelSpecificDistanceCalculator.java b/src/main/java/org/altbeacon/beacon/distance/ModelSpecificDistanceCalculator.java index 3f53af526..99512c060 100644 --- a/src/main/java/org/altbeacon/beacon/distance/ModelSpecificDistanceCalculator.java +++ b/src/main/java/org/altbeacon/beacon/distance/ModelSpecificDistanceCalculator.java @@ -62,6 +62,7 @@ public class ModelSpecificDistanceCalculator implements DistanceCalculator { public ModelSpecificDistanceCalculator(Context context, String remoteUpdateUrlString) { this(context, remoteUpdateUrlString, AndroidModel.forThisDevice()); } + /** * Obtains the best possible DistanceCalculator
for the Android device passed * as an argument @@ -80,6 +81,7 @@ public ModelSpecificDistanceCalculator(Context context, String remoteUpdateUrlSt public AndroidModel getModel() { return mModel; } + /** * @return the Android device model requested to be used for distance calculations */ @@ -130,10 +132,10 @@ private DistanceCalculator findCalculatorForModel(AndroidModel model) { private void loadModelMap() { boolean mapLoaded = false; if (mRemoteUpdateUrlString != null) { - mapLoaded= loadModelMapFromFile(); + mapLoaded = loadModelMapFromFile(); // We only want to try to download an update from the server the first time the app is // run. If we successfully download an update it gets saved to a file, so if the file - // is present that means should not download again + // is present that means should not download again. if (!mapLoaded) { requestModelMapFromWeb(); } @@ -224,7 +226,6 @@ public void onComplete(String body, Exception ex, int code) { else if (code != 200) { LogManager.w(TAG, "Cannot updated distance models from online database at %s " + "due to HTTP status code %s", mRemoteUpdateUrlString, code); - } else { LogManager.d(TAG, @@ -272,6 +273,7 @@ private void buildModelMap(String jsonString) throws JSONException { } } } + private void loadDefaultModelMap() { mModelMap = new HashMap(); try { @@ -287,13 +289,13 @@ private String stringFromFilePath(String path) throws IOException { BufferedReader bufferedReader = null; StringBuilder inputStringBuilder = new StringBuilder(); try { - stream = ModelSpecificDistanceCalculator.class.getResourceAsStream("/"+path); + stream = ModelSpecificDistanceCalculator.class.getResourceAsStream("/" + path); if (stream == null) { - stream = this.getClass().getClassLoader().getResourceAsStream("/"+path); + stream = this.getClass().getClassLoader().getResourceAsStream("/" + path); } if (stream == null) { - throw new RuntimeException("Cannot load resource at "+path); + throw new RuntimeException("Cannot load resource at " + path); } bufferedReader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); String line = bufferedReader.readLine(); @@ -301,7 +303,6 @@ private String stringFromFilePath(String path) throws IOException { inputStringBuilder.append(line);inputStringBuilder.append('\n'); line = bufferedReader.readLine(); } - } finally { if (bufferedReader != null) { diff --git a/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaver.java b/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaver.java index 697c9dc54..677f06deb 100644 --- a/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaver.java +++ b/src/main/java/org/altbeacon/beacon/powersave/BackgroundPowerSaver.java @@ -33,7 +33,7 @@ public BackgroundPowerSaver(Context context, boolean countActiveActivityStrategy LogManager.w(TAG, "BackgroundPowerSaver requires API 18 or higher."); return; } - if (context instanceof Application ) { + if (context instanceof Application) { ((Application)context).registerActivityLifecycleCallbacks(this); } else { diff --git a/src/main/java/org/altbeacon/beacon/startup/RegionBootstrap.java b/src/main/java/org/altbeacon/beacon/startup/RegionBootstrap.java index a32ae9cd5..fd77ec789 100644 --- a/src/main/java/org/altbeacon/beacon/startup/RegionBootstrap.java +++ b/src/main/java/org/altbeacon/beacon/startup/RegionBootstrap.java @@ -25,10 +25,10 @@ * is connected or disconnected from a device if the user has force terminated the app. * * IMPORTANT NOTE: The RegionBootstrap class registers an internal MonitorNotifier with the - * BeaconManager. If you use the RegionBootstrap, your application must not manually register + * BeaconManager. If you use the RegionBootstrap, your application must not manually register * a second MonitorNotifier, otherwise it will unregister the one configured by the RegionBootstrap, - * effectively disabling it. When using the RegionBootstrap, any custom monitoring code must must - * therefore be placed in the callback methods in the BootsrapNotifier implementation passed to the + * effectively disabling it. When using the RegionBootstrap, any custom monitoring code must + * therefore be placed in the callback methods in the BootstrapNotifier implementation passed to the * RegionBootstrap. */ public class RegionBootstrap { diff --git a/src/main/java/org/altbeacon/bluetooth/BluetoothCrashResolver.java b/src/main/java/org/altbeacon/bluetooth/BluetoothCrashResolver.java index 018cda70d..b89ceca95 100644 --- a/src/main/java/org/altbeacon/bluetooth/BluetoothCrashResolver.java +++ b/src/main/java/org/altbeacon/bluetooth/BluetoothCrashResolver.java @@ -28,7 +28,7 @@ * Bluetooth LE devices in the background (e.g. beacon-enabled apps), especially when these users * are around Bluetooth LE devices that randomize their mac address like Gimbal beacons. * - * This class can both recover from crashes and prevent crashes from happening in the first place + * This class can both recover from crashes and prevent crashes from happening in the first place. * * More details on the bug can be found at the following URLs: * @@ -44,7 +44,7 @@ public class BluetoothCrashResolver { private static final String TAG = "BluetoothCrashResolver"; private static final boolean PREEMPTIVE_ACTION_ENABLED = true; /** - * This is not the same file that Bluedroid uses. This is just to maintain state of this module + * This is not the same file that Bluedroid uses. This is just to maintain state of this module. */ private static final String DISTINCT_BLUETOOTH_ADDRESSES_FILE = "BluetoothCrashResolverState.txt"; private boolean recoveryInProgress = false;