Merge "Notify NetworkPolicyManagerService on tethering changes" am: 4062bec04e

am: 8d7e3b0205

Change-Id: I9595856421a848a570f4894fa55523a72a7fec44
This commit is contained in:
Christopher Wiley
2016-09-27 13:32:06 +00:00
committed by android-build-merger
2 changed files with 15 additions and 14 deletions

View File

@@ -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;

View File

@@ -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: