summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/connectivity/Tethering.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-09-22 14:59:51 -0700
committerJeff Sharkey <jsharkey@android.com>2011-09-22 16:19:06 -0700
commit367d15ab1a33b6159447fa8542d4fa8ff148371c (patch)
treeef079cca799aa0e2c68f9a158cfd0a1d533cc253 /services/java/com/android/server/connectivity/Tethering.java
parent745f1e3a06eb504c9e4465afc987854a6269220d (diff)
Watch network subtype, tethering teardown, empty.
Watch for changes to telephony network subtype, and update iface mapping to persist stats under correct type. Update network stats before removing tethering NAT rules. Skip recording that would create empty historical buckets. Query UID stats before iface stats to always skew positive when counters are actively rolling forward. Bug: 5360042, 5359860, 5335674, 5334448 Change-Id: I8aa37b568e8ffb70647218aa1aff5195d3e44d5a
Diffstat (limited to 'services/java/com/android/server/connectivity/Tethering.java')
-rw-r--r--services/java/com/android/server/connectivity/Tethering.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 10f6d2ccdc5f..6b9c08852124 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -29,6 +29,7 @@ import android.hardware.usb.UsbManager;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.net.INetworkManagementEventObserver;
+import android.net.INetworkStatsService;
import android.net.InterfaceConfiguration;
import android.net.LinkAddress;
import android.net.LinkProperties;
@@ -88,7 +89,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
// upstream type list and the DUN_REQUIRED secure-setting
private int mPreferredUpstreamMobileApn = ConnectivityManager.TYPE_NONE;
- private INetworkManagementService mNMService;
+ private final INetworkManagementService mNMService;
+ private final INetworkStatsService mStatsService;
private Looper mLooper;
private HandlerThread mThread;
@@ -124,9 +126,11 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
private boolean mUsbTetherRequested; // true if USB tethering should be started
// when RNDIS is enabled
- public Tethering(Context context, INetworkManagementService nmService, Looper looper) {
+ public Tethering(Context context, INetworkManagementService nmService,
+ INetworkStatsService statsService, Looper looper) {
mContext = context;
mNMService = nmService;
+ mStatsService = statsService;
mLooper = looper;
mIfaces = new HashMap<String, TetherInterfaceSM>();
@@ -913,6 +917,9 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
case CMD_INTERFACE_DOWN:
if (mMyUpstreamIfaceName != null) {
try {
+ // about to tear down NAT; gather remaining statistics
+ mStatsService.forceUpdate();
+
mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
mMyUpstreamIfaceName = null;
} catch (Exception e) {
@@ -957,6 +964,9 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
}
if (mMyUpstreamIfaceName != null) {
try {
+ // about to tear down NAT; gather remaining statistics
+ mStatsService.forceUpdate();
+
mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
mMyUpstreamIfaceName = null;
} catch (Exception e) {
@@ -995,6 +1005,9 @@ public class Tethering extends INetworkManagementEventObserver.Stub {
case CMD_TETHER_MODE_DEAD:
if (mMyUpstreamIfaceName != null) {
try {
+ // about to tear down NAT; gather remaining statistics
+ mStatsService.forceUpdate();
+
mNMService.disableNat(mIfaceName, mMyUpstreamIfaceName);
mMyUpstreamIfaceName = null;
} catch (Exception e) {