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

Commit 15eaa7ac authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Remove aidl wrappers for framework parcelables

The new @JavaOnlyStableParcelable annotation allows using the framework
parcelables directly, which removes a lot of boilerplate.

Includes new copy constructors for IpPrefix and LinkAddress so they can
be copied easily as-is into parcelables.

Test: atest FrameworksNetTests
Test: booted, WiFi works
Bug: 126477266

Change-Id: Icac8afe498d0b5ebf9a0d0b9eceb14d64a29b381
parent ff5b1c04
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package android.net.ip;

import static android.net.RouteInfo.RTN_UNICAST;
import static android.net.shared.IpConfigurationParcelableUtil.toStableParcelable;
import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;
import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable;

import static com.android.server.util.PermissionUtil.checkNetworkStackCallingPermission;

@@ -33,7 +31,6 @@ import android.net.LinkAddress;
import android.net.LinkProperties;
import android.net.ProvisioningConfigurationParcelable;
import android.net.ProxyInfo;
import android.net.ProxyInfoParcelable;
import android.net.RouteInfo;
import android.net.TcpKeepalivePacketDataParcelable;
import android.net.apf.ApfCapabilities;
@@ -201,7 +198,7 @@ public class IpClient extends StateMachine {
        public void onProvisioningSuccess(LinkProperties newLp) {
            log("onProvisioningSuccess({" + newLp + "})");
            try {
                mCallback.onProvisioningSuccess(toStableParcelable(newLp));
                mCallback.onProvisioningSuccess(newLp);
            } catch (RemoteException e) {
                log("Failed to call onProvisioningSuccess", e);
            }
@@ -210,7 +207,7 @@ public class IpClient extends StateMachine {
        public void onProvisioningFailure(LinkProperties newLp) {
            log("onProvisioningFailure({" + newLp + "})");
            try {
                mCallback.onProvisioningFailure(toStableParcelable(newLp));
                mCallback.onProvisioningFailure(newLp);
            } catch (RemoteException e) {
                log("Failed to call onProvisioningFailure", e);
            }
@@ -219,7 +216,7 @@ public class IpClient extends StateMachine {
        public void onLinkPropertiesChange(LinkProperties newLp) {
            log("onLinkPropertiesChange({" + newLp + "})");
            try {
                mCallback.onLinkPropertiesChange(toStableParcelable(newLp));
                mCallback.onLinkPropertiesChange(newLp);
            } catch (RemoteException e) {
                log("Failed to call onLinkPropertiesChange", e);
            }
@@ -525,9 +522,9 @@ public class IpClient extends StateMachine {
            IpClient.this.setTcpBufferSizes(tcpBufferSizes);
        }
        @Override
        public void setHttpProxy(ProxyInfoParcelable proxyInfo) {
        public void setHttpProxy(ProxyInfo proxyInfo) {
            checkNetworkStackCallingPermission();
            IpClient.this.setHttpProxy(fromStableParcelable(proxyInfo));
            IpClient.this.setHttpProxy(proxyInfo);
        }
        @Override
        public void setMulticastFilter(boolean enabled) {
+3 −9
Original line number Diff line number Diff line
@@ -16,13 +16,10 @@

package android.net.ip;

import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.eq;
@@ -207,8 +204,7 @@ public class IpClientTest {
        verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
        verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
        verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
                .onLinkPropertiesChange(argThat(
                        lp -> fromStableParcelable(lp).equals(makeEmptyLinkProperties(iface))));
                .onLinkPropertiesChange(makeEmptyLinkProperties(iface));
    }

    @Test
@@ -253,15 +249,13 @@ public class IpClientTest {
        mObserver.onInterfaceAddressUpdated(new LinkAddress(addresses[lastAddr]), iface);
        LinkProperties want = linkproperties(links(addresses), routes(prefixes));
        want.setInterfaceName(iface);
        verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).onProvisioningSuccess(argThat(
                lp -> fromStableParcelable(lp).equals(want)));
        verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).onProvisioningSuccess(want);

        ipc.shutdown();
        verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
        verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
        verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
                .onLinkPropertiesChange(argThat(
                        lp -> fromStableParcelable(lp).equals(makeEmptyLinkProperties(iface))));
                .onLinkPropertiesChange(makeEmptyLinkProperties(iface));
    }

    @Test