IBeacon.java
7.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
package com.radiusnetworks.ibeacon;
import android.annotation.TargetApi;
import android.bluetooth.BluetoothDevice;
import com.radiusnetworks.ibeacon.client.IBeaconDataFactory;
import com.radiusnetworks.ibeacon.client.NullIBeaconDataFactory;
public class IBeacon
{
public static final int PROXIMITY_FAR = 3;
public static final int PROXIMITY_IMMEDIATE = 1;
public static final int PROXIMITY_NEAR = 2;
public static final int PROXIMITY_UNKNOWN = 0;
private static final char[] a = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102 };
protected static IBeaconDataFactory iBeaconDataFactory = new NullIBeaconDataFactory();
protected Double accuracy;
protected String bluetoothAddress;
protected int major;
protected int minor;
protected Integer proximity;
protected String proximityUuid;
protected int rssi;
protected Double runningAverageRssi = null;
protected int txPower;
protected IBeacon() {}
protected IBeacon(IBeacon paramIBeacon)
{
this.major = paramIBeacon.major;
this.minor = paramIBeacon.minor;
this.accuracy = paramIBeacon.accuracy;
this.proximity = paramIBeacon.proximity;
this.runningAverageRssi = paramIBeacon.runningAverageRssi;
this.rssi = paramIBeacon.rssi;
this.proximityUuid = paramIBeacon.proximityUuid;
this.txPower = paramIBeacon.txPower;
this.bluetoothAddress = paramIBeacon.bluetoothAddress;
}
public IBeacon(String paramString, int paramInt1, int paramInt2)
{
this.proximityUuid = paramString.toLowerCase();
this.major = paramInt1;
this.minor = paramInt2;
this.txPower = -59;
this.rssi = 0;
}
protected IBeacon(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
this.proximityUuid = paramString.toLowerCase();
this.major = paramInt1;
this.minor = paramInt2;
this.rssi = paramInt4;
this.txPower = paramInt3;
}
private static String a(byte[] paramArrayOfByte)
{
char[] arrayOfChar = new char[paramArrayOfByte.length * 2];
int i = 0;
while (i < paramArrayOfByte.length)
{
int j = paramArrayOfByte[i] & 0xFF;
arrayOfChar[(i * 2)] = a[(j >>> 4)];
arrayOfChar[(i * 2 + 1)] = a[(j & 0xF)];
i += 1;
}
return new String(arrayOfChar);
}
protected static double calculateAccuracy(int paramInt, double paramDouble)
{
double d1;
if (paramDouble == 0.0D) {
d1 = -1.0D;
}
double d2;
do
{
return d1;
d1 = paramDouble * 1.0D / paramInt;
if (d1 < 1.0D) {
return Math.pow(d1, 10.0D);
}
d2 = Math.pow(d1, 7.7095D) * 0.89976D + 0.111D;
d1 = d2;
} while (!IBeaconManager.debug);
new StringBuilder(" avg rssi: ").append(paramDouble).append(" accuracy: ").append(d2);
return d2;
}
protected static int calculateProximity(double paramDouble)
{
if (paramDouble < 0.0D) {
return 0;
}
if (paramDouble < 0.5D) {
return 1;
}
if (paramDouble <= 4.0D) {
return 2;
}
return 3;
}
public static IBeacon fromScanData(byte[] paramArrayOfByte, int paramInt)
{
return fromScanData(paramArrayOfByte, paramInt, null);
}
@TargetApi(5)
public static IBeacon fromScanData(byte[] paramArrayOfByte, int paramInt, BluetoothDevice paramBluetoothDevice)
{
int i = 2;
if (i <= 5) {
if (((paramArrayOfByte[(i + 2)] & 0xFF) != 2) || ((paramArrayOfByte[(i + 3)] & 0xFF) != 21)) {}
}
for (int j = 1;; j = 0)
{
if (j == 0)
{
if (IBeaconManager.debug) {
new StringBuilder("This is not an iBeacon advertisment (no 0215 seen in bytes 4-7). The bytes I see are: ").append(a(paramArrayOfByte));
}
paramArrayOfByte = null;
}
IBeacon localIBeacon;
do
{
return paramArrayOfByte;
if (((paramArrayOfByte[i] & 0xFF) == 45) && ((paramArrayOfByte[(i + 1)] & 0xFF) == 36) && ((paramArrayOfByte[(i + 2)] & 0xFF) == 191) && ((paramArrayOfByte[(i + 3)] & 0xFF) == 22))
{
paramArrayOfByte = new IBeacon();
paramArrayOfByte.major = 0;
paramArrayOfByte.minor = 0;
paramArrayOfByte.proximityUuid = "00000000-0000-0000-0000-000000000000";
paramArrayOfByte.txPower = -55;
return paramArrayOfByte;
}
if (((paramArrayOfByte[i] & 0xFF) == 173) && ((paramArrayOfByte[(i + 1)] & 0xFF) == 119) && ((paramArrayOfByte[(i + 2)] & 0xFF) == 0) && ((paramArrayOfByte[(i + 3)] & 0xFF) == 198))
{
paramArrayOfByte = new IBeacon();
paramArrayOfByte.major = 0;
paramArrayOfByte.minor = 0;
paramArrayOfByte.proximityUuid = "00000000-0000-0000-0000-000000000000";
paramArrayOfByte.txPower = -55;
return paramArrayOfByte;
}
i += 1;
break;
localIBeacon = new IBeacon();
localIBeacon.major = ((paramArrayOfByte[(i + 20)] & 0xFF) * 256 + (paramArrayOfByte[(i + 21)] & 0xFF));
localIBeacon.minor = ((paramArrayOfByte[(i + 22)] & 0xFF) * 256 + (paramArrayOfByte[(i + 23)] & 0xFF));
localIBeacon.txPower = paramArrayOfByte[(i + 24)];
localIBeacon.rssi = paramInt;
Object localObject = new byte[16];
System.arraycopy(paramArrayOfByte, i + 4, localObject, 0, 16);
paramArrayOfByte = a((byte[])localObject);
localObject = new StringBuilder();
((StringBuilder)localObject).append(paramArrayOfByte.substring(0, 8));
((StringBuilder)localObject).append("-");
((StringBuilder)localObject).append(paramArrayOfByte.substring(8, 12));
((StringBuilder)localObject).append("-");
((StringBuilder)localObject).append(paramArrayOfByte.substring(12, 16));
((StringBuilder)localObject).append("-");
((StringBuilder)localObject).append(paramArrayOfByte.substring(16, 20));
((StringBuilder)localObject).append("-");
((StringBuilder)localObject).append(paramArrayOfByte.substring(20, 32));
localIBeacon.proximityUuid = ((StringBuilder)localObject).toString();
paramArrayOfByte = localIBeacon;
} while (paramBluetoothDevice == null);
localIBeacon.bluetoothAddress = paramBluetoothDevice.getAddress();
return localIBeacon;
}
}
public boolean equals(Object paramObject)
{
if (!(paramObject instanceof IBeacon)) {}
do
{
return false;
paramObject = (IBeacon)paramObject;
} while ((((IBeacon)paramObject).getMajor() != getMajor()) || (((IBeacon)paramObject).getMinor() != getMinor()) || (!((IBeacon)paramObject).getProximityUuid().equals(getProximityUuid())));
return true;
}
public double getAccuracy()
{
if (this.accuracy == null)
{
double d = this.rssi;
if (this.runningAverageRssi != null) {
d = this.runningAverageRssi.doubleValue();
}
this.accuracy = Double.valueOf(calculateAccuracy(this.txPower, d));
}
return this.accuracy.doubleValue();
}
public String getBluetoothAddress()
{
return this.bluetoothAddress;
}
public int getMajor()
{
return this.major;
}
public int getMinor()
{
return this.minor;
}
public int getProximity()
{
if (this.proximity == null) {
this.proximity = Integer.valueOf(calculateProximity(getAccuracy()));
}
return this.proximity.intValue();
}
public String getProximityUuid()
{
return this.proximityUuid;
}
public int getRssi()
{
return this.rssi;
}
public int getTxPower()
{
return this.txPower;
}
public int hashCode()
{
return this.minor;
}
public void requestData(IBeaconDataNotifier paramIBeaconDataNotifier)
{
iBeaconDataFactory.requestIBeaconData(this, paramIBeaconDataNotifier);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/radiusnetworks/ibeacon/IBeacon.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/