Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 783e0b74 authored by Christopher Wiley's avatar Christopher Wiley Committed by android-build-merger
Browse files

Merge "Notify NetworkPolicyManagerService on tethering changes" am: 4062bec0...

Merge "Notify NetworkPolicyManagerService on tethering changes" am: 4062bec0 am: 8d7e3b02 am: bf596f76
am: 9c933d43

Change-Id: I6075604795f97992d02bef28bb5cef85eb31d589
parents eb9ca553 9c933d43
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -816,7 +816,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);

@@ -3049,12 +3049,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;
@@ -3068,12 +3062,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;
+14 −1
Original line number Diff line number Diff line
@@ -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;
@@ -123,6 +125,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 {
@@ -177,10 +180,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();

@@ -1908,6 +1912,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: