Merge "Verify bypassability in the VPN network capabilities"
diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java
index 1f3fc11..c2cf92c 100644
--- a/Tethering/src/com/android/networkstack/tethering/Tethering.java
+++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java
@@ -477,17 +477,10 @@
wifiManager.registerSoftApCallback(mExecutor, softApCallback);
}
if (SdkLevel.isAtLeastT() && wifiManager != null) {
- try {
- // Although WifiManager#registerLocalOnlyHotspotSoftApCallback document that it need
- // NEARBY_WIFI_DEVICES permission, but actually a caller who have NETWORK_STACK
- // or MAINLINE_NETWORK_STACK permission would also able to use this API.
- wifiManager.registerLocalOnlyHotspotSoftApCallback(mExecutor, softApCallback);
- } catch (UnsupportedOperationException e) {
- // Since wifi module development in internal branch,
- // #registerLocalOnlyHotspotSoftApCallback currently doesn't supported in AOSP
- // before AOSP switch to Android T + 1.
- Log.wtf(TAG, "registerLocalOnlyHotspotSoftApCallback API is not supported");
- }
+ // Although WifiManager#registerLocalOnlyHotspotSoftApCallback document that it need
+ // NEARBY_WIFI_DEVICES permission, but actually a caller who have NETWORK_STACK
+ // or MAINLINE_NETWORK_STACK permission would also able to use this API.
+ wifiManager.registerLocalOnlyHotspotSoftApCallback(mExecutor, softApCallback);
}
startTrackDefaultNetwork();
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
index 8ef5d71..903de9d 100644
--- a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
+++ b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
@@ -22,6 +22,7 @@
import static android.net.ConnectivityManager.TYPE_MOBILE_DUN;
import static android.net.ConnectivityManager.TYPE_MOBILE_HIPRI;
import static android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY;
+import static android.provider.DeviceConfig.NAMESPACE_TETHERING;
import static com.android.net.module.util.DeviceConfigUtils.TETHERING_MODULE_NAME;
import static com.android.networkstack.apishim.ConstantsShim.KEY_CARRIER_SUPPORTS_TETHERING_BOOL;
@@ -193,8 +194,13 @@
isDunRequired = checkDunRequired(ctx);
- final boolean forceAutomaticUpstream = !SdkLevel.isAtLeastS()
- && isFeatureEnabled(ctx, TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION);
+ // Here is how automatic mode enable/disable support on different Android version:
+ // - R : can be enabled/disabled by resource config_tether_upstream_automatic.
+ // but can be force-enabled by flag TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION.
+ // - S, T: can be enabled/disabled by resource config_tether_upstream_automatic.
+ // - U+ : automatic mode only.
+ final boolean forceAutomaticUpstream = SdkLevel.isAtLeastU() || (!SdkLevel.isAtLeastS()
+ && isConnectivityFeatureEnabled(ctx, TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION));
chooseUpstreamAutomatically = forceAutomaticUpstream || getResourceBoolean(
res, R.bool.config_tether_upstream_automatic, false /** defaultValue */);
preferredUpstreamIfaceTypes = getUpstreamIfaceTypes(res, isDunRequired);
@@ -565,9 +571,23 @@
return DeviceConfig.getProperty(NAMESPACE_CONNECTIVITY, name);
}
+ /**
+ * This is deprecated because connectivity namespace already be used for NetworkStack mainline
+ * module. Tethering should use its own namespace to roll out the feature flag.
+ * @deprecated new caller should use isTetheringFeatureEnabled instead.
+ */
+ @Deprecated
+ private boolean isConnectivityFeatureEnabled(Context ctx, String featureVersionFlag) {
+ return isFeatureEnabled(ctx, NAMESPACE_CONNECTIVITY, featureVersionFlag);
+ }
+
+ private boolean isTetheringFeatureEnabled(Context ctx, String featureVersionFlag) {
+ return isFeatureEnabled(ctx, NAMESPACE_TETHERING, featureVersionFlag);
+ }
+
@VisibleForTesting
- protected boolean isFeatureEnabled(Context ctx, String featureVersionFlag) {
- return DeviceConfigUtils.isFeatureEnabled(ctx, NAMESPACE_CONNECTIVITY, featureVersionFlag,
+ protected boolean isFeatureEnabled(Context ctx, String namespace, String featureVersionFlag) {
+ return DeviceConfigUtils.isFeatureEnabled(ctx, namespace, featureVersionFlag,
TETHERING_MODULE_NAME, false /* defaultEnabled */);
}
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/FakeTetheringConfiguration.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/FakeTetheringConfiguration.java
index 95ec38f..0d686ed 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/FakeTetheringConfiguration.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/FakeTetheringConfiguration.java
@@ -33,7 +33,7 @@
}
@Override
- protected boolean isFeatureEnabled(Context ctx, String featureVersionFlag) {
+ protected boolean isFeatureEnabled(Context ctx, String namespace, String featureVersionFlag) {
return false;
}
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
index 1a12125..f662c02 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringConfigurationTest.java
@@ -545,7 +545,8 @@
assertTrue(testCfg.shouldEnableWifiP2pDedicatedIp());
}
- @Test
+ // The config only works on T-
+ @Test @IgnoreAfter(Build.VERSION_CODES.TIRAMISU)
public void testChooseUpstreamAutomatically() throws Exception {
when(mResources.getBoolean(R.bool.config_tether_upstream_automatic))
.thenReturn(true);
@@ -556,6 +557,20 @@
assertChooseUpstreamAutomaticallyIs(false);
}
+ // The automatic mode is always enabled on U+
+ @Test @IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
+ public void testChooseUpstreamAutomaticallyAfterT() throws Exception {
+ // Expect that automatic mode is always enabled no matter what
+ // config_tether_upstream_automatic is.
+ when(mResources.getBoolean(R.bool.config_tether_upstream_automatic))
+ .thenReturn(true);
+ assertChooseUpstreamAutomaticallyIs(true);
+
+ when(mResources.getBoolean(R.bool.config_tether_upstream_automatic))
+ .thenReturn(false);
+ assertChooseUpstreamAutomaticallyIs(true);
+ }
+
// The flag override only works on R-
@Test @IgnoreAfter(Build.VERSION_CODES.R)
public void testChooseUpstreamAutomatically_FlagOverride() throws Exception {
@@ -574,14 +589,34 @@
assertChooseUpstreamAutomaticallyIs(false);
}
- @Test @IgnoreUpTo(Build.VERSION_CODES.R)
- public void testChooseUpstreamAutomatically_FlagOverrideAfterR() throws Exception {
+ @Test @IgnoreUpTo(Build.VERSION_CODES.R) @IgnoreAfter(Build.VERSION_CODES.TIRAMISU)
+ public void testChooseUpstreamAutomatically_FlagOverrideOnSAndT() throws Exception {
when(mResources.getBoolean(R.bool.config_tether_upstream_automatic))
.thenReturn(false);
setTetherForceUpstreamAutomaticFlagVersion(TEST_PACKAGE_VERSION - 1);
assertChooseUpstreamAutomaticallyIs(false);
}
+ // The automatic mode is always enabled on U+
+ @Test @IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
+ public void testChooseUpstreamAutomatically_FlagOverrideAfterT() throws Exception {
+ // Expect that automatic mode is always enabled no matter what
+ // TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION is.
+ when(mResources.getBoolean(R.bool.config_tether_upstream_automatic))
+ .thenReturn(false);
+ setTetherForceUpstreamAutomaticFlagVersion(TEST_PACKAGE_VERSION - 1);
+ assertTrue(DeviceConfigUtils.isFeatureEnabled(mMockContext, NAMESPACE_CONNECTIVITY,
+ TetheringConfiguration.TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION, APEX_NAME, false));
+
+ assertChooseUpstreamAutomaticallyIs(true);
+
+ setTetherForceUpstreamAutomaticFlagVersion(0L);
+ assertChooseUpstreamAutomaticallyIs(true);
+
+ setTetherForceUpstreamAutomaticFlagVersion(Long.MAX_VALUE);
+ assertChooseUpstreamAutomaticallyIs(true);
+ }
+
private void setTetherForceUpstreamAutomaticFlagVersion(Long version) {
doReturn(version == null ? null : Long.toString(version)).when(
() -> DeviceConfig.getProperty(eq(NAMESPACE_CONNECTIVITY),
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
index 9337b1a..a8d886b 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/TetheringTest.java
@@ -196,6 +196,7 @@
import com.android.networkstack.tethering.TestConnectivityManager.TestNetworkAgent;
import com.android.networkstack.tethering.metrics.TetheringMetrics;
import com.android.testutils.DevSdkIgnoreRule;
+import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter;
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
import com.android.testutils.MiscAsserts;
@@ -1212,13 +1213,12 @@
inOrder.verify(mUpstreamNetworkMonitor).setCurrentUpstream(wifi.networkId);
}
- @Test
- public void testAutomaticUpstreamSelection() throws Exception {
+ private void verifyAutomaticUpstreamSelection(boolean configAutomatic) throws Exception {
TestNetworkAgent mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
TestNetworkAgent wifi = new TestNetworkAgent(mCm, buildWifiUpstreamState());
InOrder inOrder = inOrder(mCm, mUpstreamNetworkMonitor);
// Enable automatic upstream selection.
- upstreamSelectionTestCommon(true, inOrder, mobile, wifi);
+ upstreamSelectionTestCommon(configAutomatic, inOrder, mobile, wifi);
// This code has historically been racy, so test different orderings of CONNECTIVITY_ACTION
// broadcasts and callbacks, and add mLooper.dispatchAll() calls between the two.
@@ -1298,6 +1298,20 @@
}
@Test
+ public void testAutomaticUpstreamSelection() throws Exception {
+ verifyAutomaticUpstreamSelection(true /* configAutomatic */);
+ }
+
+ @Test
+ @IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
+ public void testAutomaticUpstreamSelectionWithConfigDisabled() throws Exception {
+ // Expect that automatic config can't disable the automatic mode because automatic mode
+ // is always enabled on U+ device.
+ verifyAutomaticUpstreamSelection(false /* configAutomatic */);
+ }
+
+ @Test
+ @IgnoreAfter(Build.VERSION_CODES.TIRAMISU)
public void testLegacyUpstreamSelection() throws Exception {
TestNetworkAgent mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
TestNetworkAgent wifi = new TestNetworkAgent(mCm, buildWifiUpstreamState());
@@ -1323,14 +1337,13 @@
verifyDisableTryCellWhenTetheringStop(inOrder);
}
- @Test
- public void testChooseDunUpstreamByAutomaticMode() throws Exception {
+ private void verifyChooseDunUpstreamByAutomaticMode(boolean configAutomatic) throws Exception {
// Enable automatic upstream selection.
TestNetworkAgent mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
TestNetworkAgent wifi = new TestNetworkAgent(mCm, buildWifiUpstreamState());
TestNetworkAgent dun = new TestNetworkAgent(mCm, buildDunUpstreamState());
InOrder inOrder = inOrder(mCm, mUpstreamNetworkMonitor);
- chooseDunUpstreamTestCommon(true, inOrder, mobile, wifi, dun);
+ chooseDunUpstreamTestCommon(configAutomatic, inOrder, mobile, wifi, dun);
// When default network switch to mobile and wifi is connected (may have low signal),
// automatic mode would request dun again and choose it as upstream.
@@ -1359,6 +1372,18 @@
}
@Test
+ public void testChooseDunUpstreamByAutomaticMode() throws Exception {
+ verifyChooseDunUpstreamByAutomaticMode(true /* configAutomatic */);
+ }
+
+ @Test
+ @IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
+ public void testChooseDunUpstreamByAutomaticModeWithConfigDisabled() throws Exception {
+ verifyChooseDunUpstreamByAutomaticMode(false /* configAutomatic */);
+ }
+
+ @Test
+ @IgnoreAfter(Build.VERSION_CODES.TIRAMISU)
public void testChooseDunUpstreamByLegacyMode() throws Exception {
// Enable Legacy upstream selection.
TestNetworkAgent mobile = new TestNetworkAgent(mCm, buildMobileDualStackUpstreamState());
diff --git a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
index edf04b2..f6a55c8 100644
--- a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
+++ b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java
@@ -289,7 +289,7 @@
enforceAdminPermission(iface, false, "enableInterface()");
- mTracker.enableInterface(iface, new EthernetCallback(cb));
+ mTracker.setInterfaceEnabled(iface, true /* enabled */, new EthernetCallback(cb));
}
@Override
@@ -301,7 +301,7 @@
enforceAdminPermission(iface, false, "disableInterface()");
- mTracker.disableInterface(iface, new EthernetCallback(cb));
+ mTracker.setInterfaceEnabled(iface, false /* enabled */, new EthernetCallback(cb));
}
@Override
diff --git a/service-t/src/com/android/server/ethernet/EthernetTracker.java b/service-t/src/com/android/server/ethernet/EthernetTracker.java
index 95baf81..852cf42 100644
--- a/service-t/src/com/android/server/ethernet/EthernetTracker.java
+++ b/service-t/src/com/android/server/ethernet/EthernetTracker.java
@@ -371,15 +371,9 @@
}
@VisibleForTesting(visibility = PACKAGE)
- protected void enableInterface(@NonNull final String iface,
+ protected void setInterfaceEnabled(@NonNull final String iface, boolean enabled,
@Nullable final EthernetCallback cb) {
- mHandler.post(() -> updateInterfaceState(iface, true, cb));
- }
-
- @VisibleForTesting(visibility = PACKAGE)
- protected void disableInterface(@NonNull final String iface,
- @Nullable final EthernetCallback cb) {
- mHandler.post(() -> updateInterfaceState(iface, false, cb));
+ mHandler.post(() -> updateInterfaceState(iface, enabled, cb));
}
IpConfiguration getIpConfiguration(String iface) {
diff --git a/service/Android.bp b/service/Android.bp
index 326f91b..691c1ad 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -178,7 +178,10 @@
"networkstack-client",
"PlatformProperties",
"service-connectivity-protos",
- "service-connectivity-stats-protos",
+ // TODO: Adding the stats protos currently affects test coverage.
+ // So remove the protos in ConnectivityService until all
+ // tests for proto apis are added.
+ //"service-connectivity-stats-protos",
"NetworkStackApiStableShims",
],
apex_available: [
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index fd219d2..f796ecc 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -2378,8 +2378,9 @@
super.expectAvailableCallbacks(network, false /* suspended */, true /* validated */,
BLOCKED_REASON_NONE, NETWORK_CALLBACK_TIMEOUT_MS);
}
- public void expectBlockedStatusCallback(Network network, int blockedStatus) {
- super.expectBlockedStatusCallback(blockedStatus, network, NETWORK_CALLBACK_TIMEOUT_MS);
+ public void eventuallyExpectBlockedStatusCallback(Network network, int blockedStatus) {
+ super.eventuallyExpect(CallbackEntry.BLOCKED_STATUS_INT, NETWORK_CALLBACK_TIMEOUT_MS,
+ (it) -> it.getNetwork().equals(network) && it.getBlocked() == blockedStatus);
}
public void onBlockedStatusChanged(Network network, int blockedReasons) {
getHistory().add(new CallbackEntry.BlockedStatusInt(network, blockedReasons));
@@ -2424,12 +2425,14 @@
final Range<Integer> otherUidRange = new Range<>(otherUid, otherUid);
setRequireVpnForUids(true, List.of(myUidRange));
- myUidCallback.expectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_LOCKDOWN_VPN);
+ myUidCallback.eventuallyExpectBlockedStatusCallback(defaultNetwork,
+ BLOCKED_REASON_LOCKDOWN_VPN);
otherUidCallback.assertNoBlockedStatusCallback();
setRequireVpnForUids(true, List.of(myUidRange, otherUidRange));
myUidCallback.assertNoBlockedStatusCallback();
- otherUidCallback.expectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_LOCKDOWN_VPN);
+ otherUidCallback.eventuallyExpectBlockedStatusCallback(defaultNetwork,
+ BLOCKED_REASON_LOCKDOWN_VPN);
// setRequireVpnForUids does no deduplication or refcounting. Removing myUidRange does not
// unblock myUid because it was added to the blocked ranges twice.
@@ -2438,8 +2441,8 @@
otherUidCallback.assertNoBlockedStatusCallback();
setRequireVpnForUids(false, List.of(myUidRange, otherUidRange));
- myUidCallback.expectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_NONE);
- otherUidCallback.expectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_NONE);
+ myUidCallback.eventuallyExpectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_NONE);
+ otherUidCallback.eventuallyExpectBlockedStatusCallback(defaultNetwork, BLOCKED_REASON_NONE);
myUidCallback.assertNoBlockedStatusCallback();
otherUidCallback.assertNoBlockedStatusCallback();
diff --git a/tests/cts/net/src/android/net/cts/TestUtils.java b/tests/cts/net/src/android/net/cts/TestUtils.java
index 001aa01..6180845 100644
--- a/tests/cts/net/src/android/net/cts/TestUtils.java
+++ b/tests/cts/net/src/android/net/cts/TestUtils.java
@@ -16,8 +16,6 @@
package android.net.cts;
-import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
-
import android.os.Build;
import com.android.modules.utils.build.SdkLevel;
@@ -37,11 +35,18 @@
}
/**
- * Whether to test T+ APIs. This requires a) that the test be running on an S+ device, and
+ * Whether to test T+ APIs. This requires a) that the test be running on an T+ device, and
* b) that the code be compiled against shims new enough to access these APIs.
*/
public static boolean shouldTestTApis() {
- // TODO: replace SC_V2 with Build.VERSION_CODES.S_V2 when it's available in mainline branch.
- return SdkLevel.isAtLeastT() && ConstantsShim.VERSION > SC_V2;
+ return SdkLevel.isAtLeastT() && ConstantsShim.VERSION > Build.VERSION_CODES.S_V2;
+ }
+
+ /**
+ * Whether to test U+ APIs. This requires a) that the test be running on an U+ device, and
+ * b) that the code be compiled against shims new enough to access these APIs.
+ */
+ public static boolean shouldTestUApis() {
+ return SdkLevel.isAtLeastU() && ConstantsShim.VERSION > Build.VERSION_CODES.TIRAMISU;
}
}
diff --git a/tests/unit/java/com/android/server/ethernet/EthernetServiceImplTest.java b/tests/unit/java/com/android/server/ethernet/EthernetServiceImplTest.java
index 9bf893a..de0af94 100644
--- a/tests/unit/java/com/android/server/ethernet/EthernetServiceImplTest.java
+++ b/tests/unit/java/com/android/server/ethernet/EthernetServiceImplTest.java
@@ -312,14 +312,15 @@
@Test
public void testEnableInterface() {
mEthernetServiceImpl.enableInterface(TEST_IFACE, NULL_LISTENER);
- verify(mEthernetTracker).enableInterface(eq(TEST_IFACE),
+ verify(mEthernetTracker).setInterfaceEnabled(eq(TEST_IFACE), eq(true),
any(EthernetCallback.class));
}
@Test
public void testDisableInterface() {
mEthernetServiceImpl.disableInterface(TEST_IFACE, NULL_LISTENER);
- verify(mEthernetTracker).disableInterface(eq(TEST_IFACE), any(EthernetCallback.class));
+ verify(mEthernetTracker).setInterfaceEnabled(eq(TEST_IFACE), eq(false),
+ any(EthernetCallback.class));
}
@Test
@@ -384,7 +385,7 @@
denyManageEthPermission();
mEthernetServiceImpl.enableInterface(TEST_IFACE, NULL_LISTENER);
- verify(mEthernetTracker).enableInterface(eq(TEST_IFACE),
+ verify(mEthernetTracker).setInterfaceEnabled(eq(TEST_IFACE), eq(true),
any(EthernetCallback.class));
}
@@ -395,7 +396,7 @@
denyManageEthPermission();
mEthernetServiceImpl.disableInterface(TEST_IFACE, NULL_LISTENER);
- verify(mEthernetTracker).disableInterface(eq(TEST_IFACE),
+ verify(mEthernetTracker).setInterfaceEnabled(eq(TEST_IFACE), eq(false),
any(EthernetCallback.class));
}
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 62afa61..376b8f1 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1727,12 +1727,14 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -1772,12 +1774,14 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -1812,12 +1816,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
"buildtools/third_party/libc++/",
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -4376,6 +4382,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -4385,6 +4392,7 @@
"buildtools/third_party/libc++abi/trunk/include",
"third_party/abseil-cpp/",
"third_party/boringssl/src/include/",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
@@ -6779,6 +6787,7 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-UANDROID",
],
local_include_dirs: [
"./",
@@ -6786,6 +6795,7 @@
"buildtools/third_party/libc++/trunk/include",
"buildtools/third_party/libc++abi/trunk/include",
"third_party/zlib/",
+ "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
"build/linux/debian_bullseye_amd64-sysroot/usr/include",
],
cpp_std: "c++20",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 4bd2479..2644e43 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -1048,6 +1048,11 @@
cflags = {flag for flag in target.cflags if re.match(cflag_allowlist, flag)}
# Consider proper allowlist or denylist if needed
cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in target.defines)
+ # -DANDROID is added by default but target.defines contain -DANDROID if it's required.
+ # So adding -UANDROID to cancel default -DANDROID if it's not specified.
+ # This is needed for some targets(e.g. symbolize)
+ if "ANDROID" not in target.defines:
+ cflags.add("-UANDROID")
return cflags
@@ -1153,7 +1158,10 @@
# include. So adding sysroot include at the end.
for flag in target.cflags:
if '--sysroot' in flag:
- module.local_include_dirs.append(flag[len('--sysroot=../../'):] + "/usr/include")
+ sysroot = flag[len('--sysroot=../../'):]
+ if sysroot == "build/linux/debian_bullseye_amd64-sysroot":
+ module.local_include_dirs.append(sysroot + "/usr/include/x86_64-linux-gnu")
+ module.local_include_dirs.append(sysroot + "/usr/include")
module_is_compiled = module.type not in ('genrule', 'filegroup')
if module_is_compiled: