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

Commit 8d7b6fe6 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Remove deps from framework on netd interfaces

If included in framework.jar, the interfaces conflict with any app that
needs to depend on them, including the NetworkStack.

(cherry-pick of aosp/903220 with trivial conflict in Android.bp)

Bug: 124033493
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I0ecae20d514bf888f3a80331f19369ceb1c52aa3
parent c8aca4b1
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.net.shared.ProvisioningConfiguration;
import android.net.util.InterfaceParams;
import android.net.util.SharedLog;
import android.os.ConditionVariable;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -380,6 +381,13 @@ public class IpClient extends StateMachine {
        public InterfaceParams getInterfaceParams(String ifname) {
            return InterfaceParams.getByName(ifname);
        }

        /**
         * Get a INetd connector.
         */
        public INetd getNetd(Context context) {
            return INetd.Stub.asInterface((IBinder) context.getSystemService(Context.NETD_SERVICE));
        }
    }

    public IpClient(Context context, String ifName, IIpClientCallbacks callback,
@@ -413,7 +421,7 @@ public class IpClient extends StateMachine {

        // TODO: Consider creating, constructing, and passing in some kind of
        // InterfaceController.Dependencies class.
        mNetd = mContext.getSystemService(INetd.class);
        mNetd = deps.getNetd(mContext);
        mInterfaceCtrl = new InterfaceController(mInterfaceName, mNetd, mLog);

        mLinkObserver = new IpClientLinkObserver(
+2 −1
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ public class NetworkStackService extends Service {

        NetworkStackConnector(Context context) {
            mContext = context;
            mNetd = (INetd) context.getSystemService(Context.NETD_SERVICE);
            mNetd = INetd.Stub.asInterface(
                    (IBinder) context.getSystemService(Context.NETD_SERVICE));
            mObserverRegistry = new NetworkObserverRegistry();
            mCm = context.getSystemService(ConnectivityManager.class);

+1 −1
Original line number Diff line number Diff line
@@ -104,8 +104,8 @@ public class IpClientTest {

        when(mContext.getSystemService(eq(Context.ALARM_SERVICE))).thenReturn(mAlarm);
        when(mContext.getSystemService(eq(ConnectivityManager.class))).thenReturn(mCm);
        when(mContext.getSystemService(INetd.class)).thenReturn(mNetd);
        when(mContext.getResources()).thenReturn(mResources);
        when(mDependencies.getNetd(any())).thenReturn(mNetd);
        when(mResources.getInteger(R.integer.config_networkAvoidBadWifi))
                .thenReturn(DEFAULT_AVOIDBADWIFI_CONFIG_VALUE);