summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java14
-rw-r--r--services/core/java/com/android/server/connectivity/Tethering.java15
2 files changed, 15 insertions, 14 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index b383633b06ed..f16376dfd348 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -760,7 +760,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mTestMode = SystemProperties.get("cm.test.mode").equals("true")
&& SystemProperties.get("ro.build.type").equals("eng");
- mTethering = new Tethering(mContext, mNetd, statsService);
+ mTethering = new Tethering(mContext, mNetd, statsService, mPolicyManager);
mPermissionMonitor = new PermissionMonitor(mContext, mNetd);
@@ -2688,12 +2688,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
ConnectivityManager.enforceTetherChangePermission(mContext);
if (isTetheringSupported()) {
final int status = mTethering.tether(iface);
- if (status == ConnectivityManager.TETHER_ERROR_NO_ERROR) {
- try {
- mPolicyManager.onTetheringChanged(iface, true);
- } catch (RemoteException e) {
- }
- }
return status;
} else {
return ConnectivityManager.TETHER_ERROR_UNSUPPORTED;
@@ -2706,12 +2700,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (isTetheringSupported()) {
final int status = mTethering.untether(iface);
- if (status == ConnectivityManager.TETHER_ERROR_NO_ERROR) {
- try {
- mPolicyManager.onTetheringChanged(iface, false);
- } catch (RemoteException e) {
- }
- }
return status;
} else {
return ConnectivityManager.TETHER_ERROR_UNSUPPORTED;
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index e9b66902d491..95d830df0a16 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -33,6 +33,7 @@ import android.content.res.Resources;
import android.hardware.usb.UsbManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
+import android.net.INetworkPolicyManager;
import android.net.INetworkStatsService;
import android.net.LinkProperties;
import android.net.Network;
@@ -49,6 +50,7 @@ import android.os.INetworkManagementService;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
+import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.SystemProperties;
import android.os.UserHandle;
@@ -122,6 +124,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
private final INetworkManagementService mNMService;
private final INetworkStatsService mStatsService;
+ private final INetworkPolicyManager mPolicyManager;
private final Looper mLooper;
private static class TetherState {
@@ -176,10 +179,11 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
private boolean mWifiTetherRequested;
public Tethering(Context context, INetworkManagementService nmService,
- INetworkStatsService statsService) {
+ INetworkStatsService statsService, INetworkPolicyManager policyManager) {
mContext = context;
mNMService = nmService;
mStatsService = statsService;
+ mPolicyManager = policyManager;
mPublicSync = new Object();
@@ -1755,6 +1759,15 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
" with error " + error);
}
+ try {
+ // Notify that we're tethering (or not) this interface.
+ // This is how data saver for instance knows if the user explicitly
+ // turned on tethering (thus keeping us from being in data saver mode).
+ mPolicyManager.onTetheringChanged(iface, state == IControlsTethering.STATE_TETHERED);
+ } catch (RemoteException e) {
+ // Not really very much we can do here.
+ }
+
switch (state) {
case IControlsTethering.STATE_UNAVAILABLE:
case IControlsTethering.STATE_AVAILABLE: