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

Commit 4062bec0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Notify NetworkPolicyManagerService on tethering changes"

parents 4ad6291b d73faf07
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -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;
+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;
@@ -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: