瀏覽代碼

Resolved IKEv2 transmitted and received bytes issue, refreshed bytes on each connection

Khubaib 8 月之前
父節點
當前提交
04a8316454
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

+ 6 - 1
app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

@@ -259,8 +259,12 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                     profile.setVpnType(VpnType.IKEV2_EAP);
                     profile.setName(server_name);
 
-                    startTrafficMonitoring();
+                    lastRxBytes = 0.0;
+                    lastTxBytes = 0.0;
+                    finalRxBytes = 0.0;
+                    finalTxBytes = 0.0;
 
+                    startTrafficMonitoring();
                     UiModeManager uiModeManager = (UiModeManager) getApplicationContext().getSystemService(UI_MODE_SERVICE);
                     List<String> splitList = Arrays.asList("All apps use the VPN", "Only allow selected apps to use the vpn",
                             "Do not allow selected apps to use the vpn");
@@ -371,6 +375,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
         double currentRxBytes = TrafficStats.getUidRxBytes(android.os.Process.myUid());
 
         Log.d("test_network_stat_IKev2", "MVT: currentTxBytes = " + currentTxBytes + " currentRxBytes = " + currentRxBytes);
+        Log.d("test_network_stat_semi", "lastTxBytes: " + lastTxBytes + " lastRxBytes: " + lastRxBytes + " finalTxBytes:" + finalTxBytes + " finalRxBytes:" + finalRxBytes);
 
         double txBytes = currentTxBytes - lastTxBytes;
         double rxBytes = currentRxBytes - lastRxBytes;