Merge "Tethering and Data Saver: There Can Be Only One!" into nyc-dev am: 5af619f am: 7f026f8

am: 33ec772

* commit '33ec77265a8e9e401a5915884c4d9ec2b6e5407a':
  Tethering and Data Saver: There Can Be Only One!

Change-Id: I184d03847abe86dd2f5e10c10bd12f90f7cc14d8
This commit is contained in:
Felipe Leme
2016-04-28 00:52:46 +00:00
committed by android-build-merger

View File

@@ -31,7 +31,6 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL;
import static android.net.NetworkPolicyManager.RULE_REJECT_ALL;
import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
import android.annotation.Nullable;
import android.app.BroadcastOptions;
import android.app.Notification;
@@ -1382,6 +1381,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (LOGD_RULES) {
log("onRestrictBackgroundChanged(restrictBackground=" + restrictBackground + ")");
}
if (restrictBackground) {
log("onRestrictBackgroundChanged(true): disabling tethering");
mTethering.untetherAll();
}
}
@Override
@@ -1816,6 +1819,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
pw.decreaseIndent();
pw.println();
pw.println("Metered Interfaces:");
pw.increaseIndent();
for (String value : mMeteredIfaces) {
pw.println(value);
}
pw.decreaseIndent();
pw.println();
pw.println("Network Requests:");
pw.increaseIndent();
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
@@ -2571,7 +2582,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
public int tether(String iface) {
ConnectivityManager.enforceTetherChangePermission(mContext);
if (isTetheringSupported()) {
return mTethering.tether(iface);
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;
}
@@ -2582,7 +2600,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
ConnectivityManager.enforceTetherChangePermission(mContext);
if (isTetheringSupported()) {
return mTethering.untether(iface);
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;
}