public class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
arrayAddBytes(byte[] arr,
byte... elements)
This method will add elements to an array and return the resulting array
|
static double |
calculateDistance(int txPower,
double rssi)
Estimates the distance between the mobile device and a BLE beacon based on the measured
RSSI and a txPower calibration value that represents the expected RSSI for an iPhone 5 receiving
the signal when it is 1 meter away.
|
static int |
convertRssiDBmToPercent(int rssidBm)
Convert a RSSI from dBm to percent.
|
static int |
countSubstring(java.lang.String subStr,
java.lang.String str)
Count the number of non-overlapping occurrences of a substring inside a string.
|
static java.lang.String |
getDeviceUniqueId(android.content.Context ctx)
Get Android ID, a 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime
of the device.
|
static java.lang.String |
getPlatformSupportedAbis() |
static long |
getThreadId()
Returns a reference to the currently executing thread object.
|
static java.lang.String |
getThreadSignature()
Returns a unique String identifying the current thread.
|
static byte[] |
intToBytes(int i)
Convert integer into 4 bytes array
|
static java.lang.Boolean |
isBitSet(int data,
int bitPos)
Checks if a bit is set
|
static boolean |
isDeviationNeeded(int modulation)
Indicates if the modulation requires setting the deviation parameter.
|
static void |
log(char logLevel,
java.lang.String tag,
java.lang.String text)
Logging helper: put new logs into the UI console
|
static boolean |
validateMacAddress(java.lang.String macAddress)
Checks for MAC address correctness.
|
public static void log(char logLevel, java.lang.String tag, java.lang.String text)
logLevel
- Priority of the log message: v,d,e,i,w,e,atag
- Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.text
- The message you would like logged.public static byte[] intToBytes(int i)
i
- integer to convertpublic static double calculateDistance(int txPower, double rssi)
txPower
- Reference rssi at 1mrssi
- Actual rssi at the current locationpublic static int convertRssiDBmToPercent(int rssidBm)
rssidBm
- RSSI level to be converted.public static java.lang.Boolean isBitSet(int data, int bitPos)
data
- Data to checkbitPos
- Index of bit to checkpublic static java.lang.String getDeviceUniqueId(android.content.Context ctx)
ctx
- Current contextpublic static int countSubstring(java.lang.String subStr, java.lang.String str)
subStr
- substring to be searched forstr
- the string to searchpublic static boolean validateMacAddress(java.lang.String macAddress)
macAddress
- A MAC address to check.public static long getThreadId()
public static java.lang.String getThreadSignature()
public static byte[] arrayAddBytes(byte[] arr, byte... elements)
arr
- Array of bytes where bytes elements need to be appended.elements
- Bytes to be appended.public static boolean isDeviationNeeded(int modulation)
modulation
- Modulation as an integer.public static java.lang.String getPlatformSupportedAbis()