summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/OpenVPNStatusService.java16
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/StatusListener.java4
2 files changed, 15 insertions, 5 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNStatusService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNStatusService.java
index 3d3dd6b1..29f4ddaa 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNStatusService.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNStatusService.java
@@ -66,6 +66,9 @@ public class OpenVPNStatusService extends Service implements VpnStatus.LogListen
@Override
public ParcelFileDescriptor registerStatusCallback(IStatusCallbacks cb) throws RemoteException {
final LogItem[] logbuffer = VpnStatus.getlogbuffer();
+ if (mLastUpdateMessage != null)
+ sendUpdate(cb, mLastUpdateMessage);
+
mCallbacks.register(cb);
try {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
@@ -137,13 +140,15 @@ public class OpenVPNStatusService extends Service implements VpnStatus.LogListen
msg.sendToTarget();
}
- class UpdateMessage {
+ static UpdateMessage mLastUpdateMessage;
+
+ static class UpdateMessage {
public String state;
public String logmessage;
public ConnectionStatus level;
- public int resId;
+ int resId;
- public UpdateMessage(String state, String logmessage, int resId, ConnectionStatus level) {
+ UpdateMessage(String state, String logmessage, int resId, ConnectionStatus level) {
this.state = state;
this.resId = resId;
this.logmessage = logmessage;
@@ -155,7 +160,8 @@ public class OpenVPNStatusService extends Service implements VpnStatus.LogListen
@Override
public void updateState(String state, String logmessage, int localizedResId, ConnectionStatus level) {
- Message msg = mHandler.obtainMessage(SEND_NEW_STATE, new UpdateMessage(state, logmessage, localizedResId, level));
+ mLastUpdateMessage = new UpdateMessage(state, logmessage, localizedResId, level);
+ Message msg = mHandler.obtainMessage(SEND_NEW_STATE, mLastUpdateMessage);
msg.sendToTarget();
}
@@ -198,7 +204,7 @@ public class OpenVPNStatusService extends Service implements VpnStatus.LogListen
broadcastItem.newLogItem((LogItem) msg.obj);
break;
case SEND_NEW_BYTECOUNT:
- Pair<Long, Long> inout = (Pair<Long, Long>) msg.obj;
+ Pair<Long, Long> inout = (Pair<Long, Long>) msg.obj;
broadcastItem.updateByteCount(inout.first, inout.second);
break;
case SEND_NEW_STATE:
diff --git a/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java b/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java
index e79bdadd..16d580b7 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java
@@ -34,6 +34,7 @@ public class StatusListener {
try {
/* Check if this a local service ... */
if (service.queryLocalInterface("de.blinkt.openvpn.core.IServiceStatus") == null) {
+ // Not a local service
VpnStatus.setConnectedVPNProfile(serviceStatus.getLastConnectedVPN());
ParcelFileDescriptor pfd = serviceStatus.registerStatusCallback(mCallback);
DataInputStream fd = new DataInputStream(new ParcelFileDescriptor.AutoCloseInputStream(pfd));
@@ -47,6 +48,9 @@ public class StatusListener {
len = fd.readShort();
}
fd.close();
+
+
+
} else {
VpnStatus.initLogCache(mCacheDir);
}