From 88d424c3b8c4569678c50a98521f8d09ef4c0177 Mon Sep 17 00:00:00 2001 From: Chuwei He Date: Thu, 31 Jul 2025 14:46:42 +0900 Subject: [PATCH] Change proto message name for NetworkConfigStoreProto This patch add *Proto suffix for some proto message in NetworkConfigStoreProto to avoid name conflicts with names in android.net package. Test: atest ConnectivityCoverageTests Bug: 397536853 Flag: EXEMPT mainline Change-Id: I4f826511bcab0fcd3b154bbc349a062fd4841321 --- service-t/src/proto/configstore.proto | 32 ++++++++-------- .../server/net/NetworkConfigStoreProtoTest.kt | 38 +++++++++++-------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/service-t/src/proto/configstore.proto b/service-t/src/proto/configstore.proto index 97ebebac20..f2bd0efcad 100644 --- a/service-t/src/proto/configstore.proto +++ b/service-t/src/proto/configstore.proto @@ -27,7 +27,7 @@ option java_package = "com.android.server.network.configstore.proto"; option java_outer_classname = "NetworkConfigStoreProto"; // Represents an IPv4 address along with its prefix length. -message LinkAddress { +message LinkAddressProto { // The string of the IPv4 address in the format of IPv4 address in dotted decimal notation, for // example "192.168.1.50". required string address = 1; @@ -36,9 +36,9 @@ message LinkAddress { } // Configuration for a static IPv4 assignment. -message StaticIpv4Configuration { +message StaticIpv4ConfigurationProto { // The IPv4 address and prefix length for the static IPv4 configuration. - required LinkAddress address = 1; + required LinkAddressProto address = 1; // The gateway IPv4 address as string in the format of IPv4 address in dotted decimal notation, // for example "192.168.1.100". optional string gateway = 2; @@ -50,7 +50,7 @@ message StaticIpv4Configuration { } // Manual configuration of the proxy server. -message ManualProxyConfig { +message ManualProxyConfigProto { // A list of hosts for which the proxy should not be used. repeated string exclusion_hosts = 1; // The hostname or IP address of the proxy server. @@ -60,32 +60,32 @@ message ManualProxyConfig { } // Configuration using a PAC (Proxy Auto-Configuration) script downloaded from a URL. -message PacUrlConfig { +message PacUrlConfigProto { // The URL of the Proxy Auto-Configuration (PAC) file. required string pac_url = 1; } // IP configuration for the interface. -message IpConfiguration { +message IpConfigurationProto { // IPv4 configuration of this interface. Making this an oneoff field because of the possibility // of adding DHCP IPv4 configuration in the future. oneof ipv4_configuration { // Static IPv4 configuration of this interface. DHCP is not used when a static configuration // exists. - StaticIpv4Configuration static_ipv4_config = 1; + StaticIpv4ConfigurationProto static_ipv4_config = 1; } // Proxy configuration to use for network connections on this interface, when not set, means // no proxy configuration is used. oneof proxy_config { // Manual proxy configuration. - ManualProxyConfig manual_proxy_config = 2; + ManualProxyConfigProto manual_proxy_config = 2; // PAC (Proxy Auto-Configuration) configuration. - PacUrlConfig pac_url_config = 3; + PacUrlConfigProto pac_url_config = 3; } } // Defines a selector to identify the ethernet port. -message EthernetPortSelector { +message EthernetPortSelectorProto { oneof identifier { // MAC address of this ethernet port. string mac_addr = 1; @@ -95,7 +95,7 @@ message EthernetPortSelector { } // Enum for metered override configuration. -enum MeteredOverride { +enum MeteredOverrideProto { // There is no metered override configuration. METERED_OVERRIDE_NONE = 0; // Forces the connection to be treated as metered. @@ -105,18 +105,18 @@ enum MeteredOverride { } // Defines the configuration of an ethernet interface. -message EthernetConfiguration { +message EthernetConfigurationProto { // Selector for applying this configuration to an Ethernet port, containing identifiable // information of related ethernet port. - required EthernetPortSelector selector = 1; + required EthernetPortSelectorProto selector = 1; // IP configuration of this ethernet interface. - required IpConfiguration ip_config = 2; + required IpConfigurationProto ip_config = 2; // Static metered override configuration, note that this is not the actual meteredness but // static configuration. - required MeteredOverride metered_override = 3; + required MeteredOverrideProto metered_override = 3; } // Defines the collective configuration states for all ethernet interfaces. message EthernetConfigHolderProto { - repeated EthernetConfiguration configs = 1; + repeated EthernetConfigurationProto configs = 1; } \ No newline at end of file diff --git a/tests/unit/java/com/android/server/net/NetworkConfigStoreProtoTest.kt b/tests/unit/java/com/android/server/net/NetworkConfigStoreProtoTest.kt index 2ceddb50e4..f890acf9a2 100644 --- a/tests/unit/java/com/android/server/net/NetworkConfigStoreProtoTest.kt +++ b/tests/unit/java/com/android/server/net/NetworkConfigStoreProtoTest.kt @@ -17,8 +17,14 @@ package com.android.server.net import androidx.test.filters.SmallTest -import com.android.server.network.configstore.proto.NetworkConfigStoreProto -import com.android.server.network.configstore.proto.NetworkConfigStoreProto.MeteredOverride +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.EthernetConfigHolderProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.EthernetConfigurationProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.EthernetPortSelectorProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.IpConfigurationProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.LinkAddressProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.ManualProxyConfigProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.MeteredOverrideProto +import com.android.server.network.configstore.proto.NetworkConfigStoreProto.StaticIpv4ConfigurationProto import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test @@ -49,12 +55,12 @@ class NetworkConfigStoreProtoTest { @Test fun testBuilder() { - val selector = NetworkConfigStoreProto.EthernetPortSelector.newBuilder().apply { + val selector = EthernetPortSelectorProto.newBuilder().apply { ifaceName = IFACE_NAME }.build() assertEquals(IFACE_NAME, selector.ifaceName) - val linkAddr = NetworkConfigStoreProto.LinkAddress.newBuilder().apply { + val linkAddr = LinkAddressProto.newBuilder().apply { address = ADDR prefixLength = PREFIX_LEN }.build() @@ -62,18 +68,18 @@ class NetworkConfigStoreProtoTest { assertEquals(PREFIX_LEN, linkAddr.prefixLength) val staticIpv4Configuration = - NetworkConfigStoreProto.StaticIpv4Configuration.newBuilder().apply { - address = linkAddr - gateway = GATEWAY - addDnsServers(DNS1) - addDnsServers(DNS2) - }.build() + StaticIpv4ConfigurationProto.newBuilder().apply { + setAddress(linkAddr) + gateway = GATEWAY + addDnsServers(DNS1) + addDnsServers(DNS2) + }.build() assertEquals(linkAddr, staticIpv4Configuration.address) assertEquals(GATEWAY, staticIpv4Configuration.gateway) assertEquals(DNS1, staticIpv4Configuration.getDnsServers(0)) assertEquals(DNS2, staticIpv4Configuration.getDnsServers(1)) - val manualProxy = NetworkConfigStoreProto.ManualProxyConfig.newBuilder().apply { + val manualProxy = ManualProxyConfigProto.newBuilder().apply { host = PROXY_HOST port = PROXY_PORT addExclusionHosts(EXCLUSION_LIST1) @@ -84,24 +90,24 @@ class NetworkConfigStoreProtoTest { assertEquals(EXCLUSION_LIST1, manualProxy.getExclusionHosts(0)) assertEquals(EXCLUSION_LIST2, manualProxy.getExclusionHosts(1)) - val ipConfig = NetworkConfigStoreProto.IpConfiguration.newBuilder().apply { + val ipConfig = IpConfigurationProto.newBuilder().apply { staticIpv4Config = staticIpv4Configuration manualProxyConfig = manualProxy }.build() assertEquals(staticIpv4Configuration, ipConfig.staticIpv4Config) assertEquals(manualProxy, ipConfig.manualProxyConfig) - val ethConfig = NetworkConfigStoreProto.EthernetConfiguration.newBuilder().apply { + val ethConfig = EthernetConfigurationProto.newBuilder().apply { setSelector(selector) setIpConfig(ipConfig) - meteredOverride = MeteredOverride.METERED_OVERRIDE_FORCE_METERED + meteredOverride = MeteredOverrideProto.METERED_OVERRIDE_FORCE_METERED }.build() assertEquals(selector, ethConfig.selector) assertEquals(ipConfig, ethConfig.ipConfig) - assertEquals(MeteredOverride.METERED_OVERRIDE_FORCE_METERED, ethConfig.meteredOverride) + assertEquals(MeteredOverrideProto.METERED_OVERRIDE_FORCE_METERED, ethConfig.meteredOverride) assertEquals(staticIpv4Configuration, ethConfig.ipConfig.staticIpv4Config) - val ethState = NetworkConfigStoreProto.EthernetConfigHolderProto.newBuilder().apply { + val ethState = EthernetConfigHolderProto.newBuilder().apply { addConfigs(ethConfig) }.build() assertEquals(ethConfig, ethState.getConfigs(0))