PushBeaconService.java
4.78 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
package com.arellomobile.android.push;
import android.annotation.TargetApi;
import android.app.Service;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.RemoteException;
import com.pushwoosh.support.v4.app.LocalBroadcastManager;
import com.radiusnetworks.ibeacon.IBeaconConsumer;
import com.radiusnetworks.ibeacon.IBeaconManager;
import com.radiusnetworks.ibeacon.MonitorNotifier;
import com.radiusnetworks.ibeacon.Region;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONObject;
@TargetApi(9)
public class PushBeaconService
extends Service
implements IBeaconConsumer, MonitorNotifier
{
public static final String BACKGROUND_MODE = "backgroundMode";
private static final Map<Region, Runnable> g = new ConcurrentHashMap();
private IBeaconManager a = IBeaconManager.getInstanceForApplication(this);
private JSONObject b;
private List<Region> c;
private Integer d;
private Handler e;
private HandlerThread f;
private static String a(Region paramRegion)
{
return "Region: " + paramRegion.getProximityUuid() + ", major: " + paramRegion.getMajor() + ", minor: " + paramRegion.getMinor();
}
public void didDetermineStateForRegion(int paramInt, Region paramRegion) {}
public void didEnterRegion(Region paramRegion)
{
PushManager.processBeacon(getApplicationContext(), paramRegion.getProximityUuid(), paramRegion.getMajor().toString(), null, "came");
Object localObject = new Intent("beacon");
((Intent)localObject).putExtra("Status", "Add " + a(paramRegion));
LocalBroadcastManager.getInstance(this).sendBroadcast((Intent)localObject);
if (this.d.intValue() > 0)
{
localObject = new b(paramRegion);
this.e.postDelayed((Runnable)localObject, this.d.intValue() * 1000);
g.put(paramRegion, localObject);
}
}
public void didExitRegion(Region paramRegion)
{
Object localObject = (Runnable)g.remove(paramRegion);
if (localObject != null) {
this.e.removeCallbacks((Runnable)localObject);
}
PushManager.processBeacon(getApplicationContext(), paramRegion.getProximityUuid(), paramRegion.getMajor().toString(), null, "cameout");
localObject = new Intent("beacon");
((Intent)localObject).putExtra("Status", "Remove " + a(paramRegion));
LocalBroadcastManager.getInstance(this).sendBroadcast((Intent)localObject);
}
public IBinder onBind(Intent paramIntent)
{
return null;
}
public void onCreate()
{
super.onCreate();
this.f = new HandlerThread(getPackageName());
this.f.start();
this.e = new Handler(this.f.getLooper());
}
public void onDestroy()
{
try
{
Iterator localIterator = this.c.iterator();
while (localIterator.hasNext())
{
Region localRegion = (Region)localIterator.next();
this.a.stopRangingBeaconsInRegion(localRegion);
this.e.removeCallbacks((Runnable)g.get(localRegion));
}
return;
}
catch (RemoteException localRemoteException)
{
this.f.quit();
this.a.unBind(this);
super.onDestroy();
}
}
public void onIBeaconServiceConnect()
{
this.a.setMonitorNotifier(this);
try
{
Iterator localIterator = this.c.iterator();
while (localIterator.hasNext())
{
Region localRegion = (Region)localIterator.next();
this.a.startMonitoringBeaconsInRegion(localRegion);
}
return;
}
catch (RemoteException localRemoteException) {}
}
public int onStartCommand(Intent paramIntent, int paramInt1, int paramInt2)
{
super.onStartCommand(paramIntent, paramInt1, paramInt2);
if (paramIntent.hasExtra("backgroundMode"))
{
this.a.setBackgroundMode(this, paramIntent.getBooleanExtra("backgroundMode", true));
return 1;
}
new a((byte)0).execute(new Void[0]);
return 1;
}
final class a
extends AsyncTask<Void, Void, JSONObject>
{
private a() {}
private JSONObject a()
{
try
{
JSONObject localJSONObject = DeviceFeature2_5.getBeacons(PushBeaconService.this);
return localJSONObject;
}
catch (Exception localException) {}
return new JSONObject();
}
}
final class b
implements Runnable
{
private Region b;
public b(Region paramRegion)
{
this.b = paramRegion;
}
public final void run()
{
PushBeaconService.a().remove(this.b);
PushBeaconService.a(PushBeaconService.this, this.b);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/arellomobile/android/push/PushBeaconService.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/