RangedIBeacon.java
2.92 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
package com.radiusnetworks.ibeacon.service;
import com.radiusnetworks.ibeacon.IBeacon;
import com.radiusnetworks.ibeacon.IBeaconManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
public class RangedIBeacon
extends IBeacon
{
public static long DEFAULT_SAMPLE_EXPIRATION_MILLISECONDS = 20000L;
private static String a = "RangedIBeacon";
private static long b = 20000L;
private boolean c = true;
private ArrayList<a> d = new ArrayList();
public RangedIBeacon(IBeacon paramIBeacon)
{
super(paramIBeacon);
addMeasurement(Integer.valueOf(this.rssi));
}
private void a()
{
try
{
Date localDate = new Date();
ArrayList localArrayList = new ArrayList();
Iterator localIterator = this.d.iterator();
while (localIterator.hasNext())
{
a locala = (a)localIterator.next();
if (localDate.getTime() - locala.b < b) {
localArrayList.add(locala);
}
}
this.d = localArrayList;
}
finally {}
Collections.sort(this.d);
}
public static void setSampleExpirationMilliseconds(long paramLong)
{
b = paramLong;
}
public void addMeasurement(Integer paramInteger)
{
this.c = true;
a locala = new a((byte)0);
locala.a = paramInteger;
locala.b = new Date().getTime();
this.d.add(locala);
}
protected void addRangeMeasurement(Integer paramInteger)
{
this.rssi = paramInteger.intValue();
addMeasurement(paramInteger);
}
public void commitMeasurements()
{
a();
int n = this.d.size();
int i;
int j;
if (n > 2)
{
i = n / 10;
j = n / 10;
i += 1;
j = n - j - 2;
}
for (;;)
{
int k = 0;
int m = i;
while (m <= j)
{
k += ((a)this.d.get(m)).a.intValue();
m += 1;
}
j = j - i + 1;
i = j;
if (j == 0) {
i = 1;
}
double d1 = k / i;
if (IBeaconManager.debug) {
new StringBuilder("Running average rssi based on ").append(n).append(" measurements: ").append(d1);
}
this.runningAverageRssi = Double.valueOf(d1);
if (IBeaconManager.debug) {
new StringBuilder("calculated new runningAverageRssi:").append(this.runningAverageRssi);
}
this.accuracy = null;
this.proximity = null;
return;
j = n - 1;
i = 0;
}
}
public boolean isTracked()
{
return this.c;
}
public boolean noMeasurementsAvailable()
{
return this.d.size() == 0;
}
public void setTracked(boolean paramBoolean)
{
this.c = paramBoolean;
}
final class a
implements Comparable<a>
{
Integer a;
long b;
private a() {}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/radiusnetworks/ibeacon/service/RangedIBeacon.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/