Merge "TetheringTest: test upstream changes capabilities"
diff --git a/Cronet/tests/common/Android.bp b/Cronet/tests/common/Android.bp
new file mode 100644
index 0000000..1ed0881
--- /dev/null
+++ b/Cronet/tests/common/Android.bp
@@ -0,0 +1,39 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// Tests in this folder are included both in unit tests and CTS.
+// They must be fast and stable, and exercise public or test APIs.
+
+package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+// TODO: Consider merging with ConnectivityCoverageTests which is a collection of all
+// Connectivity tests being used for coverage. This will depend on how far we decide to
+// go with merging NetHttp and Tethering targets.
+android_test {
+ name: "NetHttpCoverageTests",
+ defaults: ["CronetTestJavaDefaults"],
+ sdk_version: "test_current",
+ test_suites: ["general-tests", "mts-tethering"],
+ static_libs: [
+ "modules-utils-native-coverage-listener",
+ "CtsNetHttpTestsLib",
+ "NetHttpTestsLibPreJarJar",
+ ],
+ jarjar_rules: ":framework-tethering-jarjar-rules",
+ compile_multilib: "both",
+}
diff --git a/Cronet/tests/common/AndroidManifest.xml b/Cronet/tests/common/AndroidManifest.xml
new file mode 100644
index 0000000..efe880c
--- /dev/null
+++ b/Cronet/tests/common/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.android.net.http.tests.coverage">
+ <!-- NetHttpCoverageTests combines CtsNetHttpTestCases and NetHttpTests targets,
+ so permissions and others are declared in their respective manifests -->
+ <application tools:replace="android:label"
+ android:label="NetHttp coverage tests">
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.net.http.tests.coverage"
+ android:label="NetHttp coverage tests">
+ </instrumentation>
+</manifest>
diff --git a/Cronet/tests/common/AndroidTest.xml b/Cronet/tests/common/AndroidTest.xml
new file mode 100644
index 0000000..ca298dd
--- /dev/null
+++ b/Cronet/tests/common/AndroidTest.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Runs coverage tests for NetHttp">
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="test-file-name" value="NetHttpCoverageTests.apk" />
+ <option name="install-arg" value="-t" />
+ </target_preparer>
+ <option name="test-tag" value="NetHttpCoverageTests" />
+ <!-- Tethering/Connectivity is a SDK 30+ module -->
+ <object type="module_controller"
+ class="com.android.tradefed.testtype.suite.module.Sdk30ModuleController" />
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.net.http.tests.coverage" />
+ <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+ <option name="hidden-api-checks" value="false"/>
+ <option
+ name="device-listeners"
+ value="com.android.modules.utils.testing.NativeCoverageHackInstrumentationListener" />
+ </test>
+</configuration>
diff --git a/Cronet/tests/cts/Android.bp b/Cronet/tests/cts/Android.bp
index 2c28b8d..9a5ed89 100644
--- a/Cronet/tests/cts/Android.bp
+++ b/Cronet/tests/cts/Android.bp
@@ -41,13 +41,8 @@
defaults: [cronet_test_java_defaults],
}
-android_test {
- name: "CtsNetHttpTestCases",
- compile_multilib: "both", // Include both the 32 and 64 bit versions
- defaults: [
- "CronetTestJavaDefaults",
- "cts_defaults",
- ],
+android_library {
+ name: "CtsNetHttpTestsLib",
sdk_version: "test_current",
srcs: [
"src/**/*.java",
@@ -69,7 +64,17 @@
"framework-tethering",
"org.apache.http.legacy",
],
+}
+android_test {
+ name: "CtsNetHttpTestCases",
+ defaults: [
+ "cts_defaults",
+ "CronetTestJavaDefaults",
+ ],
+ sdk_version: "test_current",
+ compile_multilib: "both", // Include both the 32 and 64 bit versions
+ static_libs: ["CtsNetHttpTestsLib"],
// Tag this as a cts test artifact
test_suites: [
"cts",
diff --git a/Cronet/tests/cts/src/android/net/http/cts/HttpEngineTest.java b/Cronet/tests/cts/src/android/net/http/cts/HttpEngineTest.java
index 6a8467c..8663a67 100644
--- a/Cronet/tests/cts/src/android/net/http/cts/HttpEngineTest.java
+++ b/Cronet/tests/cts/src/android/net/http/cts/HttpEngineTest.java
@@ -17,6 +17,7 @@
package android.net.http.cts;
import static android.net.http.cts.util.TestUtilsKt.assertOKStatusCode;
+import static android.net.http.cts.util.TestUtilsKt.assumeOKStatusCode;
import static android.net.http.cts.util.TestUtilsKt.skipIfNoInternetConnection;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -46,6 +47,7 @@
private HttpEngine.Builder mEngineBuilder;
private TestUrlRequestCallback mCallback;
+ private UrlRequest mRequest;
private HttpEngine mEngine;
@Before
@@ -58,6 +60,10 @@
@After
public void tearDown() throws Exception {
+ if (mRequest != null) {
+ mRequest.cancel();
+ mCallback.blockForDone();
+ }
if (mEngine != null) {
mEngine.shutdown();
}
@@ -72,9 +78,12 @@
mEngine = mEngineBuilder.build();
UrlRequest.Builder builder =
mEngine.newUrlRequestBuilder(URL, mCallback, mCallback.getExecutor());
- builder.build().start();
+ mRequest = builder.build();
+ mRequest.start();
- mCallback.expectCallback(ResponseStep.ON_SUCCEEDED);
+ // This tests uses a non-hermetic server. Instead of asserting, assume the next callback.
+ // This way, if the request were to fail, the test would just be skipped instead of failing.
+ mCallback.assumeCallback(ResponseStep.ON_SUCCEEDED);
UrlResponseInfo info = mCallback.mResponseInfo;
assertOKStatusCode(info);
assertEquals("h2", info.getNegotiatedProtocol());
@@ -85,9 +94,12 @@
mEngine = mEngineBuilder.setEnableHttp2(false).build();
UrlRequest.Builder builder =
mEngine.newUrlRequestBuilder(URL, mCallback, mCallback.getExecutor());
- builder.build().start();
+ mRequest = builder.build();
+ mRequest.start();
- mCallback.expectCallback(ResponseStep.ON_SUCCEEDED);
+ // This tests uses a non-hermetic server. Instead of asserting, assume the next callback.
+ // This way, if the request were to fail, the test would just be skipped instead of failing.
+ mCallback.assumeCallback(ResponseStep.ON_SUCCEEDED);
UrlResponseInfo info = mCallback.mResponseInfo;
assertOKStatusCode(info);
assertEquals("http/1.1", info.getNegotiatedProtocol());
@@ -100,13 +112,18 @@
// We send multiple requests to reduce the flakiness of the test.
boolean quicWasUsed = false;
for (int i = 0; i < 5; i++) {
+ mCallback = new TestUrlRequestCallback();
UrlRequest.Builder builder =
mEngine.newUrlRequestBuilder(URL, mCallback, mCallback.getExecutor());
- builder.build().start();
+ mRequest = builder.build();
+ mRequest.start();
- mCallback.expectCallback(ResponseStep.ON_SUCCEEDED);
+ // This tests uses a non-hermetic server. Instead of asserting, assume the next
+ // callback. This way, if the request were to fail, the test would just be skipped
+ // instead of failing.
+ mCallback.assumeCallback(ResponseStep.ON_SUCCEEDED);
UrlResponseInfo info = mCallback.mResponseInfo;
- assertOKStatusCode(info);
+ assumeOKStatusCode(info);
quicWasUsed = isQuic(info.getNegotiatedProtocol());
if (quicWasUsed) {
break;
diff --git a/Cronet/tests/cts/src/android/net/http/cts/UrlRequestTest.java b/Cronet/tests/cts/src/android/net/http/cts/UrlRequestTest.java
index d7d3679..5256bae 100644
--- a/Cronet/tests/cts/src/android/net/http/cts/UrlRequestTest.java
+++ b/Cronet/tests/cts/src/android/net/http/cts/UrlRequestTest.java
@@ -21,6 +21,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
import android.content.Context;
import android.net.http.HttpEngine;
@@ -29,6 +31,7 @@
import android.net.http.UrlResponseInfo;
import android.net.http.cts.util.HttpCtsTestServer;
import android.net.http.cts.util.TestStatusListener;
+import android.net.http.cts.util.TestUploadDataProvider;
import android.net.http.cts.util.TestUrlRequestCallback;
import android.net.http.cts.util.TestUrlRequestCallback.ResponseStep;
@@ -66,14 +69,14 @@
}
}
- private UrlRequest buildUrlRequest(String url) {
- return mHttpEngine.newUrlRequestBuilder(url, mCallback, mCallback.getExecutor()).build();
+ private UrlRequest.Builder createUrlRequestBuilder(String url) {
+ return mHttpEngine.newUrlRequestBuilder(url, mCallback, mCallback.getExecutor());
}
@Test
public void testUrlRequestGet_CompletesSuccessfully() throws Exception {
String url = mTestServer.getSuccessUrl();
- UrlRequest request = buildUrlRequest(url);
+ UrlRequest request = createUrlRequestBuilder(url).build();
request.start();
mCallback.expectCallback(ResponseStep.ON_SUCCEEDED);
@@ -84,11 +87,48 @@
@Test
public void testUrlRequestStatus_InvalidBeforeRequestStarts() throws Exception {
- UrlRequest request = buildUrlRequest(mTestServer.getSuccessUrl());
+ UrlRequest request = createUrlRequestBuilder(mTestServer.getSuccessUrl()).build();
// Calling before request is started should give Status.INVALID,
// since the native adapter is not created.
TestStatusListener statusListener = new TestStatusListener();
request.getStatus(statusListener);
statusListener.expectStatus(Status.INVALID);
}
+
+ @Test
+ public void testUrlRequestCancel_CancelCalled() throws Exception {
+ UrlRequest request = createUrlRequestBuilder(mTestServer.getSuccessUrl()).build();
+ mCallback.setAutoAdvance(false);
+
+ request.start();
+ mCallback.waitForNextStep();
+ assertSame(mCallback.mResponseStep, ResponseStep.ON_RESPONSE_STARTED);
+
+ request.cancel();
+ mCallback.expectCallback(ResponseStep.ON_CANCELED);
+ }
+
+ @Test
+ public void testUrlRequestPost_EchoRequestBody() throws Exception {
+ String testData = "test";
+ UrlRequest.Builder builder = createUrlRequestBuilder(mTestServer.getEchoBodyUrl());
+
+ TestUploadDataProvider dataProvider = new TestUploadDataProvider(
+ TestUploadDataProvider.SuccessCallbackMode.SYNC, mCallback.getExecutor());
+ dataProvider.addRead(testData.getBytes());
+ builder.setUploadDataProvider(dataProvider, mCallback.getExecutor());
+ builder.addHeader("Content-Type", "text/html");
+ builder.build().start();
+ mCallback.expectCallback(ResponseStep.ON_SUCCEEDED);
+
+ assertOKStatusCode(mCallback.mResponseInfo);
+ assertEquals(testData, mCallback.mResponseAsString);
+ dataProvider.assertClosed();
+ }
+
+ @Test
+ public void testUrlRequestFail_FailedCalled() throws Exception {
+ createUrlRequestBuilder("http://0.0.0.0:0/").build().start();
+ mCallback.expectCallback(ResponseStep.ON_FAILED);
+ }
}
diff --git a/Cronet/tests/cts/src/android/net/http/cts/util/HttpCtsTestServer.kt b/Cronet/tests/cts/src/android/net/http/cts/util/HttpCtsTestServer.kt
index 87d5108..5196544 100644
--- a/Cronet/tests/cts/src/android/net/http/cts/util/HttpCtsTestServer.kt
+++ b/Cronet/tests/cts/src/android/net/http/cts/util/HttpCtsTestServer.kt
@@ -18,9 +18,40 @@
import android.content.Context
import android.webkit.cts.CtsTestServer
+import java.net.URI
+import org.apache.http.HttpEntityEnclosingRequest
+import org.apache.http.HttpRequest
+import org.apache.http.HttpResponse
+import org.apache.http.HttpStatus
+import org.apache.http.HttpVersion
+import org.apache.http.message.BasicHttpResponse
+
+private const val ECHO_BODY_PATH = "/echo_body"
/** Extends CtsTestServer to handle POST requests and other test specific requests */
class HttpCtsTestServer(context: Context) : CtsTestServer(context) {
+ val echoBodyUrl: String = baseUri + ECHO_BODY_PATH
val successUrl: String = getAssetUrl("html/hello_world.html")
+
+ override fun onPost(req: HttpRequest): HttpResponse? {
+ val path = URI.create(req.requestLine.uri).path
+ var response: HttpResponse? = null
+
+ if (path.startsWith(ECHO_BODY_PATH)) {
+ if (req !is HttpEntityEnclosingRequest) {
+ return BasicHttpResponse(
+ HttpVersion.HTTP_1_0,
+ HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ "Expected req to be of type HttpEntityEnclosingRequest but got ${req.javaClass}"
+ )
+ }
+
+ response = BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, null)
+ response.entity = req.entity
+ response.addHeader("Content-Length", req.entity.contentLength.toString())
+ }
+
+ return response
+ }
}
diff --git a/Cronet/tests/cts/src/android/net/http/cts/util/TestUrlRequestCallback.java b/Cronet/tests/cts/src/android/net/http/cts/util/TestUrlRequestCallback.java
index 0b9e90f..fc4912c 100644
--- a/Cronet/tests/cts/src/android/net/http/cts/util/TestUrlRequestCallback.java
+++ b/Cronet/tests/cts/src/android/net/http/cts/util/TestUrlRequestCallback.java
@@ -16,6 +16,7 @@
package android.net.http.cts.util;
+import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -23,6 +24,8 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeThat;
+import static org.junit.Assume.assumeTrue;
import android.net.http.CallbackException;
import android.net.http.HttpException;
@@ -232,6 +235,19 @@
}
/**
+ * Waits for a terminal callback to complete execution before skipping the test if the
+ * callback is not the expected one
+ *
+ * @param expectedStep the expected callback step
+ */
+ public void assumeCallback(ResponseStep expectedStep) {
+ if (isTerminalCallback(expectedStep)) {
+ assumeTrue("Did not receive terminal callback before timeout", blockForDone());
+ }
+ assumeThat(expectedStep, equalTo(mResponseStep));
+ }
+
+ /**
* Blocks the calling thread until one of the final states has been called.
* This is called before the callback has finished executed.
*/
diff --git a/Cronet/tests/cts/src/android/net/http/cts/util/TestUtils.kt b/Cronet/tests/cts/src/android/net/http/cts/util/TestUtils.kt
index d30c059..23ec2c8 100644
--- a/Cronet/tests/cts/src/android/net/http/cts/util/TestUtils.kt
+++ b/Cronet/tests/cts/src/android/net/http/cts/util/TestUtils.kt
@@ -19,8 +19,10 @@
import android.content.Context
import android.net.ConnectivityManager
import android.net.http.UrlResponseInfo
+import org.hamcrest.Matchers.equalTo
import org.junit.Assert.assertEquals
import org.junit.Assume.assumeNotNull
+import org.junit.Assume.assumeThat
fun skipIfNoInternetConnection(context: Context) {
val connectivityManager = context.getSystemService(ConnectivityManager::class.java)
@@ -29,5 +31,9 @@
}
fun assertOKStatusCode(info: UrlResponseInfo) {
- assertEquals("Status code must be 200 OK", 200, info.getHttpStatusCode())
+ assertEquals("Status code must be 200 OK", 200, info.httpStatusCode)
+}
+
+fun assumeOKStatusCode(info: UrlResponseInfo) {
+ assumeThat("Status code must be 200 OK", info.getHttpStatusCode(), equalTo(200))
}
diff --git a/Cronet/tests/mts/Android.bp b/Cronet/tests/mts/Android.bp
new file mode 100644
index 0000000..cfafc5b
--- /dev/null
+++ b/Cronet/tests/mts/Android.bp
@@ -0,0 +1,49 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_library {
+ name: "NetHttpTestsLibPreJarJar",
+ srcs: [":cronet_aml_javatests_sources"],
+ static_libs: [
+ "androidx.test.ext.junit",
+ "androidx.test.rules",
+ "junit",
+ ],
+ libs: [
+ "android.test.base",
+ "framework-tethering-pre-jarjar",
+ ]
+}
+
+android_test {
+ name: "NetHttpTests",
+ defaults: [
+ "CronetTestJavaDefaults",
+ "mts-target-sdk-version-current",
+ ],
+ compile_multilib: "both",
+ sdk_version: "test_current",
+ static_libs: ["NetHttpTestsLibPreJarJar"],
+ jarjar_rules: ":framework-tethering-jarjar-rules",
+ test_suites: [
+ "general-tests",
+ "mts-tethering",
+ ],
+}
+
diff --git a/Cronet/tests/mts/AndroidManifest.xml b/Cronet/tests/mts/AndroidManifest.xml
new file mode 100644
index 0000000..62c2060
--- /dev/null
+++ b/Cronet/tests/mts/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.net.http.mts">
+
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.INTERNET"/>
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.net.http.mts"
+ android:label="MTS tests of android.net.http">
+ </instrumentation>
+
+</manifest>
\ No newline at end of file
diff --git a/Cronet/tests/mts/AndroidTest.xml b/Cronet/tests/mts/AndroidTest.xml
new file mode 100644
index 0000000..8cb549e
--- /dev/null
+++ b/Cronet/tests/mts/AndroidTest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<configuration description="Runs NetHttp Mainline Tests.">
+ <!-- Only run tests if the device under test is SDK version 30 or above. -->
+ <object type="module_controller"
+ class="com.android.tradefed.testtype.suite.module.Sdk30ModuleController" />
+
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="test-file-name" value="NetHttpTests.apk" />
+ </target_preparer>
+
+ <option name="test-tag" value="NetHttpTests" />
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.net.http.mts" />
+ <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+ <option name="hidden-api-checks" value="false"/>
+ </test>
+
+ <!-- Only run NetHttpTests in MTS if the Tethering Mainline module is installed. -->
+ <object type="module_controller"
+ class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+ <option name="mainline-module-package-name" value="com.google.android.tethering" />
+ </object>
+</configuration>
\ No newline at end of file
diff --git a/TEST_MAPPING b/TEST_MAPPING
index a1e81c8..34646e2 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -102,6 +102,11 @@
},
{
"name": "FrameworksNetDeflakeTest"
+ },
+ // Run in postsubmit to confirm test passes continously since this is a new test setup
+ // TODO: move tests to presubmit
+ {
+ "name": "NetHttpTests"
}
],
"mainline-presubmit": [
diff --git a/Tethering/apex/Android.bp b/Tethering/apex/Android.bp
index b26911c..67206cd 100644
--- a/Tethering/apex/Android.bp
+++ b/Tethering/apex/Android.bp
@@ -144,7 +144,6 @@
compat_configs: [
"connectivity-platform-compat-config",
- "connectivity-t-platform-compat-config",
],
}
diff --git a/Tethering/common/TetheringLib/cronet_enabled/api/current.txt b/Tethering/common/TetheringLib/cronet_enabled/api/current.txt
index c0157b7..c1af24a 100644
--- a/Tethering/common/TetheringLib/cronet_enabled/api/current.txt
+++ b/Tethering/common/TetheringLib/cronet_enabled/api/current.txt
@@ -31,7 +31,7 @@
public abstract class HttpEngine {
method public abstract java.net.URLStreamHandlerFactory createURLStreamHandlerFactory();
- method public abstract String getVersionString();
+ method public static String getVersionString();
method public abstract android.net.http.UrlRequest.Builder newUrlRequestBuilder(String, android.net.http.UrlRequest.Callback, java.util.concurrent.Executor);
method public abstract java.net.URLConnection openConnection(java.net.URL) throws java.io.IOException;
method public abstract void shutdown();
diff --git a/framework-t/Android.bp b/framework-t/Android.bp
index d40fad9..7ef20c5 100644
--- a/framework-t/Android.bp
+++ b/framework-t/Android.bp
@@ -164,6 +164,7 @@
],
}
+// This rule is not used anymore(b/268440216).
platform_compat_config {
name: "connectivity-t-platform-compat-config",
src: ":framework-connectivity-t",
diff --git a/framework-t/api/current.txt b/framework-t/api/current.txt
index 5532853..86745d4 100644
--- a/framework-t/api/current.txt
+++ b/framework-t/api/current.txt
@@ -228,8 +228,8 @@
}
public static interface NsdManager.ResolveListener {
+ method public default void onResolutionStopped(@NonNull android.net.nsd.NsdServiceInfo);
method public void onResolveFailed(android.net.nsd.NsdServiceInfo, int);
- method public default void onResolveStopped(@NonNull android.net.nsd.NsdServiceInfo);
method public void onServiceResolved(android.net.nsd.NsdServiceInfo);
method public default void onStopResolutionFailed(@NonNull android.net.nsd.NsdServiceInfo, int);
}
diff --git a/framework-t/src/android/net/NetworkTemplate.java b/framework-t/src/android/net/NetworkTemplate.java
index f633a8f..748b1ba 100644
--- a/framework-t/src/android/net/NetworkTemplate.java
+++ b/framework-t/src/android/net/NetworkTemplate.java
@@ -383,8 +383,9 @@
@Override
public int hashCode() {
- return Objects.hash(mMatchRule, Arrays.hashCode(mMatchWifiNetworkKeys),
- mMetered, mRoaming, mDefaultNetwork, mRatType, mOemManaged);
+ return Objects.hash(mMatchRule, Arrays.hashCode(mMatchSubscriberIds),
+ Arrays.hashCode(mMatchWifiNetworkKeys), mMetered, mRoaming, mDefaultNetwork,
+ mRatType, mOemManaged);
}
@Override
@@ -397,6 +398,7 @@
&& mDefaultNetwork == other.mDefaultNetwork
&& mRatType == other.mRatType
&& mOemManaged == other.mOemManaged
+ && Arrays.equals(mMatchSubscriberIds, other.mMatchSubscriberIds)
&& Arrays.equals(mMatchWifiNetworkKeys, other.mMatchWifiNetworkKeys);
}
return false;
diff --git a/framework-t/src/android/net/nsd/NsdManager.java b/framework-t/src/android/net/nsd/NsdManager.java
index 122e3a0..b4f8897 100644
--- a/framework-t/src/android/net/nsd/NsdManager.java
+++ b/framework-t/src/android/net/nsd/NsdManager.java
@@ -16,6 +16,8 @@
package android.net.nsd;
+import static android.net.connectivity.ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER;
+
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -24,8 +26,6 @@
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemService;
import android.app.compat.CompatChanges;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledSince;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
@@ -137,28 +137,6 @@
private static final boolean DBG = false;
/**
- * When enabled, apps targeting < Android 12 are considered legacy for
- * the NSD native daemon.
- * The platform will only keep the daemon running as long as there are
- * any legacy apps connected.
- *
- * After Android 12, direct communication with the native daemon might not work since the native
- * daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
- * recommended.
- * Another alternative could be bundling your own mdns solutions instead of
- * depending on the system mdns native daemon.
- *
- * This compatibility change applies to Android 13 and later only. To toggle behavior on
- * Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
- *
- * @hide
- */
- @ChangeId
- @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
- // This was a platform change ID with value 191844585L before T
- public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
-
- /**
* Broadcast intent action to indicate whether network service discovery is
* enabled or disabled. An extra {@link #EXTRA_NSD_STATE} provides the state
* information as int.
@@ -767,18 +745,18 @@
* Called on the internal thread or with an executor passed to
* {@link NsdManager#resolveService} to report the resolution was stopped.
*
- * A stop resolution operation would call either onResolveStopped or onStopResolutionFailed
- * once based on the result.
+ * A stop resolution operation would call either onResolutionStopped or
+ * onStopResolutionFailed once based on the result.
*/
- default void onResolveStopped(@NonNull NsdServiceInfo serviceInfo) { }
+ default void onResolutionStopped(@NonNull NsdServiceInfo serviceInfo) { }
/**
* Called once on the internal thread or with an executor passed to
* {@link NsdManager#resolveService} to report that stopping resolution failed with an
* error.
*
- * A stop resolution operation would call either onResolveStopped or onStopResolutionFailed
- * once based on the result.
+ * A stop resolution operation would call either onResolutionStopped or
+ * onStopResolutionFailed once based on the result.
*/
default void onStopResolutionFailed(@NonNull NsdServiceInfo serviceInfo,
@StopOperationFailureCode int errorCode) { }
@@ -929,7 +907,7 @@
break;
case STOP_RESOLUTION_SUCCEEDED:
removeListener(key);
- executor.execute(() -> ((ResolveListener) listener).onResolveStopped(
+ executor.execute(() -> ((ResolveListener) listener).onResolutionStopped(
ns));
break;
case REGISTER_SERVICE_CALLBACK_FAILED:
@@ -1301,7 +1279,7 @@
/**
* Stop service resolution initiated with {@link #resolveService}.
*
- * A successful stop is notified with a call to {@link ResolveListener#onResolveStopped}.
+ * A successful stop is notified with a call to {@link ResolveListener#onResolutionStopped}.
*
* <p> Upon failure to stop service resolution for example if resolution is done or the
* requester stops resolution repeatedly, the application is notified
diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java
index 4224da9..79c94ab 100644
--- a/framework/src/android/net/ConnectivityManager.java
+++ b/framework/src/android/net/ConnectivityManager.java
@@ -1502,6 +1502,22 @@
}
/**
+ * Temporarily set automaticOnOff keeplaive TCP polling alarm timer to 1 second.
+ *
+ * TODO: Remove this when the TCP polling design is replaced with callback.
+ * @param timeMs The time of expiry, with System.currentTimeMillis() base. The value should be
+ * set no more than 5 minutes in the future.
+ * @hide
+ */
+ public void setTestLowTcpPollingTimerForKeepalive(long timeMs) {
+ try {
+ mService.setTestLowTcpPollingTimerForKeepalive(timeMs);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Informs ConnectivityService of whether the legacy lockdown VPN, as implemented by
* LockdownVpnTracker, is in use. This is deprecated for new devices starting from Android 12
* but is still supported for backwards compatibility.
@@ -2213,9 +2229,13 @@
/** The requested keepalive was successfully started. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onStarted() {}
+ /** The keepalive was resumed after being paused by the system. */
+ public void onResumed() {}
/** The keepalive was successfully stopped. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onStopped() {}
+ /** The keepalive was paused automatically by the system. */
+ public void onPaused() {}
/** An error occurred. */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onError(int error) {}
@@ -2279,23 +2299,12 @@
private final ISocketKeepaliveCallback mCallback;
private final ExecutorService mExecutor;
- private volatile Integer mSlot;
-
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void stop() {
try {
mExecutor.execute(() -> {
try {
- if (mSlot != null) {
- // TODO : this is incorrect, because in the presence of auto on/off
- // keepalive the slot associated with this keepalive can have
- // changed. Also, this actually causes another problem where some other
- // app might stop your keepalive if it just knows the network and
- // the slot and goes through the trouble of grabbing the aidl object.
- // This code should use the callback to identify what keepalive to
- // stop instead.
- mService.stopKeepalive(mNetwork, mSlot);
- }
+ mService.stopKeepalive(mCallback);
} catch (RemoteException e) {
Log.e(TAG, "Error stopping packet keepalive: ", e);
throw e.rethrowFromSystemServer();
@@ -2313,11 +2322,10 @@
mExecutor = Executors.newSingleThreadExecutor();
mCallback = new ISocketKeepaliveCallback.Stub() {
@Override
- public void onStarted(int slot) {
+ public void onStarted() {
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
- mSlot = slot;
callback.onStarted();
});
} finally {
@@ -2326,11 +2334,22 @@
}
@Override
+ public void onResumed() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(() -> {
+ callback.onResumed();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public void onStopped() {
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
- mSlot = null;
callback.onStopped();
});
} finally {
@@ -2340,11 +2359,23 @@
}
@Override
+ public void onPaused() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(() -> {
+ callback.onPaused();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ mExecutor.shutdown();
+ }
+
+ @Override
public void onError(int error) {
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
- mSlot = null;
callback.onError(error);
});
} finally {
diff --git a/framework/src/android/net/IConnectivityManager.aidl b/framework/src/android/net/IConnectivityManager.aidl
index 7db231e..c8f588d 100644
--- a/framework/src/android/net/IConnectivityManager.aidl
+++ b/framework/src/android/net/IConnectivityManager.aidl
@@ -193,7 +193,7 @@
void startTcpKeepalive(in Network network, in ParcelFileDescriptor pfd, int intervalSeconds,
in ISocketKeepaliveCallback cb);
- void stopKeepalive(in Network network, int slot);
+ void stopKeepalive(in ISocketKeepaliveCallback cb);
String getCaptivePortalServerUrl();
@@ -251,4 +251,6 @@
IBinder getCompanionDeviceManagerProxyService();
void setVpnNetworkPreference(String session, in UidRange[] ranges);
+
+ void setTestLowTcpPollingTimerForKeepalive(long timeMs);
}
diff --git a/framework/src/android/net/ISocketKeepaliveCallback.aidl b/framework/src/android/net/ISocketKeepaliveCallback.aidl
index 020fbca..0a1de6c 100644
--- a/framework/src/android/net/ISocketKeepaliveCallback.aidl
+++ b/framework/src/android/net/ISocketKeepaliveCallback.aidl
@@ -24,11 +24,15 @@
oneway interface ISocketKeepaliveCallback
{
/** The keepalive was successfully started. */
- void onStarted(int slot);
+ void onStarted();
/** The keepalive was successfully stopped. */
void onStopped();
/** The keepalive was stopped because of an error. */
void onError(int error);
/** The keepalive on a TCP socket was stopped because the socket received data. */
void onDataReceived();
+ /** The keepalive was paused by the system because it's not necessary right now. */
+ void onPaused();
+ /** The keepalive was resumed by the system after being suspended. */
+ void onResumed();
}
diff --git a/framework/src/android/net/LinkProperties.java b/framework/src/android/net/LinkProperties.java
index b7ee846..e0926e9 100644
--- a/framework/src/android/net/LinkProperties.java
+++ b/framework/src/android/net/LinkProperties.java
@@ -16,19 +16,18 @@
package android.net;
+import static android.net.connectivity.ConnectivityCompatChanges.EXCLUDED_ROUTES;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.compat.CompatChanges;
-import android.compat.annotation.ChangeId;
-import android.compat.annotation.EnabledAfter;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
-import com.android.internal.annotations.VisibleForTesting;
import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.LinkPropertiesUtils;
@@ -58,17 +57,6 @@
*
*/
public final class LinkProperties implements Parcelable {
- /**
- * The {@link #getRoutes()} now can contain excluded as well as included routes. Use
- * {@link RouteInfo#getType()} to determine route type.
- *
- * @hide
- */
- @ChangeId
- @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
- @VisibleForTesting
- public static final long EXCLUDED_ROUTES = 186082280;
-
// The interface described by the network link.
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
private String mIfaceName;
diff --git a/framework/src/android/net/NattSocketKeepalive.java b/framework/src/android/net/NattSocketKeepalive.java
index 4d45e70..77137f4 100644
--- a/framework/src/android/net/NattSocketKeepalive.java
+++ b/framework/src/android/net/NattSocketKeepalive.java
@@ -91,9 +91,7 @@
protected void stopImpl() {
mExecutor.execute(() -> {
try {
- if (mSlot != null) {
- mService.stopKeepalive(mNetwork, mSlot);
- }
+ mService.stopKeepalive(mCallback);
} catch (RemoteException e) {
Log.e(TAG, "Error stopping socket keepalive: ", e);
throw e.rethrowFromSystemServer();
diff --git a/framework/src/android/net/NetworkAgent.java b/framework/src/android/net/NetworkAgent.java
index 62e4fe1..8fe20de 100644
--- a/framework/src/android/net/NetworkAgent.java
+++ b/framework/src/android/net/NetworkAgent.java
@@ -291,7 +291,9 @@
/**
* Requests that the specified keepalive packet be stopped.
*
- * arg1 = hardware slot number of the keepalive to stop.
+ * arg1 = unused
+ * arg2 = error code (SUCCESS)
+ * obj = callback to identify the keepalive
*
* Also used internally by ConnectivityService / KeepaliveTracker, with different semantics.
* @hide
@@ -491,7 +493,7 @@
* TCP sockets are open over a VPN. The system will check periodically for presence of
* such open sockets, and this message is what triggers the re-evaluation.
*
- * obj = AutomaticOnOffKeepaliveObject.
+ * obj = A Binder object associated with the keepalive.
* @hide
*/
public static final int CMD_MONITOR_AUTOMATIC_KEEPALIVE = BASE + 30;
diff --git a/framework/src/android/net/SocketKeepalive.java b/framework/src/android/net/SocketKeepalive.java
index 90e5e9b..00104f6 100644
--- a/framework/src/android/net/SocketKeepalive.java
+++ b/framework/src/android/net/SocketKeepalive.java
@@ -21,7 +21,6 @@
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Binder;
import android.os.ParcelFileDescriptor;
@@ -65,6 +64,12 @@
public static final int SUCCESS = 0;
/**
+ * Success when trying to suspend.
+ * @hide
+ */
+ public static final int SUCCESS_PAUSED = 1;
+
+ /**
* No keepalive. This should only be internally as it indicates There is no keepalive.
* It should not propagate to applications.
* @hide
@@ -249,9 +254,6 @@
@NonNull protected final Executor mExecutor;
/** @hide */
@NonNull protected final ISocketKeepaliveCallback mCallback;
- // TODO: remove slot since mCallback could be used to identify which keepalive to stop.
- /** @hide */
- @Nullable protected Integer mSlot;
/** @hide */
public SocketKeepalive(@NonNull IConnectivityManager service, @NonNull Network network,
@@ -263,11 +265,10 @@
mExecutor = executor;
mCallback = new ISocketKeepaliveCallback.Stub() {
@Override
- public void onStarted(int slot) {
+ public void onStarted() {
final long token = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> {
- mSlot = slot;
callback.onStarted();
});
} finally {
@@ -276,11 +277,22 @@
}
@Override
+ public void onResumed() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(() -> {
+ callback.onResumed();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public void onStopped() {
final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
- mSlot = null;
callback.onStopped();
});
} finally {
@@ -289,11 +301,22 @@
}
@Override
+ public void onPaused() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ executor.execute(() -> {
+ callback.onPaused();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public void onError(int error) {
final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
- mSlot = null;
callback.onError(error);
});
} finally {
@@ -306,7 +329,6 @@
final long token = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
- mSlot = null;
callback.onDataReceived();
});
} finally {
@@ -395,8 +417,18 @@
public static class Callback {
/** The requested keepalive was successfully started. */
public void onStarted() {}
+ /**
+ * The keepalive was resumed by the system after being suspended.
+ * @hide
+ **/
+ public void onResumed() {}
/** The keepalive was successfully stopped. */
public void onStopped() {}
+ /**
+ * The keepalive was paused by the system because it's not necessary right now.
+ * @hide
+ **/
+ public void onPaused() {}
/** An error occurred. */
public void onError(@ErrorCode int error) {}
/** The keepalive on a TCP socket was stopped because the socket received data. This is
diff --git a/framework/src/android/net/TcpSocketKeepalive.java b/framework/src/android/net/TcpSocketKeepalive.java
index 51d805e..cda5830 100644
--- a/framework/src/android/net/TcpSocketKeepalive.java
+++ b/framework/src/android/net/TcpSocketKeepalive.java
@@ -69,9 +69,7 @@
protected void stopImpl() {
mExecutor.execute(() -> {
try {
- if (mSlot != null) {
- mService.stopKeepalive(mNetwork, mSlot);
- }
+ mService.stopKeepalive(mCallback);
} catch (RemoteException e) {
Log.e(TAG, "Error stopping packet keepalive: ", e);
throw e.rethrowFromSystemServer();
diff --git a/framework/src/android/net/connectivity/ConnectivityCompatChanges.java b/framework/src/android/net/connectivity/ConnectivityCompatChanges.java
new file mode 100644
index 0000000..a166675
--- /dev/null
+++ b/framework/src/android/net/connectivity/ConnectivityCompatChanges.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.net.connectivity;
+
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
+import android.compat.annotation.EnabledSince;
+import android.os.Build;
+
+/**
+ * The class contains all CompatChanges for the Connectivity module.
+ *
+ * <p>This is the centralized place for the CompatChanges used in the Connectivity module.
+ * Putting all the CompatChanges in single place makes it possible to manage them under a single
+ * platform_compat_config.
+ * @hide
+ */
+public final class ConnectivityCompatChanges {
+
+ /**
+ * The {@link android.net.LinkProperties#getRoutes()} now can contain excluded as well as
+ * included routes. Use {@link android.net.RouteInfo#getType()} to determine route type.
+ *
+ * @hide
+ */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
+ public static final long EXCLUDED_ROUTES = 186082280;
+
+ /**
+ * When enabled, apps targeting < Android 12 are considered legacy for
+ * the NSD native daemon.
+ * The platform will only keep the daemon running as long as there are
+ * any legacy apps connected.
+ *
+ * After Android 12, direct communication with the native daemon might not work since the native
+ * daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
+ * recommended.
+ * Another alternative could be bundling your own mdns solutions instead of
+ * depending on the system mdns native daemon.
+ *
+ * This compatibility change applies to Android 13 and later only. To toggle behavior on
+ * Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
+ *
+ * @hide
+ */
+ @ChangeId
+ @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
+ // This was a platform change ID with value 191844585L before T
+ public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
+
+ private ConnectivityCompatChanges() {
+ }
+}
diff --git a/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp b/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp
index 122c2d4..4fbc5f4 100644
--- a/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp
+++ b/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp
@@ -247,10 +247,6 @@
return parseBpfNetworkStatsDevInternal(lines, ifaceStatsMap, ifaceIndexNameMap);
}
-uint64_t combineUidTag(const uid_t uid, const uint32_t tag) {
- return (uint64_t)uid << 32 | tag;
-}
-
void groupNetworkStats(std::vector<stats_line>* lines) {
if (lines->size() <= 1) return;
std::sort(lines->begin(), lines->end());
diff --git a/service-t/native/libs/libnetworkstats/NetworkTraceHandler.cpp b/service-t/native/libs/libnetworkstats/NetworkTraceHandler.cpp
index 4c37b8d..aeadb4a 100644
--- a/service-t/native/libs/libnetworkstats/NetworkTraceHandler.cpp
+++ b/service-t/native/libs/libnetworkstats/NetworkTraceHandler.cpp
@@ -50,6 +50,7 @@
void NetworkTraceHandler::InitPerfettoTracing() {
perfetto::TracingInitArgs args = {};
args.backends |= perfetto::kSystemBackend;
+ args.enable_system_consumer = false;
perfetto::Tracing::Initialize(args);
NetworkTraceHandler::RegisterDataSource();
}
diff --git a/service-t/native/libs/libnetworkstats/NetworkTraceHandlerTest.cpp b/service-t/native/libs/libnetworkstats/NetworkTraceHandlerTest.cpp
index 760ae91..560194f 100644
--- a/service-t/native/libs/libnetworkstats/NetworkTraceHandlerTest.cpp
+++ b/service-t/native/libs/libnetworkstats/NetworkTraceHandlerTest.cpp
@@ -87,7 +87,10 @@
protected:
void SetUp() {
if (access(PACKET_TRACE_RINGBUF_PATH, R_OK)) {
- GTEST_SKIP() << "Network tracing is not enabled/loaded on this build";
+ GTEST_SKIP() << "Network tracing is not enabled/loaded on this build.";
+ }
+ if (sizeof(void*) != 8) {
+ GTEST_SKIP() << "Network tracing requires 64-bit build.";
}
}
};
diff --git a/service-t/src/com/android/server/IpSecService.java b/service-t/src/com/android/server/IpSecService.java
index 9e71eb3..a884840 100644
--- a/service-t/src/com/android/server/IpSecService.java
+++ b/service-t/src/com/android/server/IpSecService.java
@@ -17,6 +17,7 @@
package com.android.server;
import static android.Manifest.permission.DUMP;
+import static android.Manifest.permission.NETWORK_SETTINGS;
import static android.net.IpSecManager.FEATURE_IPSEC_TUNNEL_MIGRATION;
import static android.net.IpSecManager.INVALID_RESOURCE_ID;
import static android.system.OsConstants.AF_INET;
@@ -65,6 +66,7 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;
+import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.BinderUtils;
import com.android.net.module.util.NetdUtils;
import com.android.net.module.util.PermissionUtils;
@@ -102,6 +104,7 @@
private static final int NETD_FETCH_TIMEOUT_MS = 5000; // ms
private static final InetAddress INADDR_ANY;
+ private static final InetAddress IN6ADDR_ANY;
@VisibleForTesting static final int MAX_PORT_BIND_ATTEMPTS = 10;
@@ -110,6 +113,8 @@
static {
try {
INADDR_ANY = InetAddress.getByAddress(new byte[] {0, 0, 0, 0});
+ IN6ADDR_ANY = InetAddress.getByAddress(
+ new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
@@ -1013,11 +1018,13 @@
private final class EncapSocketRecord extends OwnedResourceRecord {
private FileDescriptor mSocket;
private final int mPort;
+ private final int mFamily; // TODO: what about IPV6_ADDRFORM?
- EncapSocketRecord(int resourceId, FileDescriptor socket, int port) {
+ EncapSocketRecord(int resourceId, FileDescriptor socket, int port, int family) {
super(resourceId);
mSocket = socket;
mPort = port;
+ mFamily = family;
}
/** always guarded by IpSecService#this */
@@ -1038,6 +1045,10 @@
return mSocket;
}
+ public int getFamily() {
+ return mFamily;
+ }
+
@Override
protected ResourceTracker getResourceTracker() {
return getUserRecord().mSocketQuotaTracker;
@@ -1210,15 +1221,16 @@
* and re-binding, during which the system could *technically* hand that port out to someone
* else.
*/
- private int bindToRandomPort(FileDescriptor sockFd) throws IOException {
+ private int bindToRandomPort(FileDescriptor sockFd, int family, InetAddress localAddr)
+ throws IOException {
for (int i = MAX_PORT_BIND_ATTEMPTS; i > 0; i--) {
try {
- FileDescriptor probeSocket = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- Os.bind(probeSocket, INADDR_ANY, 0);
+ FileDescriptor probeSocket = Os.socket(family, SOCK_DGRAM, IPPROTO_UDP);
+ Os.bind(probeSocket, localAddr, 0);
int port = ((InetSocketAddress) Os.getsockname(probeSocket)).getPort();
Os.close(probeSocket);
Log.v(TAG, "Binding to port " + port);
- Os.bind(sockFd, INADDR_ANY, port);
+ Os.bind(sockFd, localAddr, port);
return port;
} catch (ErrnoException e) {
// Someone miraculously claimed the port just after we closed probeSocket.
@@ -1260,6 +1272,19 @@
@Override
public synchronized IpSecUdpEncapResponse openUdpEncapsulationSocket(int port, IBinder binder)
throws RemoteException {
+ // Experimental support for IPv6 UDP encap.
+ final int family;
+ final InetAddress localAddr;
+ if (SdkLevel.isAtLeastU() && port >= 65536) {
+ PermissionUtils.enforceNetworkStackPermissionOr(mContext, NETWORK_SETTINGS);
+ port -= 65536;
+ family = AF_INET6;
+ localAddr = IN6ADDR_ANY;
+ } else {
+ family = AF_INET;
+ localAddr = INADDR_ANY;
+ }
+
if (port != 0 && (port < FREE_PORT_MIN || port > PORT_MAX)) {
throw new IllegalArgumentException(
"Specified port number must be a valid non-reserved UDP port");
@@ -1278,7 +1303,7 @@
FileDescriptor sockFd = null;
try {
- sockFd = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ sockFd = Os.socket(family, SOCK_DGRAM, IPPROTO_UDP);
pFd = ParcelFileDescriptor.dup(sockFd);
} finally {
IoUtils.closeQuietly(sockFd);
@@ -1295,15 +1320,16 @@
mNetd.ipSecSetEncapSocketOwner(pFd, callingUid);
if (port != 0) {
Log.v(TAG, "Binding to port " + port);
- Os.bind(pFd.getFileDescriptor(), INADDR_ANY, port);
+ Os.bind(pFd.getFileDescriptor(), localAddr, port);
} else {
- port = bindToRandomPort(pFd.getFileDescriptor());
+ port = bindToRandomPort(pFd.getFileDescriptor(), family, localAddr);
}
userRecord.mEncapSocketRecords.put(
resourceId,
new RefcountedResource<EncapSocketRecord>(
- new EncapSocketRecord(resourceId, pFd.getFileDescriptor(), port),
+ new EncapSocketRecord(resourceId, pFd.getFileDescriptor(), port,
+ family),
binder));
return new IpSecUdpEncapResponse(IpSecManager.Status.OK, resourceId, port,
pFd.getFileDescriptor());
@@ -1580,6 +1606,7 @@
*/
private void checkIpSecConfig(IpSecConfig config) {
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
+ EncapSocketRecord encapSocketRecord = null;
switch (config.getEncapType()) {
case IpSecTransform.ENCAP_NONE:
@@ -1587,7 +1614,7 @@
case IpSecTransform.ENCAP_ESPINUDP:
case IpSecTransform.ENCAP_ESPINUDP_NON_IKE:
// Retrieve encap socket record; will throw IllegalArgumentException if not found
- userRecord.mEncapSocketRecords.getResourceOrThrow(
+ encapSocketRecord = userRecord.mEncapSocketRecords.getResourceOrThrow(
config.getEncapSocketResourceId());
int port = config.getEncapRemotePort();
@@ -1641,10 +1668,9 @@
+ ") have different address families.");
}
- // Throw an error if UDP Encapsulation is not used in IPv4.
- if (config.getEncapType() != IpSecTransform.ENCAP_NONE && sourceFamily != AF_INET) {
+ if (encapSocketRecord != null && encapSocketRecord.getFamily() != destinationFamily) {
throw new IllegalArgumentException(
- "UDP Encapsulation is not supported for this address family");
+ "UDP encapsulation socket and destination address families must match");
}
switch (config.getMode()) {
diff --git a/service-t/src/com/android/server/NsdService.java b/service-t/src/com/android/server/NsdService.java
index 49c6ef0..4ad39e1 100644
--- a/service-t/src/com/android/server/NsdService.java
+++ b/service-t/src/com/android/server/NsdService.java
@@ -118,13 +118,15 @@
private final NsdStateMachine mNsdStateMachine;
private final MDnsManager mMDnsManager;
private final MDnsEventCallback mMDnsEventCallback;
- @Nullable
+ @NonNull
+ private final Dependencies mDeps;
+ @NonNull
private final MdnsMultinetworkSocketClient mMdnsSocketClient;
- @Nullable
+ @NonNull
private final MdnsDiscoveryManager mMdnsDiscoveryManager;
- @Nullable
+ @NonNull
private final MdnsSocketProvider mMdnsSocketProvider;
- @Nullable
+ @NonNull
private final MdnsAdvertiser mAdvertiser;
// WARNING : Accessing these values in any thread is not safe, it must only be changed in the
// state machine thread. If change this outside state machine, it will need to introduce
@@ -311,21 +313,14 @@
mIsMonitoringSocketsStarted = true;
}
- private void maybeStopMonitoringSockets() {
- if (!mIsMonitoringSocketsStarted) {
- if (DBG) Log.d(TAG, "Socket monitoring has not been started.");
- return;
- }
+ private void maybeStopMonitoringSocketsIfNoActiveRequest() {
+ if (!mIsMonitoringSocketsStarted) return;
+ if (isAnyRequestActive()) return;
+
mMdnsSocketProvider.stopMonitoringSockets();
mIsMonitoringSocketsStarted = false;
}
- private void maybeStopMonitoringSocketsIfNoActiveRequest() {
- if (!isAnyRequestActive()) {
- maybeStopMonitoringSockets();
- }
- }
-
NsdStateMachine(String name, Handler handler) {
super(name, handler);
addState(mDefaultState);
@@ -362,9 +357,7 @@
mLegacyClientCount -= 1;
}
}
- if (mMdnsDiscoveryManager != null || mAdvertiser != null) {
- maybeStopMonitoringSocketsIfNoActiveRequest();
- }
+ maybeStopMonitoringSocketsIfNoActiveRequest();
maybeScheduleStop();
break;
case NsdManager.DISCOVER_SERVICES:
@@ -579,7 +572,7 @@
final NsdServiceInfo info = args.serviceInfo;
id = getUniqueId();
- if (mMdnsDiscoveryManager != null) {
+ if (mDeps.isMdnsDiscoveryManagerEnabled(mContext)) {
final String serviceType = constructServiceType(info.getServiceType());
if (serviceType == null) {
clientInfo.onDiscoverServicesFailed(clientId,
@@ -634,6 +627,9 @@
break;
}
id = request.mGlobalId;
+ // Note isMdnsDiscoveryManagerEnabled may have changed to false at this
+ // point, so this needs to check the type of the original request to
+ // unregister instead of looking at the flag value.
if (request instanceof DiscoveryManagerRequest) {
final MdnsListener listener =
((DiscoveryManagerRequest) request).mListener;
@@ -671,7 +667,7 @@
}
id = getUniqueId();
- if (mAdvertiser != null) {
+ if (mDeps.isMdnsAdvertiserEnabled(mContext)) {
final NsdServiceInfo serviceInfo = args.serviceInfo;
final String serviceType = serviceInfo.getServiceType();
final String registerServiceType = constructServiceType(serviceType);
@@ -722,7 +718,10 @@
id = request.mGlobalId;
removeRequestMap(clientId, id, clientInfo);
- if (mAdvertiser != null) {
+ // Note isMdnsAdvertiserEnabled may have changed to false at this point,
+ // so this needs to check the type of the original request to unregister
+ // instead of looking at the flag value.
+ if (request instanceof AdvertiserClientRequest) {
mAdvertiser.removeService(id);
clientInfo.onUnregisterServiceSucceeded(clientId);
} else {
@@ -749,7 +748,7 @@
final NsdServiceInfo info = args.serviceInfo;
id = getUniqueId();
- if (mMdnsDiscoveryManager != null) {
+ if (mDeps.isMdnsDiscoveryManagerEnabled(mContext)) {
final String serviceType = constructServiceType(info.getServiceType());
if (serviceType == null) {
clientInfo.onResolveServiceFailed(clientId,
@@ -1241,32 +1240,16 @@
mNsdStateMachine.start();
mMDnsManager = ctx.getSystemService(MDnsManager.class);
mMDnsEventCallback = new MDnsEventCallback(mNsdStateMachine);
+ mDeps = deps;
- final boolean discoveryManagerEnabled = deps.isMdnsDiscoveryManagerEnabled(ctx);
- final boolean advertiserEnabled = deps.isMdnsAdvertiserEnabled(ctx);
- if (discoveryManagerEnabled || advertiserEnabled) {
- mMdnsSocketProvider = deps.makeMdnsSocketProvider(ctx, handler.getLooper());
- } else {
- mMdnsSocketProvider = null;
- }
-
- if (discoveryManagerEnabled) {
- mMdnsSocketClient =
- new MdnsMultinetworkSocketClient(handler.getLooper(), mMdnsSocketProvider);
- mMdnsDiscoveryManager =
- deps.makeMdnsDiscoveryManager(new ExecutorProvider(), mMdnsSocketClient);
- handler.post(() -> mMdnsSocketClient.setCallback(mMdnsDiscoveryManager));
- } else {
- mMdnsSocketClient = null;
- mMdnsDiscoveryManager = null;
- }
-
- if (advertiserEnabled) {
- mAdvertiser = deps.makeMdnsAdvertiser(handler.getLooper(), mMdnsSocketProvider,
- new AdvertiserCallback());
- } else {
- mAdvertiser = null;
- }
+ mMdnsSocketProvider = deps.makeMdnsSocketProvider(ctx, handler.getLooper());
+ mMdnsSocketClient =
+ new MdnsMultinetworkSocketClient(handler.getLooper(), mMdnsSocketProvider);
+ mMdnsDiscoveryManager =
+ deps.makeMdnsDiscoveryManager(new ExecutorProvider(), mMdnsSocketClient);
+ handler.post(() -> mMdnsSocketClient.setCallback(mMdnsDiscoveryManager));
+ mAdvertiser = deps.makeMdnsAdvertiser(handler.getLooper(), mMdnsSocketProvider,
+ new AdvertiserCallback());
}
/**
diff --git a/service/ServiceConnectivityResources/res/values-mcc310-mnc590/config.xml b/service/ServiceConnectivityResources/res/values-mcc310-mnc590/config.xml
new file mode 120000
index 0000000..2b8e406
--- /dev/null
+++ b/service/ServiceConnectivityResources/res/values-mcc310-mnc590/config.xml
@@ -0,0 +1 @@
+../values-mcc310-mnc004/config.xml
\ No newline at end of file
diff --git a/service/ServiceConnectivityResources/res/values-mcc310-mnc599/config.xml b/service/ServiceConnectivityResources/res/values-mcc310-mnc599/config.xml
new file mode 120000
index 0000000..2b8e406
--- /dev/null
+++ b/service/ServiceConnectivityResources/res/values-mcc310-mnc599/config.xml
@@ -0,0 +1 @@
+../values-mcc310-mnc004/config.xml
\ No newline at end of file
diff --git a/service/ServiceConnectivityResources/res/values-mcc311-mnc270/config.xml b/service/ServiceConnectivityResources/res/values-mcc311-mnc270/config.xml
new file mode 120000
index 0000000..2b8e406
--- /dev/null
+++ b/service/ServiceConnectivityResources/res/values-mcc311-mnc270/config.xml
@@ -0,0 +1 @@
+../values-mcc310-mnc004/config.xml
\ No newline at end of file
diff --git a/service/ServiceConnectivityResources/res/values-mcc311-mnc280/config.xml b/service/ServiceConnectivityResources/res/values-mcc311-mnc280/config.xml
new file mode 120000
index 0000000..2b8e406
--- /dev/null
+++ b/service/ServiceConnectivityResources/res/values-mcc311-mnc280/config.xml
@@ -0,0 +1 @@
+../values-mcc310-mnc004/config.xml
\ No newline at end of file
diff --git a/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml b/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml
deleted file mode 100644
index 7e7025f..0000000
--- a/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!-- Configuration values for ConnectivityService
- DO NOT EDIT THIS FILE for specific device configuration; instead, use a Runtime Resources
- Overlay package following the overlayable.xml configuration in the same directory:
- https://source.android.com/devices/architecture/rros -->
-<resources>
- <!-- Whether the device should automatically switch away from Wi-Fi networks that lose
- Internet access. Actual device behaviour is controlled by
- Settings.Global.NETWORK_AVOID_BAD_WIFI. This is the default value of that setting. -->
- <integer translatable="false" name="config_networkAvoidBadWifi">0</integer>
-</resources>
\ No newline at end of file
diff --git a/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml b/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml
new file mode 120000
index 0000000..2b8e406
--- /dev/null
+++ b/service/ServiceConnectivityResources/res/values-mcc311-mnc480/config.xml
@@ -0,0 +1 @@
+../values-mcc310-mnc004/config.xml
\ No newline at end of file
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 330a1da..1332f32 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -107,6 +107,7 @@
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
@@ -765,6 +766,11 @@
private static final int EVENT_SET_VPN_NETWORK_PREFERENCE = 59;
/**
+ * Event to use low TCP polling timer used in automatic on/off keepalive temporarily.
+ */
+ private static final int EVENT_SET_LOW_TCP_POLLING_UNTIL = 60;
+
+ /**
* Argument for {@link #EVENT_PROVISIONING_NOTIFICATION} to indicate that the notification
* should be shown.
*/
@@ -782,6 +788,12 @@
private static final long MAX_TEST_ALLOW_BAD_WIFI_UNTIL_MS = 5 * 60 * 1000L;
/**
+ * The maximum alive time to decrease TCP polling timer in automatic on/off keepalive for
+ * testing.
+ */
+ private static final long MAX_TEST_LOW_TCP_POLLING_UNTIL_MS = 5 * 60 * 1000L;
+
+ /**
* The priority of the tc police rate limiter -- smaller value is higher priority.
* This value needs to be coordinated with PRIO_CLAT, PRIO_TETHER4, and PRIO_TETHER6.
*/
@@ -1304,6 +1316,14 @@
}
/**
+ * @see AutomaticOnOffKeepaliveTracker
+ */
+ public AutomaticOnOffKeepaliveTracker makeAutomaticOnOffKeepaliveTracker(
+ @NonNull Context c, @NonNull Handler h) {
+ return new AutomaticOnOffKeepaliveTracker(c, h);
+ }
+
+ /**
* @see BatteryStatsManager
*/
public void reportNetworkInterfaceForTransports(Context context, String iface,
@@ -1566,7 +1586,7 @@
mSettingsObserver = new SettingsObserver(mContext, mHandler);
registerSettingsCallbacks();
- mKeepaliveTracker = new AutomaticOnOffKeepaliveTracker(mContext, mHandler);
+ mKeepaliveTracker = mDeps.makeAutomaticOnOffKeepaliveTracker(mContext, mHandler);
mNotifier = new NetworkNotificationManager(mContext, mTelephonyManager);
mQosCallbackTracker = new QosCallbackTracker(mHandler, mNetworkRequestCounter);
@@ -3038,6 +3058,8 @@
sendStickyBroadcast(makeGeneralIntent(info, bcastType));
}
+ // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
+ @SuppressLint("NewApi")
// TODO: Set the mini sdk to 31 and remove @TargetApi annotation when b/205923322 is addressed.
@TargetApi(Build.VERSION_CODES.S)
private void sendStickyBroadcast(Intent intent) {
@@ -4998,6 +5020,22 @@
mHandler.obtainMessage(EVENT_SET_TEST_ALLOW_BAD_WIFI_UNTIL, timeMs));
}
+ @Override
+ public void setTestLowTcpPollingTimerForKeepalive(long timeMs) {
+ enforceSettingsPermission();
+ if (!Build.isDebuggable()) {
+ throw new IllegalStateException("Is not supported in non-debuggable build");
+ }
+
+ if (timeMs > System.currentTimeMillis() + MAX_TEST_LOW_TCP_POLLING_UNTIL_MS) {
+ throw new IllegalArgumentException("Argument should not exceed "
+ + MAX_TEST_LOW_TCP_POLLING_UNTIL_MS + "ms from now");
+ }
+
+ mHandler.sendMessage(
+ mHandler.obtainMessage(EVENT_SET_LOW_TCP_POLLING_UNTIL, timeMs));
+ }
+
private void handleSetAcceptUnvalidated(Network network, boolean accept, boolean always) {
if (DBG) log("handleSetAcceptUnvalidated network=" + network +
" accept=" + accept + " always=" + always);
@@ -5547,7 +5585,9 @@
break;
}
case NetworkAgent.CMD_MONITOR_AUTOMATIC_KEEPALIVE: {
- final AutomaticOnOffKeepalive ki = (AutomaticOnOffKeepalive) msg.obj;
+ final AutomaticOnOffKeepalive ki =
+ mKeepaliveTracker.getKeepaliveForBinder((IBinder) msg.obj);
+ if (null == ki) return; // The callback was unregistered before the alarm fired
final Network network = ki.getNetwork();
boolean networkFound = false;
@@ -5575,14 +5615,14 @@
}
// Sent by KeepaliveTracker to process an app request on the state machine thread.
case NetworkAgent.CMD_STOP_SOCKET_KEEPALIVE: {
- NetworkAgentInfo nai = getNetworkAgentInfoForNetwork((Network) msg.obj);
- if (nai == null) {
- Log.e(TAG, "Attempt to stop keepalive on nonexistent network");
+ final AutomaticOnOffKeepalive ki = mKeepaliveTracker.getKeepaliveForBinder(
+ (IBinder) msg.obj);
+ if (ki == null) {
+ Log.e(TAG, "Attempt to stop an already stopped keepalive");
return;
}
- int slot = msg.arg1;
- int reason = msg.arg2;
- mKeepaliveTracker.handleStopKeepalive(nai, slot, reason);
+ final int reason = msg.arg2;
+ mKeepaliveTracker.handleStopKeepalive(ki, reason);
break;
}
case EVENT_REPORT_NETWORK_CONNECTIVITY: {
@@ -5637,6 +5677,11 @@
case EVENT_SET_VPN_NETWORK_PREFERENCE:
handleSetVpnNetworkPreference((VpnNetworkPreferenceInfo) msg.obj);
break;
+ case EVENT_SET_LOW_TCP_POLLING_UNTIL: {
+ final long time = ((Long) msg.obj).longValue();
+ mKeepaliveTracker.handleSetTestLowTcpPollingTimer(time);
+ break;
+ }
}
}
}
@@ -8516,6 +8561,8 @@
// else not handled
}
+ // TODO(b/193460475): Remove when tooling supports SystemApi to public API.
+ @SuppressLint("NewApi")
private void sendIntent(PendingIntent pendingIntent, Intent intent) {
mPendingIntentWakeLock.acquire();
try {
@@ -9863,9 +9910,10 @@
}
@Override
- public void stopKeepalive(Network network, int slot) {
+ public void stopKeepalive(@NonNull final ISocketKeepaliveCallback cb) {
mHandler.sendMessage(mHandler.obtainMessage(
- NetworkAgent.CMD_STOP_SOCKET_KEEPALIVE, slot, SocketKeepalive.SUCCESS, network));
+ NetworkAgent.CMD_STOP_SOCKET_KEEPALIVE, 0, SocketKeepalive.SUCCESS,
+ Objects.requireNonNull(cb).asBinder()));
}
@Override
diff --git a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
index 46fff6c..daabfd8 100644
--- a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
+++ b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
@@ -18,7 +18,7 @@
import static android.net.NetworkAgent.CMD_START_SOCKET_KEEPALIVE;
import static android.net.SocketKeepalive.ERROR_INVALID_SOCKET;
-import static android.net.SocketKeepalive.SUCCESS;
+import static android.net.SocketKeepalive.SUCCESS_PAUSED;
import static android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY;
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.AF_INET6;
@@ -45,6 +45,7 @@
import android.net.Network;
import android.net.NetworkAgent;
import android.net.SocketKeepalive.InvalidSocketException;
+import android.os.Bundle;
import android.os.FileUtils;
import android.os.Handler;
import android.os.IBinder;
@@ -53,6 +54,7 @@
import android.os.SystemClock;
import android.system.ErrnoException;
import android.system.Os;
+import android.system.OsConstants;
import android.system.StructTimeval;
import android.util.Log;
import android.util.SparseArray;
@@ -60,11 +62,13 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.modules.utils.build.SdkLevel;
+import com.android.net.module.util.BinderUtils;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.DeviceConfigUtils;
import com.android.net.module.util.HexDump;
import com.android.net.module.util.SocketUtils;
import com.android.net.module.util.netlink.InetDiagMessage;
+import com.android.net.module.util.netlink.NetlinkMessage;
import com.android.net.module.util.netlink.NetlinkUtils;
import com.android.net.module.util.netlink.StructNlAttr;
@@ -92,9 +96,9 @@
private static final int[] ADDRESS_FAMILIES = new int[] {AF_INET6, AF_INET};
private static final String ACTION_TCP_POLLING_ALARM =
"com.android.server.connectivity.KeepaliveTracker.TCP_POLLING_ALARM";
- private static final String EXTRA_NETWORK = "network_id";
- private static final String EXTRA_SLOT = "slot";
+ private static final String EXTRA_BINDER_TOKEN = "token";
private static final long DEFAULT_TCP_POLLING_INTERVAL_MS = 120_000L;
+ private static final long LOW_TCP_POLLING_INTERVAL_MS = 1_000L;
private static final String AUTOMATIC_ON_OFF_KEEPALIVE_VERSION =
"automatic_on_off_keepalive_version";
/**
@@ -153,17 +157,18 @@
* This should be only updated in ConnectivityService handler thread.
*/
private final ArrayList<AutomaticOnOffKeepalive> mAutomaticOnOffKeepalives = new ArrayList<>();
+ // TODO: Remove this when TCP polling design is replaced with callback.
+ private long mTestLowTcpPollingTimerUntilMs = 0;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_TCP_POLLING_ALARM.equals(intent.getAction())) {
Log.d(TAG, "Received TCP polling intent");
- final Network network = intent.getParcelableExtra(EXTRA_NETWORK);
- final int slot = intent.getIntExtra(EXTRA_SLOT, -1);
+ final IBinder token = intent.getBundleExtra(EXTRA_BINDER_TOKEN).getBinder(
+ EXTRA_BINDER_TOKEN);
mConnectivityServiceHandler.obtainMessage(
- NetworkAgent.CMD_MONITOR_AUTOMATIC_KEEPALIVE,
- slot, 0 , network).sendToTarget();
+ NetworkAgent.CMD_MONITOR_AUTOMATIC_KEEPALIVE, token).sendToTarget();
}
}
};
@@ -180,9 +185,11 @@
* resumed if a TCP socket is open on the VPN.
* See the documentation for the states for more detail.
*/
- public class AutomaticOnOffKeepalive {
+ public class AutomaticOnOffKeepalive implements IBinder.DeathRecipient {
@NonNull
private final KeepaliveTracker.KeepaliveInfo mKi;
+ @NonNull
+ private final ISocketKeepaliveCallback mCallback;
@Nullable
private final FileDescriptor mFd;
@Nullable
@@ -193,6 +200,7 @@
AutomaticOnOffKeepalive(@NonNull final KeepaliveTracker.KeepaliveInfo ki,
final boolean autoOnOff, @NonNull Context context) throws InvalidSocketException {
this.mKi = Objects.requireNonNull(ki);
+ mCallback = ki.mCallback;
if (autoOnOff && mDependencies.isFeatureEnabled(AUTOMATIC_ON_OFF_KEEPALIVE_VERSION)) {
mAutomaticOnOffState = STATE_ENABLED;
if (null == ki.mFd) {
@@ -205,8 +213,7 @@
Log.e(TAG, "Cannot dup fd: ", e);
throw new InvalidSocketException(ERROR_INVALID_SOCKET, e);
}
- mTcpPollingAlarm = createTcpPollingAlarmIntent(
- context, ki.getNai().network(), ki.getSlot());
+ mTcpPollingAlarm = createTcpPollingAlarmIntent(context, mCallback.asBinder());
} else {
mAutomaticOnOffState = STATE_ALWAYS_ON;
// A null fd is acceptable in KeepaliveInfo for backward compatibility of
@@ -226,12 +233,48 @@
}
private PendingIntent createTcpPollingAlarmIntent(@NonNull Context context,
- @NonNull Network network, int slot) {
+ @NonNull IBinder token) {
final Intent intent = new Intent(ACTION_TCP_POLLING_ALARM);
- intent.putExtra(EXTRA_NETWORK, network);
- intent.putExtra(EXTRA_SLOT, slot);
- return PendingIntent.getBroadcast(
- context, 0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE);
+ // Intent doesn't expose methods to put extra Binders, but Bundle does.
+ final Bundle b = new Bundle();
+ b.putBinder(EXTRA_BINDER_TOKEN, token);
+ intent.putExtra(EXTRA_BINDER_TOKEN, b);
+ return BinderUtils.withCleanCallingIdentity(() -> PendingIntent.getBroadcast(
+ context, 0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE));
+ }
+
+ @Override
+ public void binderDied() {
+ mConnectivityServiceHandler.post(() -> cleanupAutoOnOffKeepalive(this));
+ }
+
+ /** Close this automatic on/off keepalive */
+ public void close() {
+ // Close the duplicated fd that maintains the lifecycle of socket. If this fd was
+ // not duplicated this is a no-op.
+ FileUtils.closeQuietly(mFd);
+ }
+
+ private String getAutomaticOnOffStateName(int state) {
+ switch (state) {
+ case STATE_ENABLED:
+ return "STATE_ENABLED";
+ case STATE_SUSPENDED:
+ return "STATE_SUSPENDED";
+ case STATE_ALWAYS_ON:
+ return "STATE_ALWAYS_ON";
+ default:
+ Log.e(TAG, "Get unexpected state:" + state);
+ return Integer.toString(state);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "AutomaticOnOffKeepalive [ "
+ + mKi
+ + ", state=" + getAutomaticOnOffStateName(mAutomaticOnOffState)
+ + " ]";
}
}
@@ -258,7 +301,7 @@
private void startTcpPollingAlarm(@NonNull PendingIntent alarm) {
final long triggerAtMillis =
- SystemClock.elapsedRealtime() + DEFAULT_TCP_POLLING_INTERVAL_MS;
+ SystemClock.elapsedRealtime() + getTcpPollingInterval();
// Setup a non-wake up alarm.
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME, triggerAtMillis, alarm);
}
@@ -291,7 +334,7 @@
// SUSPENDED.
if (ki.mAutomaticOnOffState == STATE_ENABLED) {
ki.mAutomaticOnOffState = STATE_SUSPENDED;
- handleSuspendKeepalive(ki.mKi);
+ handlePauseKeepalive(ki.mKi);
}
} else {
handleMaybeResumeKeepalive(ki);
@@ -318,33 +361,23 @@
newKi = autoKi.mKi.withFd(autoKi.mFd);
} catch (InvalidSocketException | IllegalArgumentException | SecurityException e) {
Log.e(TAG, "Fail to construct keepalive", e);
- mKeepaliveTracker.notifyErrorCallback(autoKi.mKi.mCallback, ERROR_INVALID_SOCKET);
+ mKeepaliveTracker.notifyErrorCallback(autoKi.mCallback, ERROR_INVALID_SOCKET);
return;
}
autoKi.mAutomaticOnOffState = STATE_ENABLED;
handleResumeKeepalive(newKi);
}
- private int findAutomaticOnOffKeepaliveIndex(@NonNull Network network, int slot) {
- ensureRunningOnHandlerThread();
-
- int index = 0;
- for (AutomaticOnOffKeepalive ki : mAutomaticOnOffKeepalives) {
- if (ki.match(network, slot)) {
- return index;
- }
- index++;
- }
- return -1;
- }
-
+ /**
+ * Find the AutomaticOnOffKeepalive associated with a given callback.
+ * @return the keepalive associated with this callback, or null if none
+ */
@Nullable
- private AutomaticOnOffKeepalive findAutomaticOnOffKeepalive(@NonNull Network network,
- int slot) {
+ public AutomaticOnOffKeepalive getKeepaliveForBinder(@NonNull final IBinder token) {
ensureRunningOnHandlerThread();
- final int index = findAutomaticOnOffKeepaliveIndex(network, slot);
- return (index >= 0) ? mAutomaticOnOffKeepalives.get(index) : null;
+ return CollectionUtils.findFirst(mAutomaticOnOffKeepalives,
+ it -> it.mCallback.asBinder().equals(token));
}
/**
@@ -378,6 +411,13 @@
mKeepaliveTracker.handleStartKeepalive(autoKi.mKi);
// Add automatic on/off request into list to track its life cycle.
+ try {
+ autoKi.mKi.mCallback.asBinder().linkToDeath(autoKi, 0);
+ } catch (RemoteException e) {
+ // The underlying keepalive performs its own cleanup
+ autoKi.binderDied();
+ return;
+ }
mAutomaticOnOffKeepalives.add(autoKi);
if (STATE_ALWAYS_ON != autoKi.mAutomaticOnOffState) {
startTcpPollingAlarm(autoKi.mTcpPollingAlarm);
@@ -388,26 +428,22 @@
mKeepaliveTracker.handleStartKeepalive(ki);
}
- private void handleSuspendKeepalive(@NonNull final KeepaliveTracker.KeepaliveInfo ki) {
+ private void handlePauseKeepalive(@NonNull final KeepaliveTracker.KeepaliveInfo ki) {
// TODO : mKT.handleStopKeepalive should take a KeepaliveInfo instead
- // TODO : create a separate success code for suspend
- mKeepaliveTracker.handleStopKeepalive(ki.getNai(), ki.getSlot(), SUCCESS);
+ mKeepaliveTracker.handleStopKeepalive(ki.getNai(), ki.getSlot(), SUCCESS_PAUSED);
}
/**
* Handle stop keepalives on the specific network with given slot.
*/
- public void handleStopKeepalive(@NonNull NetworkAgentInfo nai, int slot, int reason) {
- final AutomaticOnOffKeepalive autoKi = findAutomaticOnOffKeepalive(nai.network, slot);
- if (null == autoKi) {
- Log.e(TAG, "Attempt to stop nonexistent keepalive " + slot + " on " + nai);
- return;
- }
-
+ public void handleStopKeepalive(@NonNull final AutomaticOnOffKeepalive autoKi, int reason) {
// Stop the keepalive unless it was suspended. This includes the case where it's managed
// but enabled, and the case where it's always on.
if (autoKi.mAutomaticOnOffState != STATE_SUSPENDED) {
- mKeepaliveTracker.handleStopKeepalive(nai, slot, reason);
+ final KeepaliveTracker.KeepaliveInfo ki = autoKi.mKi;
+ mKeepaliveTracker.handleStopKeepalive(ki.getNai(), ki.getSlot(), reason);
+ } else {
+ mKeepaliveTracker.finalizePausedKeepalive(autoKi.mKi);
}
cleanupAutoOnOffKeepalive(autoKi);
@@ -415,10 +451,15 @@
private void cleanupAutoOnOffKeepalive(@NonNull final AutomaticOnOffKeepalive autoKi) {
ensureRunningOnHandlerThread();
+ autoKi.close();
if (null != autoKi.mTcpPollingAlarm) mAlarmManager.cancel(autoKi.mTcpPollingAlarm);
- // Close the duplicated fd that maintains the lifecycle of socket.
- FileUtils.closeQuietly(autoKi.mFd);
- mAutomaticOnOffKeepalives.remove(autoKi);
+
+ // If the KI is not in the array, it's because it was already removed, or it was never
+ // added ; the only ways this can happen is if the keepalive is stopped by the app and the
+ // app dies immediately, or if the app died before the link to death could be registered.
+ if (!mAutomaticOnOffKeepalives.remove(autoKi)) return;
+
+ autoKi.mKi.mCallback.asBinder().unlinkToDeath(autoKi, 0);
}
/**
@@ -510,8 +551,18 @@
* Dump AutomaticOnOffKeepaliveTracker state.
*/
public void dump(IndentingPrintWriter pw) {
- // TODO: Dump the necessary information for automatic on/off keepalive.
mKeepaliveTracker.dump(pw);
+ // Reading DeviceConfig will check if the calling uid and calling package name are the same.
+ // Clear calling identity to align the calling uid and package so that it won't fail if cts
+ // would like to do the dump()
+ final boolean featureEnabled = BinderUtils.withCleanCallingIdentity(
+ () -> mDependencies.isFeatureEnabled(AUTOMATIC_ON_OFF_KEEPALIVE_VERSION));
+ pw.println("AutomaticOnOff enabled: " + featureEnabled);
+ pw.increaseIndent();
+ for (AutomaticOnOffKeepalive autoKi : mAutomaticOnOffKeepalives) {
+ pw.println(autoKi.toString());
+ }
+ pw.decreaseIndent();
}
/**
@@ -581,6 +632,16 @@
bytes.position(startPos + SOCKDIAG_MSG_HEADER_SIZE);
if (isTargetTcpSocket(bytes, nlmsgLen, networkMark, networkMask)) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ bytes.position(startPos);
+ final InetDiagMessage diagMsg = (InetDiagMessage) NetlinkMessage.parse(
+ bytes, OsConstants.NETLINK_INET_DIAG);
+ Log.d(TAG, String.format("Found open TCP connection by uid %d to %s"
+ + " cookie %d",
+ diagMsg.inetDiagMsg.idiag_uid,
+ diagMsg.inetDiagMsg.id.remSocketAddress,
+ diagMsg.inetDiagMsg.id.cookie));
+ }
return true;
}
}
@@ -631,6 +692,20 @@
}
}
+ private long getTcpPollingInterval() {
+ final boolean useLowTimer = mTestLowTcpPollingTimerUntilMs > System.currentTimeMillis();
+ return useLowTimer ? LOW_TCP_POLLING_INTERVAL_MS : DEFAULT_TCP_POLLING_INTERVAL_MS;
+ }
+
+ /**
+ * Temporarily use low TCP polling timer for testing.
+ * The value works when the time set is more than {@link System.currentTimeMillis()}.
+ */
+ public void handleSetTestLowTcpPollingTimer(long timeMs) {
+ Log.d(TAG, "handleSetTestLowTcpPollingTimer: " + timeMs);
+ mTestLowTcpPollingTimerUntilMs = timeMs;
+ }
+
/**
* Dependencies class for testing.
*/
diff --git a/service/src/com/android/server/connectivity/KeepaliveTracker.java b/service/src/com/android/server/connectivity/KeepaliveTracker.java
index 63b76c7..5572361 100644
--- a/service/src/com/android/server/connectivity/KeepaliveTracker.java
+++ b/service/src/com/android/server/connectivity/KeepaliveTracker.java
@@ -32,6 +32,7 @@
import static android.net.SocketKeepalive.MIN_INTERVAL_SEC;
import static android.net.SocketKeepalive.NO_KEEPALIVE;
import static android.net.SocketKeepalive.SUCCESS;
+import static android.net.SocketKeepalive.SUCCESS_PAUSED;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -125,14 +126,18 @@
* which is only returned when the hardware has successfully started the keepalive.
*/
class KeepaliveInfo implements IBinder.DeathRecipient {
- // Bookkeeping data.
+ // TODO : remove this member. Only AutoOnOffKeepalive should have a reference to this.
public final ISocketKeepaliveCallback mCallback;
+ // Bookkeeping data.
private final int mUid;
private final int mPid;
private final boolean mPrivileged;
public final NetworkAgentInfo mNai;
private final int mType;
public final FileDescriptor mFd;
+ // True if this was resumed from a previously turned off keepalive, otherwise false.
+ // This is necessary to send the correct callbacks.
+ public final boolean mResumed;
public static final int TYPE_NATT = 1;
public static final int TYPE_TCP = 2;
@@ -159,6 +164,16 @@
int interval,
int type,
@Nullable FileDescriptor fd) throws InvalidSocketException {
+ this(callback, nai, packet, interval, type, fd, false /* resumed */);
+ }
+
+ KeepaliveInfo(@NonNull ISocketKeepaliveCallback callback,
+ @NonNull NetworkAgentInfo nai,
+ @NonNull KeepalivePacketData packet,
+ int interval,
+ int type,
+ @Nullable FileDescriptor fd,
+ boolean resumed) throws InvalidSocketException {
mCallback = callback;
mPid = Binder.getCallingPid();
mUid = Binder.getCallingUid();
@@ -168,6 +183,7 @@
mPacket = packet;
mInterval = interval;
mType = type;
+ mResumed = resumed;
// For SocketKeepalive, a dup of fd is kept in mFd so the source port from which the
// keepalives are sent cannot be reused by another app even if the fd gets closed by
@@ -231,6 +247,8 @@
/** Called when the application process is killed. */
public void binderDied() {
+ // TODO b/267106526 : this is not called on the handler thread but stop() happily
+ // assumes it is, which means this is a pretty dangerous race condition.
stop(BINDER_DIED);
}
@@ -326,6 +344,10 @@
}
void start(int slot) {
+ // BINDER_DIED can happen if the binder died before the KeepaliveInfo was created and
+ // the constructor set the state to BINDER_DIED. If that's the case, the KI is already
+ // cleaned up.
+ if (BINDER_DIED == mStartedState) return;
mSlot = slot;
int error = isValid();
if (error == SUCCESS) {
@@ -370,7 +392,10 @@
// To prevent races from re-entrance of stop(), return if the state is already stopping.
// This might happen if multiple event sources stop keepalive in a short time. Such as
// network disconnect after user calls stop(), or tear down socket after binder died.
- if (mStartedState == STOPPING) return;
+ // Note that it's always possible this method is called by the auto keepalive timer
+ // or any other way after the binder died, hence the check for BINDER_DIED. If the
+ // binder has died, then the KI has already been cleaned up.
+ if (mStartedState == STOPPING || mStartedState == BINDER_DIED) return;
// Store the reason of stopping, and report it after the keepalive is fully stopped.
if (mStopReason != ERROR_STOP_REASON_UNINITIALIZED) {
@@ -381,9 +406,10 @@
+ ": " + reason);
switch (mStartedState) {
case NOT_STARTED:
- // Remove the reference of the keepalive that meet error before starting,
+ // Remove the reference to this keepalive that had an error before starting,
// e.g. invalid parameter.
cleanupStoppedKeepalive(mNai, mSlot);
+ if (BINDER_DIED == reason) mStartedState = BINDER_DIED;
break;
default:
mStartedState = STOPPING;
@@ -421,7 +447,8 @@
* Construct a new KeepaliveInfo from existing KeepaliveInfo with a new fd.
*/
public KeepaliveInfo withFd(@NonNull FileDescriptor fd) throws InvalidSocketException {
- return new KeepaliveInfo(mCallback, mNai, mPacket, mInterval, mType, fd);
+ return new KeepaliveInfo(mCallback, mNai, mPacket, mInterval, mType, fd,
+ true /* resumed */);
}
}
@@ -522,6 +549,12 @@
} catch (RemoteException e) {
Log.w(TAG, "Discarded onStop callback: " + reason);
}
+ } else if (reason == SUCCESS_PAUSED) {
+ try {
+ ki.mCallback.onPaused();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Discarded onPaused callback: " + reason);
+ }
} else if (reason == DATA_RECEIVED) {
try {
ki.mCallback.onDataReceived();
@@ -539,6 +572,25 @@
ki.unlinkDeathRecipient();
}
+ /**
+ * Finalize a paused keepalive.
+ *
+ * This will simply send the onStopped() callback after checking that this keepalive is
+ * indeed paused.
+ *
+ * @param ki the keepalive to finalize
+ */
+ public void finalizePausedKeepalive(@NonNull final KeepaliveInfo ki) {
+ if (SUCCESS_PAUSED != ki.mStopReason) {
+ throw new IllegalStateException("Keepalive is not paused");
+ }
+ try {
+ ki.mCallback.onStopped();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Discarded onStopped callback while finalizing paused keepalive");
+ }
+ }
+
public void handleCheckKeepalivesStillValid(NetworkAgentInfo nai) {
HashMap <Integer, KeepaliveInfo> networkKeepalives = mKeepalives.get(nai);
if (networkKeepalives != null) {
@@ -588,9 +640,14 @@
Log.d(TAG, "Started keepalive " + slot + " on " + nai.toShortString());
ki.mStartedState = KeepaliveInfo.STARTED;
try {
- ki.mCallback.onStarted(slot);
+ if (ki.mResumed) {
+ ki.mCallback.onResumed();
+ } else {
+ ki.mCallback.onStarted();
+ }
} catch (RemoteException e) {
- Log.w(TAG, "Discarded onStarted(" + slot + ") callback");
+ Log.w(TAG, "Discarded " + (ki.mResumed ? "onResumed" : "onStarted")
+ + " callback for slot " + slot);
}
} else {
Log.d(TAG, "Failed to start keepalive " + slot + " on " + nai.toShortString()
diff --git a/tests/common/AndroidTest_Coverage.xml b/tests/common/AndroidTest_Coverage.xml
index 48d26b8..c94ec27 100644
--- a/tests/common/AndroidTest_Coverage.xml
+++ b/tests/common/AndroidTest_Coverage.xml
@@ -13,7 +13,7 @@
limitations under the License.
-->
<configuration description="Runs coverage tests for Connectivity">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="test-file-name" value="ConnectivityCoverageTests.apk" />
<option name="install-arg" value="-t" />
</target_preparer>
diff --git a/tests/common/java/android/net/LinkPropertiesTest.java b/tests/common/java/android/net/LinkPropertiesTest.java
index 5ee375f..09f5d6e 100644
--- a/tests/common/java/android/net/LinkPropertiesTest.java
+++ b/tests/common/java/android/net/LinkPropertiesTest.java
@@ -32,6 +32,7 @@
import android.compat.testing.PlatformCompatChangeRule;
import android.net.LinkProperties.ProvisioningChange;
+import android.net.connectivity.ConnectivityCompatChanges;
import android.os.Build;
import android.system.OsConstants;
import android.util.ArraySet;
@@ -1261,7 +1262,7 @@
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
- @EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
+ @EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
public void testHasExcludeRoute() {
LinkProperties lp = new LinkProperties();
lp.setInterfaceName("tun0");
@@ -1274,7 +1275,7 @@
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
- @EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
+ @EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
public void testRouteAddWithSameKey() throws Exception {
LinkProperties lp = new LinkProperties();
lp.setInterfaceName("wlan0");
@@ -1348,14 +1349,14 @@
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
- @EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
+ @EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
public void testExcludedRoutesEnabledByCompatChange() {
assertExcludeRoutesVisible();
}
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
- @DisableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
+ @DisableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
public void testExcludedRoutesDisabledByCompatChange() {
checkExcludeRoutesNotVisibleAfterS();
}
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
index a62ef8a..f1ab62d 100755
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/VpnTest.java
@@ -41,6 +41,7 @@
import static com.android.networkstack.apishim.ConstantsShim.RECEIVER_EXPORTED;
import static com.android.testutils.Cleanup.testAndCleanup;
import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
+import static com.android.testutils.RecorderCallback.CallbackEntry.BLOCKED_STATUS_INT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -1643,7 +1644,8 @@
// setRequireVpnForUids setup a lockdown rule asynchronously. So it needs to wait for
// BlockedStatusCallback to be fired before checking the blocking status of incoming
// packets.
- remoteUidCallback.expectBlockedStatusCallback(network, BLOCKED_REASON_LOCKDOWN_VPN);
+ remoteUidCallback.expect(BLOCKED_STATUS_INT, network,
+ cb -> cb.getReason() == BLOCKED_REASON_LOCKDOWN_VPN);
if (SdkLevel.isAtLeastT()) {
// On T and above, lockdown rule drop packets not coming from lo regardless of the
@@ -1818,9 +1820,6 @@
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 onBlockedStatusChanged(Network network, int blockedReasons) {
getHistory().add(new CallbackEntry.BlockedStatusInt(network, blockedReasons));
}
diff --git a/tests/cts/net/native/dns/Android.bp b/tests/cts/net/native/dns/Android.bp
index 434e529..49b9337 100644
--- a/tests/cts/net/native/dns/Android.bp
+++ b/tests/cts/net/native/dns/Android.bp
@@ -24,6 +24,10 @@
"liblog",
"libutils",
],
+ static_libs: [
+ "libbase",
+ "libnetdutils",
+ ],
// To be compatible with Q devices, the min_sdk_version must be 29.
min_sdk_version: "29",
}
diff --git a/tests/cts/net/native/dns/NativeDnsAsyncTest.cpp b/tests/cts/net/native/dns/NativeDnsAsyncTest.cpp
index e501475..68bd227 100644
--- a/tests/cts/net/native/dns/NativeDnsAsyncTest.cpp
+++ b/tests/cts/net/native/dns/NativeDnsAsyncTest.cpp
@@ -28,6 +28,7 @@
#include <android/multinetwork.h>
#include <gtest/gtest.h>
+#include <netdutils/NetNativeTestBase.h>
namespace {
constexpr int MAXPACKET = 8 * 1024;
@@ -101,7 +102,9 @@
} // namespace
-TEST (NativeDnsAsyncTest, Async_Query) {
+class NativeDnsAsyncTest : public NetNativeTestBase {};
+
+TEST_F(NativeDnsAsyncTest, Async_Query) {
// V4
int fd1 = android_res_nquery(
NETWORK_UNSPECIFIED, "www.google.com", ns_c_in, ns_t_a, 0);
@@ -123,7 +126,7 @@
expectAnswersValid(fd1, AF_INET6, ns_r_noerror);
}
-TEST (NativeDnsAsyncTest, Async_Send) {
+TEST_F(NativeDnsAsyncTest, Async_Send) {
// V4
uint8_t buf1[MAXPACKET] = {};
int len1 = res_mkquery(ns_o_query, "www.googleapis.com",
@@ -162,7 +165,7 @@
expectAnswersValid(fd1, AF_INET6, ns_r_noerror);
}
-TEST (NativeDnsAsyncTest, Async_NXDOMAIN) {
+TEST_F(NativeDnsAsyncTest, Async_NXDOMAIN) {
uint8_t buf[MAXPACKET] = {};
int len = res_mkquery(ns_o_query, "test1-nx.metric.gstatic.com",
ns_c_in, ns_t_a, nullptr, 0, nullptr, buf, sizeof(buf));
@@ -191,7 +194,7 @@
expectAnswersValid(fd1, AF_INET6, ns_r_nxdomain);
}
-TEST (NativeDnsAsyncTest, Async_Cancel) {
+TEST_F(NativeDnsAsyncTest, Async_Cancel) {
int fd = android_res_nquery(
NETWORK_UNSPECIFIED, "www.google.com", ns_c_in, ns_t_a, 0);
errno = 0;
@@ -202,7 +205,7 @@
// otherwise it will hit fdsan double-close fd.
}
-TEST (NativeDnsAsyncTest, Async_Query_MALFORMED) {
+TEST_F(NativeDnsAsyncTest, Async_Query_MALFORMED) {
// Empty string to create BLOB and query, we will get empty result and rcode = 0
// on DNSTLS.
int fd = android_res_nquery(
@@ -221,7 +224,7 @@
EXPECT_EQ(-EMSGSIZE, fd);
}
-TEST (NativeDnsAsyncTest, Async_Send_MALFORMED) {
+TEST_F(NativeDnsAsyncTest, Async_Send_MALFORMED) {
uint8_t buf[10] = {};
// empty BLOB
int fd = android_res_nsend(NETWORK_UNSPECIFIED, buf, 10, 0);
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index d4b23a3..68b20e2 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -1140,11 +1140,8 @@
.setPackage(mContext.getPackageName());
// While ConnectivityService would put extra info such as network or request id before
// broadcasting the inner intent. The MUTABLE flag needs to be added accordingly.
- // TODO: replace with PendingIntent.FLAG_MUTABLE when this code compiles against S+ or
- // shims.
- final int pendingIntentFlagMutable = 1 << 25;
final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0 /*requestCode*/,
- intent, PendingIntent.FLAG_CANCEL_CURRENT | pendingIntentFlagMutable);
+ intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE);
// We will register for a WIFI network being available or lost.
mCm.registerNetworkCallback(makeWifiNetworkRequest(), pendingIntent);
@@ -1184,15 +1181,13 @@
// Avoid receiving broadcasts from other runs by appending a timestamp
final String broadcastAction = NETWORK_CALLBACK_ACTION + System.currentTimeMillis();
try {
- // TODO: replace with PendingIntent.FLAG_MUTABLE when this code compiles against S+
// Intent is mutable to receive EXTRA_NETWORK_REQUEST from ConnectivityService
- final int pendingIntentFlagMutable = 1 << 25;
final String extraBoolKey = "extra_bool";
firstIntent = PendingIntent.getBroadcast(mContext,
0 /* requestCode */,
new Intent(broadcastAction).putExtra(extraBoolKey, false)
.setPackage(mContext.getPackageName()),
- PendingIntent.FLAG_UPDATE_CURRENT | pendingIntentFlagMutable);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
if (useListen) {
mCm.registerNetworkCallback(firstRequest, firstIntent);
@@ -1206,7 +1201,7 @@
0 /* requestCode */,
new Intent(broadcastAction).putExtra(extraBoolKey, true)
.setPackage(mContext.getPackageName()),
- PendingIntent.FLAG_UPDATE_CURRENT | pendingIntentFlagMutable);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE);
// Because secondIntent.intentFilterEquals the first, the request should be replaced
if (useListen) {
@@ -2390,7 +2385,7 @@
}
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);
+ (it) -> it.getNetwork().equals(network) && it.getReason() == blockedStatus);
}
public void onBlockedStatusChanged(Network network, int blockedReasons) {
getHistory().add(new CallbackEntry.BlockedStatusInt(network, blockedReasons));
diff --git a/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java b/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
index ac50740..6ba0fda 100644
--- a/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
+++ b/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
@@ -529,11 +529,10 @@
assertFalse(profileState.isLockdownEnabled());
}
- cb.expectCapabilitiesThat(vpnNetwork, TIMEOUT_MS,
- caps -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasCapability(NET_CAPABILITY_INTERNET)
- && !caps.hasCapability(NET_CAPABILITY_VALIDATED)
- && Process.myUid() == caps.getOwnerUid());
+ cb.expectCaps(vpnNetwork, TIMEOUT_MS, c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasCapability(NET_CAPABILITY_INTERNET)
+ && !c.hasCapability(NET_CAPABILITY_VALIDATED)
+ && Process.myUid() == c.getOwnerUid());
cb.expect(CallbackEntry.LINK_PROPERTIES_CHANGED, vpnNetwork);
cb.expect(CallbackEntry.BLOCKED_STATUS, vpnNetwork);
diff --git a/tests/cts/net/src/android/net/cts/IpSecManagerTest.java b/tests/cts/net/src/android/net/cts/IpSecManagerTest.java
index 8234ec1..4fa0080 100644
--- a/tests/cts/net/src/android/net/cts/IpSecManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/IpSecManagerTest.java
@@ -16,6 +16,7 @@
package android.net.cts;
+import static android.Manifest.permission.NETWORK_SETTINGS;
import static android.net.IpSecAlgorithm.AUTH_AES_CMAC;
import static android.net.IpSecAlgorithm.AUTH_AES_XCBC;
import static android.net.IpSecAlgorithm.AUTH_CRYPT_AES_GCM;
@@ -52,7 +53,9 @@
import static com.android.compatibility.common.util.PropertyUtil.getFirstApiLevel;
import static com.android.compatibility.common.util.PropertyUtil.getVendorApiLevel;
+import static com.android.testutils.DeviceInfoUtils.isKernelVersionAtLeast;
import static com.android.testutils.MiscAsserts.assertThrows;
+import static com.android.testutils.TestPermissionUtil.runAsShell;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -62,6 +65,8 @@
import android.net.IpSecAlgorithm;
import android.net.IpSecManager;
+import android.net.IpSecManager.SecurityParameterIndex;
+import android.net.IpSecManager.UdpEncapsulationSocket;
import android.net.IpSecTransform;
import android.net.TrafficStats;
import android.os.Build;
@@ -73,6 +78,7 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
+import com.android.modules.utils.build.SdkLevel;
import com.android.testutils.DevSdkIgnoreRule;
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
@@ -120,7 +126,7 @@
@Test
public void testAllocSpi() throws Exception {
for (InetAddress addr : GOOGLE_DNS_LIST) {
- IpSecManager.SecurityParameterIndex randomSpi = null, droidSpi = null;
+ SecurityParameterIndex randomSpi, droidSpi;
randomSpi = mISM.allocateSecurityParameterIndex(addr);
assertTrue(
"Failed to receive a valid SPI",
@@ -258,6 +264,24 @@
accepted.close();
}
+ private IpSecTransform buildTransportModeTransform(
+ SecurityParameterIndex spi, InetAddress localAddr,
+ UdpEncapsulationSocket encapSocket)
+ throws Exception {
+ final IpSecTransform.Builder builder =
+ new IpSecTransform.Builder(InstrumentationRegistry.getContext())
+ .setEncryption(new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY))
+ .setAuthentication(
+ new IpSecAlgorithm(
+ IpSecAlgorithm.AUTH_HMAC_SHA256,
+ AUTH_KEY,
+ AUTH_KEY.length * 8));
+ if (encapSocket != null) {
+ builder.setIpv4Encapsulation(encapSocket, encapSocket.getPort());
+ }
+ return builder.buildTransportModeTransform(localAddr, spi);
+ }
+
/*
* Alloc outbound SPI
* Alloc inbound SPI
@@ -268,21 +292,8 @@
* release transform
* send data (expect exception)
*/
- @Test
- public void testCreateTransform() throws Exception {
- InetAddress localAddr = InetAddress.getByName(IPV4_LOOPBACK);
- IpSecManager.SecurityParameterIndex spi =
- mISM.allocateSecurityParameterIndex(localAddr);
-
- IpSecTransform transform =
- new IpSecTransform.Builder(InstrumentationRegistry.getContext())
- .setEncryption(new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY))
- .setAuthentication(
- new IpSecAlgorithm(
- IpSecAlgorithm.AUTH_HMAC_SHA256,
- AUTH_KEY,
- AUTH_KEY.length * 8))
- .buildTransportModeTransform(localAddr, spi);
+ private void doTestCreateTransform(String loopbackAddrString, boolean encap) throws Exception {
+ InetAddress localAddr = InetAddress.getByName(loopbackAddrString);
final boolean [][] applyInApplyOut = {
{false, false}, {false, true}, {true, false}, {true,true}};
@@ -291,50 +302,93 @@
byte[] in = new byte[data.length];
DatagramPacket inPacket = new DatagramPacket(in, in.length);
- DatagramSocket localSocket;
int localPort;
for(boolean[] io : applyInApplyOut) {
boolean applyIn = io[0];
boolean applyOut = io[1];
- // Bind localSocket to a random available port.
- localSocket = new DatagramSocket(0);
- localPort = localSocket.getLocalPort();
- localSocket.setSoTimeout(200);
- outPacket.setPort(localPort);
- if (applyIn) {
- mISM.applyTransportModeTransform(
- localSocket, IpSecManager.DIRECTION_IN, transform);
- }
- if (applyOut) {
- mISM.applyTransportModeTransform(
- localSocket, IpSecManager.DIRECTION_OUT, transform);
- }
- if (applyIn == applyOut) {
- localSocket.send(outPacket);
- localSocket.receive(inPacket);
- assertTrue("Encapsulated data did not match.",
- Arrays.equals(outPacket.getData(), inPacket.getData()));
- mISM.removeTransportModeTransforms(localSocket);
- localSocket.close();
- } else {
- try {
+ try (
+ SecurityParameterIndex spi = mISM.allocateSecurityParameterIndex(localAddr);
+ UdpEncapsulationSocket encapSocket = encap
+ ? getPrivilegedUdpEncapSocket(/*ipv6=*/ localAddr instanceof Inet6Address)
+ : null;
+ IpSecTransform transform = buildTransportModeTransform(spi, localAddr,
+ encapSocket);
+ // Bind localSocket to a random available port.
+ DatagramSocket localSocket = new DatagramSocket(0);
+ ) {
+ localPort = localSocket.getLocalPort();
+ localSocket.setSoTimeout(200);
+ outPacket.setPort(localPort);
+ if (applyIn) {
+ mISM.applyTransportModeTransform(
+ localSocket, IpSecManager.DIRECTION_IN, transform);
+ }
+ if (applyOut) {
+ mISM.applyTransportModeTransform(
+ localSocket, IpSecManager.DIRECTION_OUT, transform);
+ }
+ if (applyIn == applyOut) {
localSocket.send(outPacket);
localSocket.receive(inPacket);
- } catch (IOException e) {
- continue;
- } finally {
+ assertTrue("Encrypted data did not match.",
+ Arrays.equals(outPacket.getData(), inPacket.getData()));
mISM.removeTransportModeTransforms(localSocket);
- localSocket.close();
+ } else {
+ try {
+ localSocket.send(outPacket);
+ localSocket.receive(inPacket);
+ } catch (IOException e) {
+ continue;
+ } finally {
+ mISM.removeTransportModeTransforms(localSocket);
+ }
+ // FIXME: This check is disabled because sockets currently receive data
+ // if there is a valid SA for decryption, even when the input policy is
+ // not applied to a socket.
+ // fail("Data IO should fail on asymmetrical transforms! + Input="
+ // + applyIn + " Output=" + applyOut);
}
- // FIXME: This check is disabled because sockets currently receive data
- // if there is a valid SA for decryption, even when the input policy is
- // not applied to a socket.
- // fail("Data IO should fail on asymmetrical transforms! + Input="
- // + applyIn + " Output=" + applyOut);
}
}
- transform.close();
+ }
+
+ private UdpEncapsulationSocket getPrivilegedUdpEncapSocket(boolean ipv6) throws Exception {
+ return runAsShell(NETWORK_SETTINGS, () -> {
+ if (ipv6) {
+ return mISM.openUdpEncapsulationSocket(65536);
+ } else {
+ // Can't pass 0 to IpSecManager#openUdpEncapsulationSocket(int).
+ return mISM.openUdpEncapsulationSocket();
+ }
+ });
+ }
+
+ private void assumeExperimentalIpv6UdpEncapSupported() throws Exception {
+ assumeTrue("Not supported before U", SdkLevel.isAtLeastU());
+ assumeTrue("Not supported by kernel", isKernelVersionAtLeast("5.15.31")
+ || (isKernelVersionAtLeast("5.10.108") && !isKernelVersionAtLeast("5.15.0")));
+ }
+
+ @Test
+ public void testCreateTransformIpv4() throws Exception {
+ doTestCreateTransform(IPV4_LOOPBACK, false);
+ }
+
+ @Test
+ public void testCreateTransformIpv6() throws Exception {
+ doTestCreateTransform(IPV6_LOOPBACK, false);
+ }
+
+ @Test
+ public void testCreateTransformIpv4Encap() throws Exception {
+ doTestCreateTransform(IPV4_LOOPBACK, true);
+ }
+
+ @Test
+ public void testCreateTransformIpv6Encap() throws Exception {
+ assumeExperimentalIpv6UdpEncapSupported();
+ doTestCreateTransform(IPV6_LOOPBACK, true);
}
/** Snapshot of TrafficStats as of initStatsChecker call for later comparisons */
@@ -503,8 +557,8 @@
StatsChecker.initStatsChecker();
InetAddress local = InetAddress.getByName(localAddress);
- try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket();
- IpSecManager.SecurityParameterIndex spi =
+ try (UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket();
+ SecurityParameterIndex spi =
mISM.allocateSecurityParameterIndex(local)) {
IpSecTransform.Builder transformBuilder =
@@ -656,7 +710,7 @@
public void testIkeOverUdpEncapSocket() throws Exception {
// IPv6 not supported for UDP-encap-ESP
InetAddress local = InetAddress.getByName(IPV4_LOOPBACK);
- try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
+ try (UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
NativeUdpSocket wrappedEncapSocket =
new NativeUdpSocket(encapSocket.getFileDescriptor());
checkIkePacket(wrappedEncapSocket, local);
@@ -665,7 +719,7 @@
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
- try (IpSecManager.SecurityParameterIndex spi =
+ try (SecurityParameterIndex spi =
mISM.allocateSecurityParameterIndex(local);
IpSecTransform transform =
new IpSecTransform.Builder(InstrumentationRegistry.getContext())
@@ -1498,7 +1552,7 @@
@Test
public void testOpenUdpEncapSocketSpecificPort() throws Exception {
- IpSecManager.UdpEncapsulationSocket encapSocket = null;
+ UdpEncapsulationSocket encapSocket = null;
int port = -1;
for (int i = 0; i < MAX_PORT_BIND_ATTEMPTS; i++) {
try {
@@ -1527,7 +1581,7 @@
@Test
public void testOpenUdpEncapSocketRandomPort() throws Exception {
- try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
+ try (UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
assertTrue("Returned invalid port", encapSocket.getPort() != 0);
}
}
diff --git a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
index 6df71c8..f578ff3 100644
--- a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
+++ b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
@@ -391,9 +391,7 @@
val nc = NetworkCapabilities(agent.nc)
nc.addCapability(NET_CAPABILITY_NOT_METERED)
agent.sendNetworkCapabilities(nc)
- callback.expectCapabilitiesThat(agent.network) {
- it.hasCapability(NET_CAPABILITY_NOT_METERED)
- }
+ callback.expectCaps(agent.network) { it.hasCapability(NET_CAPABILITY_NOT_METERED) }
val networkInfo = mCM.getNetworkInfo(agent.network)
assertEquals(subtypeUMTS, networkInfo.getSubtype())
assertEquals(subtypeNameUMTS, networkInfo.getSubtypeName())
@@ -434,27 +432,28 @@
(agent, callback) ->
// Send signal strength and check that the callbacks are called appropriately.
val nc = NetworkCapabilities(agent.nc)
+ val net = agent.network!!
nc.setSignalStrength(20)
agent.sendNetworkCapabilities(nc)
callbacks.forEach { it.assertNoCallback(NO_CALLBACK_TIMEOUT) }
nc.setSignalStrength(40)
agent.sendNetworkCapabilities(nc)
- callbacks[0].expectAvailableCallbacks(agent.network!!)
+ callbacks[0].expectAvailableCallbacks(net)
callbacks[1].assertNoCallback(NO_CALLBACK_TIMEOUT)
callbacks[2].assertNoCallback(NO_CALLBACK_TIMEOUT)
nc.setSignalStrength(80)
agent.sendNetworkCapabilities(nc)
- callbacks[0].expectCapabilitiesThat(agent.network!!) { it.signalStrength == 80 }
- callbacks[1].expectAvailableCallbacks(agent.network!!)
- callbacks[2].expectAvailableCallbacks(agent.network!!)
+ callbacks[0].expectCaps(net) { it.signalStrength == 80 }
+ callbacks[1].expectAvailableCallbacks(net)
+ callbacks[2].expectAvailableCallbacks(net)
nc.setSignalStrength(55)
agent.sendNetworkCapabilities(nc)
- callbacks[0].expectCapabilitiesThat(agent.network!!) { it.signalStrength == 55 }
- callbacks[1].expectCapabilitiesThat(agent.network!!) { it.signalStrength == 55 }
- callbacks[2].expect<Lost>(agent.network!!)
+ callbacks[0].expectCaps(net) { it.signalStrength == 55 }
+ callbacks[1].expectCaps(net) { it.signalStrength == 55 }
+ callbacks[2].expect<Lost>(net)
}
callbacks.forEach {
mCM.unregisterNetworkCallback(it)
@@ -507,15 +506,11 @@
val lp = LinkProperties(agent.lp)
lp.setInterfaceName(ifaceName)
agent.sendLinkProperties(lp)
- callback.expectLinkPropertiesThat(agent.network!!) {
- it.getInterfaceName() == ifaceName
- }
+ callback.expect<LinkPropertiesChanged>(agent.network!!) { it.lp.interfaceName == ifaceName }
val nc = NetworkCapabilities(agent.nc)
nc.addCapability(NET_CAPABILITY_NOT_METERED)
agent.sendNetworkCapabilities(nc)
- callback.expectCapabilitiesThat(agent.network!!) {
- it.hasCapability(NET_CAPABILITY_NOT_METERED)
- }
+ callback.expectCaps(agent.network!!) { it.hasCapability(NET_CAPABILITY_NOT_METERED) }
}
private fun ncWithAllowedUids(vararg uids: Int) = NetworkCapabilities.Builder()
@@ -533,12 +528,12 @@
// Make sure the UIDs have been ignored.
callback.expect<Available>(agent.network!!)
- callback.expectCapabilitiesThat(agent.network!!) {
+ callback.expectCaps(agent.network!!) {
it.allowedUids.isEmpty() && !it.hasCapability(NET_CAPABILITY_VALIDATED)
}
callback.expect<LinkPropertiesChanged>(agent.network!!)
callback.expect<BlockedStatus>(agent.network!!)
- callback.expectCapabilitiesThat(agent.network!!) {
+ callback.expectCaps(agent.network!!) {
it.allowedUids.isEmpty() && it.hasCapability(NET_CAPABILITY_VALIDATED)
}
callback.assertNoCallback(NO_CALLBACK_TIMEOUT)
@@ -582,8 +577,8 @@
// tearDown() will unregister the requests and agents
}
- private fun hasAllTransports(nc: NetworkCapabilities?, transports: IntArray) =
- nc != null && transports.all { nc.hasTransport(it) }
+ private fun NetworkCapabilities?.hasAllTransports(transports: IntArray) =
+ this != null && transports.all { hasTransport(it) }
@Test
@IgnoreUpTo(Build.VERSION_CODES.R)
@@ -625,25 +620,25 @@
assertEquals(mySessionId, (vpnNc.transportInfo as VpnTransportInfo).sessionId)
val testAndVpn = intArrayOf(TRANSPORT_TEST, TRANSPORT_VPN)
- assertTrue(hasAllTransports(vpnNc, testAndVpn))
+ assertTrue(vpnNc.hasAllTransports(testAndVpn))
assertFalse(vpnNc.hasCapability(NET_CAPABILITY_NOT_VPN))
- assertTrue(hasAllTransports(vpnNc, defaultNetworkTransports),
+ assertTrue(vpnNc.hasAllTransports(defaultNetworkTransports),
"VPN transports ${Arrays.toString(vpnNc.transportTypes)}" +
" lacking transports from ${Arrays.toString(defaultNetworkTransports)}")
// Check that when no underlying networks are announced the underlying transport disappears.
agent.setUnderlyingNetworks(listOf<Network>())
- callback.expectCapabilitiesThat(agent.network!!) {
- it.transportTypes.size == 2 && hasAllTransports(it, testAndVpn)
+ callback.expectCaps(agent.network!!) {
+ it.transportTypes.size == 2 && it.hasAllTransports(testAndVpn)
}
// Put the underlying network back and check that the underlying transport reappears.
val expectedTransports = (defaultNetworkTransports.toSet() + TRANSPORT_TEST + TRANSPORT_VPN)
.toIntArray()
agent.setUnderlyingNetworks(null)
- callback.expectCapabilitiesThat(agent.network!!) {
+ callback.expectCaps(agent.network!!) {
it.transportTypes.size == expectedTransports.size &&
- hasAllTransports(it, expectedTransports)
+ it.hasAllTransports(expectedTransports)
}
// Check that some underlying capabilities are propagated.
@@ -757,7 +752,7 @@
val nc1 = NetworkCapabilities(agent.nc)
.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED)
agent.sendNetworkCapabilities(nc1)
- callback.expectCapabilitiesThat(agent.network!!) {
+ callback.expectCaps(agent.network!!) {
it.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED)
}
@@ -765,7 +760,7 @@
val nc2 = NetworkCapabilities(agent.nc)
.removeCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED)
agent.sendNetworkCapabilities(nc2)
- callback.expectCapabilitiesThat(agent.network!!) {
+ callback.expectCaps(agent.network!!) {
!it.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED)
}
@@ -917,12 +912,10 @@
val history = ArrayTrackRecord<CallbackEntry>().newReadHead()
sealed class CallbackEntry {
- data class OnQosSessionAvailable(val sess: QosSession, val attr: QosSessionAttributes)
- : CallbackEntry()
- data class OnQosSessionLost(val sess: QosSession)
- : CallbackEntry()
- data class OnError(val ex: QosCallbackException)
- : CallbackEntry()
+ data class OnQosSessionAvailable(val sess: QosSession, val attr: QosSessionAttributes) :
+ CallbackEntry()
+ data class OnQosSessionLost(val sess: QosSession) : CallbackEntry()
+ data class OnError(val ex: QosCallbackException) : CallbackEntry()
}
override fun onQosSessionAvailable(sess: QosSession, attr: QosSessionAttributes) {
@@ -1330,14 +1323,10 @@
val (wifiAgent, wifiNetwork) = connectNetwork(TRANSPORT_WIFI)
testCallback.expectAvailableCallbacks(wifiNetwork, validated = true)
- testCallback.expectCapabilitiesThat(wifiNetwork) {
- it.hasCapability(NET_CAPABILITY_VALIDATED)
- }
+ testCallback.expectCaps(wifiNetwork) { it.hasCapability(NET_CAPABILITY_VALIDATED) }
matchAllCallback.expectAvailableCallbacks(wifiNetwork, validated = false)
matchAllCallback.expect<Losing>(cellNetwork)
- matchAllCallback.expectCapabilitiesThat(wifiNetwork) {
- it.hasCapability(NET_CAPABILITY_VALIDATED)
- }
+ matchAllCallback.expectCaps(wifiNetwork) { it.hasCapability(NET_CAPABILITY_VALIDATED) }
wifiAgent.unregisterAfterReplacement(5_000 /* timeoutMillis */)
wifiAgent.expectCallback<OnNetworkDestroyed>()
diff --git a/tests/cts/net/src/android/net/cts/NsdManagerTest.kt b/tests/cts/net/src/android/net/cts/NsdManagerTest.kt
index 66e7713..093c7f8 100644
--- a/tests/cts/net/src/android/net/cts/NsdManagerTest.kt
+++ b/tests/cts/net/src/android/net/cts/NsdManagerTest.kt
@@ -30,6 +30,7 @@
import android.net.TestNetworkInterface
import android.net.TestNetworkManager
import android.net.TestNetworkSpecifier
+import android.net.connectivity.ConnectivityCompatChanges
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStarted
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStopped
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.ServiceFound
@@ -40,8 +41,8 @@
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.ServiceRegistered
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.ServiceUnregistered
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.UnregistrationFailed
+import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolutionStopped
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolveFailed
-import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolveStopped
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ServiceResolved
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.StopResolutionFailed
import android.net.cts.NsdManagerTest.NsdServiceInfoCallbackRecord.ServiceInfoCallbackEvent.RegisterCallbackFailed
@@ -273,7 +274,7 @@
ResolveEvent()
data class ServiceResolved(val serviceInfo: NsdServiceInfo) : ResolveEvent()
- data class ResolveStopped(val serviceInfo: NsdServiceInfo) : ResolveEvent()
+ data class ResolutionStopped(val serviceInfo: NsdServiceInfo) : ResolveEvent()
data class StopResolutionFailed(val serviceInfo: NsdServiceInfo, val errorCode: Int) :
ResolveEvent()
}
@@ -286,8 +287,8 @@
add(ServiceResolved(si))
}
- override fun onResolveStopped(si: NsdServiceInfo) {
- add(ResolveStopped(si))
+ override fun onResolutionStopped(si: NsdServiceInfo) {
+ add(ResolutionStopped(si))
}
override fun onStopResolutionFailed(si: NsdServiceInfo, err: Int) {
@@ -783,7 +784,7 @@
// when the compat change is disabled.
// Note that before T the compat constant had a different int value.
assertFalse(CompatChanges.isChangeEnabled(
- NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER))
+ ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER))
}
@Test
@@ -798,10 +799,10 @@
val resolveRecord = NsdResolveRecord()
// Try to resolve an unknown service then stop it immediately.
- // Expected ResolveStopped callback.
+ // Expected ResolutionStopped callback.
nsdShim.resolveService(nsdManager, si, { it.run() }, resolveRecord)
nsdShim.stopServiceResolution(nsdManager, resolveRecord)
- val stoppedCb = resolveRecord.expectCallback<ResolveStopped>()
+ val stoppedCb = resolveRecord.expectCallback<ResolutionStopped>()
assertEquals(si.serviceName, stoppedCb.serviceInfo.serviceName)
assertEquals(si.serviceType, stoppedCb.serviceInfo.serviceType)
}
diff --git a/tests/integration/src/com/android/server/net/integrationtests/ConnectivityServiceIntegrationTest.kt b/tests/integration/src/com/android/server/net/integrationtests/ConnectivityServiceIntegrationTest.kt
index 26b058d..3c1340d 100644
--- a/tests/integration/src/com/android/server/net/integrationtests/ConnectivityServiceIntegrationTest.kt
+++ b/tests/integration/src/com/android/server/net/integrationtests/ConnectivityServiceIntegrationTest.kt
@@ -37,7 +37,6 @@
import android.net.TestNetworkStackClient
import android.net.Uri
import android.net.metrics.IpConnectivityLog
-import com.android.server.connectivity.MultinetworkPolicyTracker
import android.os.ConditionVariable
import android.os.IBinder
import android.os.SystemConfigManager
@@ -52,7 +51,9 @@
import com.android.server.NetworkAgentWrapper
import com.android.server.TestNetIdManager
import com.android.server.connectivity.MockableSystemProperties
+import com.android.server.connectivity.MultinetworkPolicyTracker
import com.android.server.connectivity.ProxyTracker
+import com.android.testutils.RecorderCallback.CallbackEntry.LinkPropertiesChanged
import com.android.testutils.TestableNetworkCallback
import org.junit.After
import org.junit.Before
@@ -73,8 +74,6 @@
import org.mockito.MockitoAnnotations
import org.mockito.Spy
import kotlin.test.assertEquals
-import kotlin.test.assertFalse
-import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail
@@ -289,15 +288,16 @@
testCb.expectAvailableCallbacks(na.network, validated = false, tmt = TEST_TIMEOUT_MS)
- val capportData = testCb.expectLinkPropertiesThat(na, TEST_TIMEOUT_MS) {
- it.captivePortalData != null
+ val capportData = testCb.expect<LinkPropertiesChanged>(na, TEST_TIMEOUT_MS) {
+ it.lp.captivePortalData != null
}.lp.captivePortalData
- assertNotNull(capportData)
assertTrue(capportData.isCaptive)
assertEquals(Uri.parse("https://login.capport.android.com"), capportData.userPortalUrl)
assertEquals(Uri.parse("https://venueinfo.capport.android.com"), capportData.venueInfoUrl)
- val nc = testCb.expectCapabilitiesWith(NET_CAPABILITY_CAPTIVE_PORTAL, na, TEST_TIMEOUT_MS)
- assertFalse(nc.hasCapability(NET_CAPABILITY_VALIDATED))
+ testCb.expectCaps(na, TEST_TIMEOUT_MS) {
+ it.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL) &&
+ !it.hasCapability(NET_CAPABILITY_VALIDATED)
+ }
}
-}
\ No newline at end of file
+}
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp
index e0de246..8db307d 100644
--- a/tests/unit/Android.bp
+++ b/tests/unit/Android.bp
@@ -114,6 +114,7 @@
"service-connectivity-pre-jarjar",
"service-connectivity-tiramisu-pre-jarjar",
"services.core-vpn",
+ "testables",
"cts-net-utils"
],
libs: [
diff --git a/tests/unit/java/android/net/NetworkTemplateTest.kt b/tests/unit/java/android/net/NetworkTemplateTest.kt
index 78854fb..edbcea9 100644
--- a/tests/unit/java/android/net/NetworkTemplateTest.kt
+++ b/tests/unit/java/android/net/NetworkTemplateTest.kt
@@ -443,6 +443,35 @@
}
@Test
+ fun testEquals() {
+ val templateImsi1 = NetworkTemplate.Builder(MATCH_MOBILE).setMeteredness(METERED_YES)
+ .setSubscriberIds(setOf(TEST_IMSI1)).setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
+ .build()
+ val dupTemplateImsi1 = NetworkTemplate(MATCH_MOBILE, arrayOf(TEST_IMSI1),
+ emptyArray<String>(), METERED_YES, ROAMING_ALL, DEFAULT_NETWORK_ALL,
+ TelephonyManager.NETWORK_TYPE_UMTS, OEM_MANAGED_ALL)
+ val templateImsi2 = NetworkTemplate.Builder(MATCH_MOBILE).setMeteredness(METERED_YES)
+ .setSubscriberIds(setOf(TEST_IMSI2)).setRatType(TelephonyManager.NETWORK_TYPE_UMTS)
+ .build()
+
+ assertEquals(templateImsi1, dupTemplateImsi1)
+ assertEquals(dupTemplateImsi1, templateImsi1)
+ assertNotEquals(templateImsi1, templateImsi2)
+
+ val templateWifiKey1 = NetworkTemplate.Builder(MATCH_WIFI)
+ .setWifiNetworkKeys(setOf(TEST_WIFI_KEY1)).build()
+ val dupTemplateWifiKey1 = NetworkTemplate(MATCH_WIFI, emptyArray<String>(),
+ arrayOf(TEST_WIFI_KEY1), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
+ NETWORK_TYPE_ALL, OEM_MANAGED_ALL)
+ val templateWifiKey2 = NetworkTemplate.Builder(MATCH_WIFI)
+ .setWifiNetworkKeys(setOf(TEST_WIFI_KEY2)).build()
+
+ assertEquals(templateWifiKey1, dupTemplateWifiKey1)
+ assertEquals(dupTemplateWifiKey1, templateWifiKey1)
+ assertNotEquals(templateWifiKey1, templateWifiKey2)
+ }
+
+ @Test
fun testParcelUnparcel() {
val templateMobile = NetworkTemplate(MATCH_MOBILE, arrayOf(TEST_IMSI1),
emptyArray<String>(), METERED_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL,
diff --git a/tests/unit/java/android/net/nsd/NsdManagerTest.java b/tests/unit/java/android/net/nsd/NsdManagerTest.java
index 8a4932b..da65b62 100644
--- a/tests/unit/java/android/net/nsd/NsdManagerTest.java
+++ b/tests/unit/java/android/net/nsd/NsdManagerTest.java
@@ -32,6 +32,7 @@
import android.compat.testing.PlatformCompatChangeRule;
import android.content.Context;
+import android.net.connectivity.ConnectivityCompatChanges;
import android.os.Build;
import androidx.test.filters.SmallTest;
@@ -81,70 +82,70 @@
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testResolveServiceS() throws Exception {
verify(mServiceConn, never()).startDaemon();
doTestResolveService();
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testResolveServicePreS() throws Exception {
verify(mServiceConn).startDaemon();
doTestResolveService();
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testDiscoverServiceS() throws Exception {
verify(mServiceConn, never()).startDaemon();
doTestDiscoverService();
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testDiscoverServicePreS() throws Exception {
verify(mServiceConn).startDaemon();
doTestDiscoverService();
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testParallelResolveServiceS() throws Exception {
verify(mServiceConn, never()).startDaemon();
doTestParallelResolveService();
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testParallelResolveServicePreS() throws Exception {
verify(mServiceConn).startDaemon();
doTestParallelResolveService();
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testInvalidCallsS() throws Exception {
verify(mServiceConn, never()).startDaemon();
doTestInvalidCalls();
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testInvalidCallsPreS() throws Exception {
verify(mServiceConn).startDaemon();
doTestInvalidCalls();
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testRegisterServiceS() throws Exception {
verify(mServiceConn, never()).startDaemon();
doTestRegisterService();
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testRegisterServicePreS() throws Exception {
verify(mServiceConn).startDaemon();
doTestRegisterService();
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index a2d284b..634d5c9 100755
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -138,6 +138,7 @@
import static android.net.OemNetworkPreferences.OEM_NETWORK_PREFERENCE_TEST;
import static android.net.OemNetworkPreferences.OEM_NETWORK_PREFERENCE_TEST_ONLY;
import static android.net.OemNetworkPreferences.OEM_NETWORK_PREFERENCE_UNINITIALIZED;
+import static android.net.Proxy.PROXY_CHANGE_ACTION;
import static android.net.RouteInfo.RTN_UNREACHABLE;
import static android.net.resolv.aidl.IDnsResolverUnsolicitedEventListener.PREFIX_OPERATION_ADDED;
import static android.net.resolv.aidl.IDnsResolverUnsolicitedEventListener.PREFIX_OPERATION_REMOVED;
@@ -171,6 +172,7 @@
import static com.android.testutils.MiscAsserts.assertThrows;
import static com.android.testutils.RecorderCallback.CallbackEntry.AVAILABLE;
import static com.android.testutils.RecorderCallback.CallbackEntry.BLOCKED_STATUS;
+import static com.android.testutils.RecorderCallback.CallbackEntry.BLOCKED_STATUS_INT;
import static com.android.testutils.RecorderCallback.CallbackEntry.LINK_PROPERTIES_CHANGED;
import static com.android.testutils.RecorderCallback.CallbackEntry.LOSING;
import static com.android.testutils.RecorderCallback.CallbackEntry.LOST;
@@ -376,6 +378,7 @@
import com.android.server.ConnectivityService.ConnectivityDiagnosticsCallbackInfo;
import com.android.server.ConnectivityService.NetworkRequestInfo;
import com.android.server.ConnectivityServiceTest.ConnectivityServiceDependencies.ReportedInterfaces;
+import com.android.server.connectivity.AutomaticOnOffKeepaliveTracker;
import com.android.server.connectivity.CarrierPrivilegeAuthenticator;
import com.android.server.connectivity.ClatCoordinator;
import com.android.server.connectivity.ConnectivityFlags;
@@ -537,6 +540,7 @@
private MockContext mServiceContext;
private HandlerThread mCsHandlerThread;
private ConnectivityServiceDependencies mDeps;
+ private AutomaticOnOffKeepaliveTrackerDependencies mAutoOnOffKeepaliveDependencies;
private ConnectivityService mService;
private WrappedConnectivityManager mCm;
private TestNetworkAgentWrapper mWiFiAgent;
@@ -1837,7 +1841,8 @@
doReturn(mResources).when(mockResContext).getResources();
ConnectivityResources.setResourcesContextForTest(mockResContext);
mDeps = new ConnectivityServiceDependencies(mockResContext);
-
+ mAutoOnOffKeepaliveDependencies =
+ new AutomaticOnOffKeepaliveTrackerDependencies(mServiceContext);
mService = new ConnectivityService(mServiceContext,
mMockDnsResolver,
mock(IpConnectivityLog.class),
@@ -1938,6 +1943,12 @@
}
@Override
+ public AutomaticOnOffKeepaliveTracker makeAutomaticOnOffKeepaliveTracker(final Context c,
+ final Handler h) {
+ return new AutomaticOnOffKeepaliveTracker(c, h, mAutoOnOffKeepaliveDependencies);
+ }
+
+ @Override
public ConnectivityResources getResources(final Context ctx) {
return mConnRes;
}
@@ -2095,6 +2106,20 @@
}
}
+ private class AutomaticOnOffKeepaliveTrackerDependencies
+ extends AutomaticOnOffKeepaliveTracker.Dependencies {
+ AutomaticOnOffKeepaliveTrackerDependencies(Context context) {
+ super(context);
+ }
+
+ @Override
+ public boolean isFeatureEnabled(@NonNull final String name) {
+ // Tests for enabling the feature are verified in AutomaticOnOffKeepaliveTrackerTest.
+ // Assuming enabled here to focus on ConnectivityService tests.
+ return true;
+ }
+ }
+
private static void initAlarmManager(final AlarmManager am, final Handler alarmHandler) {
doAnswer(inv -> {
final long when = inv.getArgument(1);
@@ -2273,22 +2298,15 @@
}
}
- /** Expects that {@code count} CONNECTIVITY_ACTION broadcasts are received. */
- private ExpectedBroadcast registerConnectivityBroadcast(final int count) {
- return registerConnectivityBroadcastThat(count, intent -> true);
- }
-
- private ExpectedBroadcast registerConnectivityBroadcastThat(final int count,
+ private ExpectedBroadcast registerBroadcastReceiverThat(final String action, final int count,
@NonNull final Predicate<Intent> filter) {
- final IntentFilter intentFilter = new IntentFilter(CONNECTIVITY_ACTION);
+ final IntentFilter intentFilter = new IntentFilter(action);
// AtomicReference allows receiver to access expected even though it is constructed later.
final AtomicReference<ExpectedBroadcast> expectedRef = new AtomicReference<>();
final BroadcastReceiver receiver = new BroadcastReceiver() {
private int mRemaining = count;
public void onReceive(Context context, Intent intent) {
- final int type = intent.getIntExtra(EXTRA_NETWORK_TYPE, -1);
- final NetworkInfo ni = intent.getParcelableExtra(EXTRA_NETWORK_INFO);
- Log.d(TAG, "Received CONNECTIVITY_ACTION type=" + type + " ni=" + ni);
+ logIntent(intent);
if (!filter.test(intent)) return;
if (--mRemaining == 0) {
expectedRef.get().complete(intent);
@@ -2301,39 +2319,49 @@
return expected;
}
+ private void logIntent(Intent intent) {
+ final String action = intent.getAction();
+ if (CONNECTIVITY_ACTION.equals(action)) {
+ final int type = intent.getIntExtra(EXTRA_NETWORK_TYPE, -1);
+ final NetworkInfo ni = intent.getParcelableExtra(EXTRA_NETWORK_INFO);
+ Log.d(TAG, "Received " + action + ", type=" + type + " ni=" + ni);
+ } else if (PROXY_CHANGE_ACTION.equals(action)) {
+ final ProxyInfo proxy = (ProxyInfo) intent.getExtra(
+ Proxy.EXTRA_PROXY_INFO, ProxyInfo.buildPacProxy(Uri.EMPTY));
+ Log.d(TAG, "Received " + action + ", proxy = " + proxy);
+ } else {
+ throw new IllegalArgumentException("Unsupported logging " + action);
+ }
+ }
+
+ /** Expects that {@code count} CONNECTIVITY_ACTION broadcasts are received. */
+ private ExpectedBroadcast expectConnectivityAction(final int count) {
+ return registerBroadcastReceiverThat(CONNECTIVITY_ACTION, count, intent -> true);
+ }
+
+ private ExpectedBroadcast expectConnectivityAction(int type, NetworkInfo.DetailedState state) {
+ return registerBroadcastReceiverThat(CONNECTIVITY_ACTION, 1, intent -> {
+ final int actualType = intent.getIntExtra(EXTRA_NETWORK_TYPE, -1);
+ final NetworkInfo ni = intent.getParcelableExtra(EXTRA_NETWORK_INFO);
+ return type == actualType
+ && state == ni.getDetailedState()
+ && extraInfoInBroadcastHasExpectedNullness(ni);
+ });
+ }
+
+ /** Expects that PROXY_CHANGE_ACTION broadcast is received. */
+ private ExpectedBroadcast expectProxyChangeAction() {
+ return registerBroadcastReceiverThat(PROXY_CHANGE_ACTION, 1, intent -> true);
+ }
+
private ExpectedBroadcast expectProxyChangeAction(ProxyInfo proxy) {
- return registerPacProxyBroadcastThat(intent -> {
+ return registerBroadcastReceiverThat(PROXY_CHANGE_ACTION, 1, intent -> {
final ProxyInfo actualProxy = (ProxyInfo) intent.getExtra(Proxy.EXTRA_PROXY_INFO,
ProxyInfo.buildPacProxy(Uri.EMPTY));
return proxy.equals(actualProxy);
});
}
- private ExpectedBroadcast registerPacProxyBroadcast() {
- return registerPacProxyBroadcastThat(intent -> true);
- }
-
- private ExpectedBroadcast registerPacProxyBroadcastThat(
- @NonNull final Predicate<Intent> filter) {
- final IntentFilter intentFilter = new IntentFilter(Proxy.PROXY_CHANGE_ACTION);
- // AtomicReference allows receiver to access expected even though it is constructed later.
- final AtomicReference<ExpectedBroadcast> expectedRef = new AtomicReference<>();
- final BroadcastReceiver receiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- final ProxyInfo proxy = (ProxyInfo) intent.getExtra(
- Proxy.EXTRA_PROXY_INFO, ProxyInfo.buildPacProxy(Uri.EMPTY));
- Log.d(TAG, "Receive PROXY_CHANGE_ACTION, proxy = " + proxy);
- if (filter.test(intent)) {
- expectedRef.get().complete(intent);
- }
- }
- };
- final ExpectedBroadcast expected = new ExpectedBroadcast(receiver);
- expectedRef.set(expected);
- mServiceContext.registerReceiver(receiver, intentFilter);
- return expected;
- }
-
private boolean extraInfoInBroadcastHasExpectedNullness(NetworkInfo ni) {
final DetailedState state = ni.getDetailedState();
if (state == DetailedState.CONNECTED && ni.getExtraInfo() == null) return false;
@@ -2349,16 +2377,6 @@
return true;
}
- private ExpectedBroadcast expectConnectivityAction(int type, NetworkInfo.DetailedState state) {
- return registerConnectivityBroadcastThat(1, intent -> {
- final int actualType = intent.getIntExtra(EXTRA_NETWORK_TYPE, -1);
- final NetworkInfo ni = intent.getParcelableExtra(EXTRA_NETWORK_INFO);
- return type == actualType
- && state == ni.getDetailedState()
- && extraInfoInBroadcastHasExpectedNullness(ni);
- });
- }
-
@Test
public void testNetworkTypes() {
// Ensure that our mocks for the networkAttributes config variable work as expected. If they
@@ -2393,7 +2411,7 @@
ConnectivityManager.REQUEST_ID_UNSET, NetworkRequest.Type.REQUEST);
// File request, withdraw it and make sure no broadcast is sent
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
final TestNetworkCallback callback = new TestNetworkCallback();
mCm.requestNetwork(legacyRequest, callback);
callback.expect(AVAILABLE, mCellAgent);
@@ -2424,7 +2442,7 @@
assertTrue(mCm.getAllNetworks()[0].equals(mWiFiAgent.getNetwork())
|| mCm.getAllNetworks()[1].equals(mWiFiAgent.getNetwork()));
// Test bringing up validated WiFi.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
@@ -2441,7 +2459,7 @@
assertLength(1, mCm.getAllNetworks());
assertEquals(mCm.getAllNetworks()[0], mCm.getActiveNetwork());
// Test WiFi disconnect.
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
mWiFiAgent.disconnect();
b.expectBroadcast();
verifyNoNetwork();
@@ -2607,7 +2625,7 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up unvalidated WiFi
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mWiFiAgent.connect(false);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
@@ -2622,17 +2640,17 @@
verifyActiveNetwork(TRANSPORT_WIFI);
// Test bringing up validated cellular
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mCellAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test cellular disconnect.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mCellAgent.disconnect();
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
// Test WiFi disconnect.
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
mWiFiAgent.disconnect();
b.expectBroadcast();
verifyNoNetwork();
@@ -2655,23 +2673,23 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up unvalidated cellular.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mCellAgent.connect(false);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test bringing up unvalidated WiFi.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.connect(false);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
// Test WiFi disconnect.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.disconnect();
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test cellular disconnect.
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
mCellAgent.disconnect();
b.expectBroadcast();
verifyNoNetwork();
@@ -2694,7 +2712,7 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up unvalidated WiFi.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mWiFiAgent.connect(false);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
@@ -2702,14 +2720,14 @@
NET_CAPABILITY_VALIDATED));
// Test bringing up validated cellular.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mCellAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
assertFalse(mCm.getNetworkCapabilities(mWiFiAgent.getNetwork()).hasCapability(
NET_CAPABILITY_VALIDATED));
// Test cellular disconnect.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mCellAgent.disconnect();
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
@@ -2771,7 +2789,7 @@
if (expectLingering) {
generalCb.expectLosing(net1);
}
- generalCb.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, net2);
+ generalCb.expectCaps(net2, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
defaultCb.expectAvailableDoubleValidatedCallbacks(net2);
// Make sure cell 1 is unwanted immediately if the radio can't time share, but only
@@ -2849,23 +2867,23 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up validated cellular.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mCellAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test bringing up validated WiFi.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
// Test WiFi getting really weak.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.adjustScore(-11);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test WiFi restoring signal strength.
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.adjustScore(11);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
@@ -2930,18 +2948,18 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up validated cellular.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mCellAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Test bringing up validated WiFi.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
// Reevaluate WiFi (it'll instantly fail DNS).
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
assertTrue(mCm.getNetworkCapabilities(mWiFiAgent.getNetwork()).hasCapability(
NET_CAPABILITY_VALIDATED));
mCm.reportBadNetwork(mWiFiAgent.getNetwork());
@@ -2951,7 +2969,7 @@
NET_CAPABILITY_VALIDATED));
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Reevaluate cellular (it'll instantly fail DNS).
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
assertTrue(mCm.getNetworkCapabilities(mCellAgent.getNetwork()).hasCapability(
NET_CAPABILITY_VALIDATED));
mCm.reportBadNetwork(mCellAgent.getNetwork());
@@ -2981,18 +2999,18 @@
mService.mCellularRadioTimesharingCapable = cellRadioTimesharingCapable;
// Test bringing up unvalidated WiFi.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mWiFiAgent.connect(false);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_WIFI);
// Test bringing up validated cellular.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mCellAgent.connect(true);
b.expectBroadcast();
verifyActiveNetwork(TRANSPORT_CELLULAR);
// Reevaluate cellular (it'll instantly fail DNS).
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
assertTrue(mCm.getNetworkCapabilities(mCellAgent.getNetwork()).hasCapability(
NET_CAPABILITY_VALIDATED));
mCm.reportBadNetwork(mCellAgent.getNetwork());
@@ -3070,9 +3088,8 @@
NetworkSpecifier specifier, TestNetworkCallback ... callbacks) {
for (TestNetworkCallback c : callbacks) {
c.expect(AVAILABLE, network);
- c.expectCapabilitiesThat(network, (nc) ->
- !nc.hasCapability(NET_CAPABILITY_VALIDATED)
- && Objects.equals(specifier, nc.getNetworkSpecifier()));
+ c.expectCaps(network, cb -> !cb.hasCapability(NET_CAPABILITY_VALIDATED)
+ && Objects.equals(specifier, cb.getNetworkSpecifier()));
c.expect(LINK_PROPERTIES_CHANGED, network);
c.expect(BLOCKED_STATUS, network);
}
@@ -3131,7 +3148,7 @@
mCm.registerNetworkCallback(cellRequest, cellNetworkCallback);
// Test unvalidated networks
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
mCellAgent.connect(false);
genericNetworkCallback.expectAvailableCallbacksUnvalidated(mCellAgent);
@@ -3146,7 +3163,7 @@
assertNoCallbacks(genericNetworkCallback, wifiNetworkCallback, cellNetworkCallback);
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.connect(false);
genericNetworkCallback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
@@ -3155,18 +3172,18 @@
b.expectBroadcast();
assertNoCallbacks(genericNetworkCallback, wifiNetworkCallback, cellNetworkCallback);
- b = registerConnectivityBroadcast(2);
+ b = expectConnectivityAction(2);
mWiFiAgent.disconnect();
- genericNetworkCallback.expect(LOST, mWiFiAgent);
- wifiNetworkCallback.expect(LOST, mWiFiAgent);
+ genericNetworkCallback.expect(CallbackEntry.LOST, mWiFiAgent);
+ wifiNetworkCallback.expect(CallbackEntry.LOST, mWiFiAgent);
cellNetworkCallback.assertNoCallback();
b.expectBroadcast();
assertNoCallbacks(genericNetworkCallback, wifiNetworkCallback, cellNetworkCallback);
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
mCellAgent.disconnect();
- genericNetworkCallback.expect(LOST, mCellAgent);
- cellNetworkCallback.expect(LOST, mCellAgent);
+ genericNetworkCallback.expect(CallbackEntry.LOST, mCellAgent);
+ cellNetworkCallback.expect(CallbackEntry.LOST, mCellAgent);
b.expectBroadcast();
assertNoCallbacks(genericNetworkCallback, wifiNetworkCallback, cellNetworkCallback);
@@ -3188,7 +3205,8 @@
mWiFiAgent.connect(true);
genericNetworkCallback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
genericNetworkCallback.expectLosing(mCellAgent);
- genericNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ genericNetworkCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
wifiNetworkCallback.expectAvailableThenValidatedCallbacks(mWiFiAgent);
cellNetworkCallback.expectLosing(mCellAgent);
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
@@ -3229,17 +3247,17 @@
final Uri expectedCapportUrl = sanitized ? null : capportUrl;
newLp.setCaptivePortalApiUrl(capportUrl);
mWiFiAgent.sendLinkProperties(newLp);
- callback.expectLinkPropertiesThat(mWiFiAgent, lp ->
- Objects.equals(expectedCapportUrl, lp.getCaptivePortalApiUrl()));
- defaultCallback.expectLinkPropertiesThat(mWiFiAgent, lp ->
- Objects.equals(expectedCapportUrl, lp.getCaptivePortalApiUrl()));
+ callback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent, cb ->
+ Objects.equals(expectedCapportUrl, cb.getLp().getCaptivePortalApiUrl()));
+ defaultCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent, cb ->
+ Objects.equals(expectedCapportUrl, cb.getLp().getCaptivePortalApiUrl()));
final CaptivePortalData expectedCapportData = sanitized ? null : capportData;
mWiFiAgent.notifyCapportApiDataChanged(capportData);
- callback.expectLinkPropertiesThat(mWiFiAgent, lp ->
- Objects.equals(expectedCapportData, lp.getCaptivePortalData()));
- defaultCallback.expectLinkPropertiesThat(mWiFiAgent, lp ->
- Objects.equals(expectedCapportData, lp.getCaptivePortalData()));
+ callback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent, cb ->
+ Objects.equals(expectedCapportData, cb.getLp().getCaptivePortalData()));
+ defaultCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent, cb ->
+ Objects.equals(expectedCapportData, cb.getLp().getCaptivePortalData()));
final LinkProperties lp = mCm.getLinkProperties(mWiFiAgent.getNetwork());
assertEquals(expectedCapportUrl, lp.getCaptivePortalApiUrl());
@@ -3337,7 +3355,7 @@
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
// TODO: Investigate sending validated before losing.
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
defaultCallback.expectAvailableDoubleValidatedCallbacks(mWiFiAgent);
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
@@ -3346,7 +3364,7 @@
callback.expectAvailableCallbacksUnvalidated(mEthernetAgent);
// TODO: Investigate sending validated before losing.
callback.expectLosing(mWiFiAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mEthernetAgent);
+ callback.expectCaps(mEthernetAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
defaultCallback.expectAvailableDoubleValidatedCallbacks(mEthernetAgent);
assertEquals(mEthernetAgent.getNetwork(), mCm.getActiveNetwork());
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
@@ -3381,7 +3399,7 @@
// if the network is still up.
mWiFiAgent.removeCapability(NET_CAPABILITY_NOT_METERED);
// We expect a notification about the capabilities change, and nothing else.
- defaultCallback.expectCapabilitiesWithout(NET_CAPABILITY_NOT_METERED, mWiFiAgent);
+ defaultCallback.expectCaps(mWiFiAgent, c -> !c.hasCapability(NET_CAPABILITY_NOT_METERED));
defaultCallback.assertNoCallback();
callback.expect(LOST, mWiFiAgent);
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
@@ -3440,7 +3458,7 @@
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
// TODO: Investigate sending validated before losing.
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
defaultCallback.expectAvailableThenValidatedCallbacks(mWiFiAgent);
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
@@ -3467,7 +3485,7 @@
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
// TODO: Investigate sending validated before losing.
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
NetworkRequest cellRequest = new NetworkRequest.Builder()
@@ -3517,7 +3535,7 @@
mEthernetAgent.connect(true);
callback.expectAvailableCallbacksUnvalidated(mEthernetAgent);
callback.expectLosing(mWiFiAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mEthernetAgent);
+ callback.expectCaps(mEthernetAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
trackDefaultCallback.expectAvailableDoubleValidatedCallbacks(mEthernetAgent);
defaultCallback.expectAvailableDoubleValidatedCallbacks(mEthernetAgent);
assertEquals(defaultCallback.getLastAvailableNetwork(), mCm.getActiveNetwork());
@@ -3577,7 +3595,7 @@
defaultCallback.expectAvailableDoubleValidatedCallbacks(mWiFiAgent);
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
// File a request for cellular, then release it.
NetworkRequest cellRequest = new NetworkRequest.Builder()
@@ -3590,7 +3608,8 @@
// Let linger run its course.
callback.assertNoCallback();
final int lingerTimeoutMs = TEST_LINGER_DELAY_MS + TEST_LINGER_DELAY_MS / 4;
- callback.expectCapabilitiesWithout(NET_CAPABILITY_FOREGROUND, mCellAgent, lingerTimeoutMs);
+ callback.expectCaps(mCellAgent, lingerTimeoutMs,
+ c -> !c.hasCapability(NET_CAPABILITY_FOREGROUND));
// Clean up.
mCm.unregisterNetworkCallback(defaultCallback);
@@ -3812,7 +3831,7 @@
mWiFiAgent.connect(true);
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
expectUnvalidationCheckWillNotNotify(mWiFiAgent);
@@ -3820,7 +3839,7 @@
mEthernetAgent.connect(true);
callback.expectAvailableCallbacksUnvalidated(mEthernetAgent);
callback.expectLosing(mWiFiAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mEthernetAgent);
+ callback.expectCaps(mEthernetAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertEquals(mEthernetAgent.getNetwork(), mCm.getActiveNetwork());
callback.assertNoCallback();
@@ -4268,7 +4287,7 @@
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.connectWithPartialConnectivity();
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
// Mobile data should be the default network.
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
@@ -4296,8 +4315,8 @@
// validated.
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
callback.expectLosing(mCellAgent);
- NetworkCapabilities nc = callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED,
- mWiFiAgent);
+ NetworkCapabilities nc =
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertTrue(nc.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
@@ -4311,7 +4330,7 @@
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.connectWithPartialConnectivity();
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
// Mobile data should be the default network.
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
@@ -4343,7 +4362,7 @@
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
verify(mWiFiAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity();
callback.expectLosing(mCellAgent);
- nc = callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ nc = callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertFalse(nc.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
// Wifi should be the default network.
@@ -4364,7 +4383,7 @@
verify(mWiFiAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity();
callback.expectLosing(mCellAgent);
assertEquals(mWiFiAgent.getNetwork(), mCm.getActiveNetwork());
- callback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
expectUnvalidationCheckWillNotNotify(mWiFiAgent);
mWiFiAgent.setNetworkValid(false /* privateDnsProbeSent */);
@@ -4372,7 +4391,7 @@
// Need a trigger point to let NetworkMonitor tell ConnectivityService that the network is
// validated.
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
mWiFiAgent.disconnect();
callback.expect(LOST, mWiFiAgent);
@@ -4388,8 +4407,8 @@
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
verify(mWiFiAgent.mNetworkMonitor, times(1)).setAcceptPartialConnectivity();
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(
- NET_CAPABILITY_PARTIAL_CONNECTIVITY | NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY)
+ && c.hasCapability(NET_CAPABILITY_VALIDATED));
expectUnvalidationCheckWillNotNotify(mWiFiAgent);
mWiFiAgent.disconnect();
callback.expect(LOST, mWiFiAgent);
@@ -4420,7 +4439,7 @@
// This is necessary because of b/245893397, the same bug that happens where we use
// expectAvailableDoubleValidatedCallbacks.
// TODO : fix b/245893397 and remove this.
- wifiCallback.expectCapabilitiesWith(NET_CAPABILITY_CAPTIVE_PORTAL, mWiFiAgent);
+ wifiCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
// Check that startCaptivePortalApp sends the expected command to NetworkMonitor.
mCm.startCaptivePortalApp(mWiFiAgent.getNetwork());
@@ -4431,9 +4450,9 @@
mWiFiAgent.setNetworkPartial();
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
waitForIdle();
- wifiCallback.expectCapabilitiesThat(mWiFiAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY)
- && !nc.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
+ wifiCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY)
+ && !c.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
// Report partial connectivity is accepted.
mWiFiAgent.setNetworkPartialValid(false /* privateDnsProbeSent */);
@@ -4441,9 +4460,10 @@
false /* always */);
waitForIdle();
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
- wifiCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ wifiCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
validatedCallback.expectAvailableCallbacksValidated(mWiFiAgent);
- validatedCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiAgent);
+ validatedCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
mCm.unregisterNetworkCallback(wifiCallback);
mCm.unregisterNetworkCallback(validatedCallback);
@@ -4552,7 +4572,7 @@
// This is necessary because of b/245893397, the same bug that happens where we use
// expectAvailableDoubleValidatedCallbacks.
// TODO : fix b/245893397 and remove this.
- captivePortalCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
+ captivePortalCallback.expectCaps(mWiFiAgent);
startCaptivePortalApp(mWiFiAgent);
@@ -4645,15 +4665,16 @@
mWiFiAgent.notifyCapportApiDataChanged(testData);
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> testData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> testData.equals(cb.getLp().getCaptivePortalData()));
final LinkProperties newLps = new LinkProperties();
newLps.setMtu(1234);
mWiFiAgent.sendLinkProperties(newLps);
// CaptivePortalData is not lost and unchanged when LPs are received from the NetworkAgent
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> testData.equals(lp.getCaptivePortalData()) && lp.getMtu() == 1234);
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> testData.equals(cb.getLp().getCaptivePortalData())
+ && cb.getLp().getMtu() == 1234);
}
private TestNetworkCallback setupNetworkCallbackAndConnectToWifi() throws Exception {
@@ -4747,8 +4768,8 @@
// Baseline capport data
mWiFiAgent.notifyCapportApiDataChanged(captivePortalTestData.mCapportData);
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mCapportData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mCapportData.equals(cb.getLp().getCaptivePortalData()));
// Venue URL, T&C URL and friendly name from Network agent with Passpoint source, confirm
// that API data gets precedence on the bytes remaining.
@@ -4757,9 +4778,9 @@
mWiFiAgent.sendLinkProperties(linkProperties);
// Make sure that the capport data is merged
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mExpectedMergedPasspointData
- .equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mExpectedMergedPasspointData.equals(
+ cb.getLp().getCaptivePortalData()));
// Now send this information from non-Passpoint source, confirm that Capport data takes
// precedence
@@ -4767,9 +4788,9 @@
mWiFiAgent.sendLinkProperties(linkProperties);
// Make sure that the capport data is merged
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mExpectedMergedOtherData
- .equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mExpectedMergedOtherData.equals(
+ cb.getLp().getCaptivePortalData()));
// Create a new LP with no Network agent capport data
final LinkProperties newLps = new LinkProperties();
@@ -4777,21 +4798,22 @@
mWiFiAgent.sendLinkProperties(newLps);
// CaptivePortalData is not lost and has the original values when LPs are received from the
// NetworkAgent
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mCapportData.equals(lp.getCaptivePortalData())
- && lp.getMtu() == 1234);
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mCapportData.equals(cb.getLp().getCaptivePortalData())
+ && cb.getLp().getMtu() == 1234);
// Now send capport data only from the Network agent
mWiFiAgent.notifyCapportApiDataChanged(null);
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> lp.getCaptivePortalData() == null);
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> cb.getLp().getCaptivePortalData() == null);
newLps.setCaptivePortalData(captivePortalTestData.mNaPasspointData);
mWiFiAgent.sendLinkProperties(newLps);
// Make sure that only the network agent capport data is available
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mNaPasspointData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mNaPasspointData.equals(
+ cb.getLp().getCaptivePortalData()));
}
@Test
@@ -4806,25 +4828,26 @@
mWiFiAgent.sendLinkProperties(linkProperties);
// Make sure that the data is saved correctly
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mNaPasspointData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mNaPasspointData.equals(
+ cb.getLp().getCaptivePortalData()));
// Expected merged data: Network agent data is preferred, and values that are not used by
// it are merged from capport data
mWiFiAgent.notifyCapportApiDataChanged(captivePortalTestData.mCapportData);
// Make sure that the Capport data is merged correctly
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mExpectedMergedPasspointData.equals(
- lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mExpectedMergedPasspointData.equals(
+ cb.getLp().getCaptivePortalData()));
// Now set the naData to null
linkProperties.setCaptivePortalData(null);
mWiFiAgent.sendLinkProperties(linkProperties);
// Make sure that the Capport data is retained correctly
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mCapportData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mCapportData.equals(cb.getLp().getCaptivePortalData()));
}
@Test
@@ -4840,17 +4863,17 @@
mWiFiAgent.sendLinkProperties(linkProperties);
// Make sure that the data is saved correctly
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mNaOtherData.equals(lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mNaOtherData.equals(cb.getLp().getCaptivePortalData()));
// Expected merged data: Network agent data is preferred, and values that are not used by
// it are merged from capport data
mWiFiAgent.notifyCapportApiDataChanged(captivePortalTestData.mCapportData);
// Make sure that the Capport data is merged correctly
- captivePortalCallback.expectLinkPropertiesThat(mWiFiAgent,
- lp -> captivePortalTestData.mExpectedMergedOtherData.equals(
- lp.getCaptivePortalData()));
+ captivePortalCallback.expect(LINK_PROPERTIES_CHANGED, mWiFiAgent,
+ cb -> captivePortalTestData.mExpectedMergedOtherData.equals(
+ cb.getLp().getCaptivePortalData()));
}
private NetworkRequest.Builder newWifiRequestBuilder() {
@@ -5239,7 +5262,8 @@
// Suspend the network.
mCellAgent.suspend();
- cellNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_NOT_SUSPENDED, mCellAgent);
+ cellNetworkCallback.expectCaps(mCellAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
cellNetworkCallback.expect(SUSPENDED, mCellAgent);
cellNetworkCallback.assertNoCallback();
assertEquals(NetworkInfo.State.SUSPENDED, mCm.getActiveNetworkInfo().getState());
@@ -5254,7 +5278,8 @@
mCm.unregisterNetworkCallback(dfltNetworkCallback);
mCellAgent.resume();
- cellNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_NOT_SUSPENDED, mCellAgent);
+ cellNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
cellNetworkCallback.expect(RESUMED, mCellAgent);
cellNetworkCallback.assertNoCallback();
assertEquals(NetworkInfo.State.CONNECTED, mCm.getActiveNetworkInfo().getState());
@@ -5481,10 +5506,10 @@
// When wifi connects, cell lingers.
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
callback.expectLosing(mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
fgCallback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
fgCallback.expectLosing(mCellAgent);
- fgCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ fgCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
assertTrue(isForegroundNetwork(mCellAgent));
assertTrue(isForegroundNetwork(mWiFiAgent));
@@ -5493,7 +5518,7 @@
int timeoutMs = TEST_LINGER_DELAY_MS + TEST_LINGER_DELAY_MS / 4;
fgCallback.expect(LOST, mCellAgent, timeoutMs);
// Expect a network capabilities update sans FOREGROUND.
- callback.expectCapabilitiesWithout(NET_CAPABILITY_FOREGROUND, mCellAgent);
+ callback.expectCaps(mCellAgent, c -> !c.hasCapability(NET_CAPABILITY_FOREGROUND));
assertFalse(isForegroundNetwork(mCellAgent));
assertTrue(isForegroundNetwork(mWiFiAgent));
@@ -5506,8 +5531,8 @@
fgCallback.expectAvailableCallbacksValidated(mCellAgent);
// Expect a network capabilities update with FOREGROUND, because the most recent
// request causes its state to change.
- cellCallback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellAgent);
- callback.expectCapabilitiesWith(NET_CAPABILITY_FOREGROUND, mCellAgent);
+ cellCallback.expectCaps(mCellAgent, c -> c.hasCapability(NET_CAPABILITY_FOREGROUND));
+ callback.expectCaps(mCellAgent, c -> c.hasCapability(NET_CAPABILITY_FOREGROUND));
assertTrue(isForegroundNetwork(mCellAgent));
assertTrue(isForegroundNetwork(mWiFiAgent));
@@ -5516,7 +5541,7 @@
mCm.unregisterNetworkCallback(cellCallback);
fgCallback.expect(LOST, mCellAgent);
// Expect a network capabilities update sans FOREGROUND.
- callback.expectCapabilitiesWithout(NET_CAPABILITY_FOREGROUND, mCellAgent);
+ callback.expectCaps(mCellAgent, c -> !c.hasCapability(NET_CAPABILITY_FOREGROUND));
assertFalse(isForegroundNetwork(mCellAgent));
assertTrue(isForegroundNetwork(mWiFiAgent));
@@ -5668,7 +5693,8 @@
// Need a trigger point to let NetworkMonitor tell ConnectivityService that network is
// validated – see testPartialConnectivity.
mCm.reportNetworkConnectivity(mCellAgent.getNetwork(), true);
- cellNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mCellAgent);
+ cellNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
testFactory.expectRequestRemove();
testFactory.assertRequestCountEquals(0);
// Accordingly, the factory shouldn't be started.
@@ -5869,14 +5895,15 @@
mWiFiAgent.setNetworkValid(true /* privateDnsProbeSent */);
// Have CS reconsider the network (see testPartialConnectivity)
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
- wifiNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
cellCallback.expectOnNetworkUnneeded(defaultCaps);
wifiCallback.assertNoCallback();
// Wifi is no longer validated. Cell is needed again.
mWiFiAgent.setNetworkInvalid(true /* invalidBecauseOfPrivateDns */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), false);
- wifiNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_VALIDATED));
cellCallback.expectOnNetworkNeeded(defaultCaps);
wifiCallback.assertNoCallback();
@@ -5898,7 +5925,8 @@
wifiCallback.assertNoCallback();
mWiFiAgent.setNetworkValid(true /* privateDnsProbeSent */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
- wifiNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
cellCallback.expectOnNetworkUnneeded(defaultCaps);
wifiCallback.assertNoCallback();
@@ -5906,7 +5934,8 @@
// not needed.
mWiFiAgent.setNetworkInvalid(true /* invalidBecauseOfPrivateDns */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), false);
- wifiNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_VALIDATED));
cellCallback.assertNoCallback();
wifiCallback.assertNoCallback();
}
@@ -6001,7 +6030,7 @@
// Fail validation on wifi.
mWiFiAgent.setNetworkInvalid(false /* invalidBecauseOfPrivateDns */);
mCm.reportNetworkConnectivity(wifiNetwork, false);
- defaultCallback.expectCapabilitiesWithout(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ defaultCallback.expectCaps(mWiFiAgent, c -> !c.hasCapability(NET_CAPABILITY_VALIDATED));
validatedWifiCallback.expect(LOST, mWiFiAgent);
expectNotification(mWiFiAgent, NotificationType.LOST_INTERNET);
@@ -6052,7 +6081,7 @@
// Fail validation on wifi and expect the dialog to appear.
mWiFiAgent.setNetworkInvalid(false /* invalidBecauseOfPrivateDns */);
mCm.reportNetworkConnectivity(wifiNetwork, false);
- defaultCallback.expectCapabilitiesWithout(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ defaultCallback.expectCaps(mWiFiAgent, c -> !c.hasCapability(NET_CAPABILITY_VALIDATED));
validatedWifiCallback.expect(LOST, mWiFiAgent);
expectNotification(mWiFiAgent, NotificationType.LOST_INTERNET);
@@ -6998,7 +7027,7 @@
assertNotPinnedToWifi();
// Disconnect cell and wifi.
- ExpectedBroadcast b = registerConnectivityBroadcast(3); // cell down, wifi up, wifi down.
+ ExpectedBroadcast b = expectConnectivityAction(3); // cell down, wifi up, wifi down.
mCellAgent.disconnect();
mWiFiAgent.disconnect();
b.expectBroadcast();
@@ -7011,7 +7040,7 @@
assertPinnedToWifiWithWifiDefault();
// ... and is maintained even when that network is no longer the default.
- b = registerConnectivityBroadcast(1);
+ b = expectConnectivityAction(1);
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mCellAgent.connect(true);
b.expectBroadcast();
@@ -7188,7 +7217,7 @@
@Test
public void testNetworkInfoOfTypeNone() throws Exception {
- ExpectedBroadcast b = registerConnectivityBroadcast(1);
+ ExpectedBroadcast b = expectConnectivityAction(1);
verifyNoNetwork();
TestNetworkAgentWrapper wifiAware = new TestNetworkAgentWrapper(TRANSPORT_WIFI_AWARE);
@@ -7269,7 +7298,7 @@
CallbackEntry.LinkPropertiesChanged cbi =
networkCallback.expect(LINK_PROPERTIES_CHANGED, networkAgent);
networkCallback.expect(BLOCKED_STATUS, networkAgent);
- networkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, networkAgent);
+ networkCallback.expectCaps(networkAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
networkCallback.assertNoCallback();
checkDirectlyConnectedRoutes(cbi.getLp(), asList(myIpv4Address),
asList(myIpv4DefaultRoute));
@@ -7583,8 +7612,7 @@
TestNetworkCallback callback = new TestNetworkCallback();
mCm.registerDefaultNetworkCallback(callback);
callback.expect(AVAILABLE, mCellAgent);
- callback.expectCapabilitiesThat(
- mCellAgent, nc -> Arrays.equals(adminUids, nc.getAdministratorUids()));
+ callback.expectCaps(mCellAgent, c -> Arrays.equals(adminUids, c.getAdministratorUids()));
mCm.unregisterNetworkCallback(callback);
// Verify case where caller does NOT have permission
@@ -7594,7 +7622,7 @@
callback = new TestNetworkCallback();
mCm.registerDefaultNetworkCallback(callback);
callback.expect(AVAILABLE, mCellAgent);
- callback.expectCapabilitiesThat(mCellAgent, nc -> nc.getAdministratorUids().length == 0);
+ callback.expectCaps(mCellAgent, c -> c.getAdministratorUids().length == 0);
}
@Test
@@ -8177,8 +8205,7 @@
mMockVpn.setUnderlyingNetworks(new Network[]{wifiNetwork});
// onCapabilitiesChanged() should be called because
// NetworkCapabilities#mUnderlyingNetworks is updated.
- CallbackEntry ce = callback.expect(NETWORK_CAPS_UPDATED, mMockVpn);
- final NetworkCapabilities vpnNc1 = ((CallbackEntry.CapabilitiesChanged) ce).getCaps();
+ final NetworkCapabilities vpnNc1 = callback.expectCaps(mMockVpn);
// Since the wifi network hasn't brought up,
// ConnectivityService#applyUnderlyingCapabilities cannot find it. Update
// NetworkCapabilities#mUnderlyingNetworks to an empty array, and it will be updated to
@@ -8213,8 +8240,7 @@
// 2. When a network connects, updateNetworkInfo propagates underlying network
// capabilities before rematching networks.
// Given that this scenario can't really happen, this is probably fine for now.
- ce = callback.expect(NETWORK_CAPS_UPDATED, mMockVpn);
- final NetworkCapabilities vpnNc2 = ((CallbackEntry.CapabilitiesChanged) ce).getCaps();
+ final NetworkCapabilities vpnNc2 = callback.expectCaps(mMockVpn);
// The wifi network is brought up, NetworkCapabilities#mUnderlyingNetworks is updated to
// it.
underlyingNetwork.add(wifiNetwork);
@@ -8228,8 +8254,8 @@
// Disconnect the network, and expect to see the VPN capabilities change accordingly.
mWiFiAgent.disconnect();
callback.expect(LOST, mWiFiAgent);
- callback.expectCapabilitiesThat(mMockVpn, (nc) ->
- nc.getTransportTypes().length == 1 && nc.hasTransport(TRANSPORT_VPN));
+ callback.expectCaps(mMockVpn, c -> c.getTransportTypes().length == 1
+ && c.hasTransport(TRANSPORT_VPN));
mMockVpn.disconnect();
mCm.unregisterNetworkCallback(callback);
@@ -8255,9 +8281,8 @@
// Connect cellular data.
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
mCellAgent.connect(false /* validated */);
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
callback.assertNoCallback();
assertTrue(mCm.getNetworkCapabilities(mMockVpn.getNetwork())
@@ -8270,9 +8295,8 @@
// Suspend the cellular network and expect the VPN to be suspended.
mCellAgent.suspend();
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> !nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> !c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
callback.expect(SUSPENDED, mMockVpn);
callback.assertNoCallback();
@@ -8288,9 +8312,8 @@
// Switch to another network. The VPN should no longer be suspended.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.connect(false /* validated */);
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_WIFI));
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_WIFI));
callback.expect(RESUMED, mMockVpn);
callback.assertNoCallback();
@@ -8306,13 +8329,11 @@
mCellAgent.resume();
callback.assertNoCallback();
mWiFiAgent.disconnect();
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
// Spurious double callback?
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
callback.assertNoCallback();
assertTrue(mCm.getNetworkCapabilities(mMockVpn.getNetwork())
@@ -8325,9 +8346,8 @@
// Suspend cellular and expect no connectivity.
mCellAgent.suspend();
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> !nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> !c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
callback.expect(SUSPENDED, mMockVpn);
callback.assertNoCallback();
@@ -8341,9 +8361,8 @@
// Resume cellular and expect that connectivity comes back.
mCellAgent.resume();
- callback.expectCapabilitiesThat(mMockVpn,
- nc -> nc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
- && nc.hasTransport(TRANSPORT_CELLULAR));
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED)
+ && c.hasTransport(TRANSPORT_CELLULAR));
callback.expect(RESUMED, mMockVpn);
callback.assertNoCallback();
@@ -8432,7 +8451,7 @@
// can't currently update their UIDs without disconnecting, so this does not matter too
// much, but that is the reason the test here has to check for an update to the
// capabilities instead of the expected LOST then AVAILABLE.
- defaultCallback.expect(NETWORK_CAPS_UPDATED, mMockVpn);
+ defaultCallback.expectCaps(mMockVpn);
systemDefaultCallback.assertNoCallback();
ranges.add(new UidRange(uid, uid));
@@ -8444,7 +8463,7 @@
vpnNetworkCallback.expectAvailableCallbacksValidated(mMockVpn);
// TODO : Here like above, AVAILABLE would be correct, but because this can't actually
// happen outside of the test, ConnectivityService does not rematch callbacks.
- defaultCallback.expect(NETWORK_CAPS_UPDATED, mMockVpn);
+ defaultCallback.expectCaps(mMockVpn);
systemDefaultCallback.assertNoCallback();
mWiFiAgent.disconnect();
@@ -8565,7 +8584,7 @@
mMockVpn.getAgent().mNetworkMonitor.forceReevaluation(Process.myUid());
// Expect to see the validated capability, but no other changes, because the VPN is already
// the default network for the app.
- callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mMockVpn);
+ callback.expectCaps(mMockVpn, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
callback.assertNoCallback();
mMockVpn.disconnect();
@@ -8597,8 +8616,8 @@
vpnNetworkCallback.expectAvailableCallbacks(mMockVpn.getNetwork(),
false /* suspended */, false /* validated */, false /* blocked */, TIMEOUT_MS);
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn.getNetwork(), TIMEOUT_MS,
- nc -> nc.hasCapability(NET_CAPABILITY_VALIDATED));
+ vpnNetworkCallback.expectCaps(mMockVpn.getNetwork(), TIMEOUT_MS,
+ c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
final NetworkCapabilities nc = mCm.getNetworkCapabilities(mMockVpn.getNetwork());
assertTrue(nc.hasTransport(TRANSPORT_VPN));
@@ -8660,11 +8679,12 @@
mMockVpn.setUnderlyingNetworks(new Network[] { mCellAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
assertDefaultNetworkCapabilities(userId, mCellAgent);
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
@@ -8675,62 +8695,68 @@
mMockVpn.setUnderlyingNetworks(
new Network[] { mCellAgent.getNetwork(), mWiFiAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
assertDefaultNetworkCapabilities(userId, mCellAgent, mWiFiAgent);
// Don't disconnect, but note the VPN is not using wifi any more.
mMockVpn.setUnderlyingNetworks(new Network[] { mCellAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
// The return value of getDefaultNetworkCapabilitiesForUser always includes the default
// network (wifi) as well as the underlying networks (cell).
assertDefaultNetworkCapabilities(userId, mCellAgent, mWiFiAgent);
// Remove NOT_SUSPENDED from the only network and observe VPN is now suspended.
mCellAgent.removeCapability(NET_CAPABILITY_NOT_SUSPENDED);
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && !caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && !c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
vpnNetworkCallback.expect(SUSPENDED, mMockVpn);
// Add NOT_SUSPENDED again and observe VPN is no longer suspended.
mCellAgent.addCapability(NET_CAPABILITY_NOT_SUSPENDED);
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
vpnNetworkCallback.expect(RESUMED, mMockVpn);
// Use Wifi but not cell. Note the VPN is now unmetered and not suspended.
mMockVpn.setUnderlyingNetworks(new Network[] { mWiFiAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
assertDefaultNetworkCapabilities(userId, mWiFiAgent);
// Use both again.
mMockVpn.setUnderlyingNetworks(
new Network[] { mCellAgent.getNetwork(), mWiFiAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
assertDefaultNetworkCapabilities(userId, mCellAgent, mWiFiAgent);
// Cell is suspended again. As WiFi is not, this should not cause a callback.
@@ -8739,11 +8765,11 @@
// Stop using WiFi. The VPN is suspended again.
mMockVpn.setUnderlyingNetworks(new Network[] { mCellAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && !caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && !c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
vpnNetworkCallback.expect(SUSPENDED, mMockVpn);
assertDefaultNetworkCapabilities(userId, mCellAgent, mWiFiAgent);
@@ -8751,29 +8777,32 @@
mMockVpn.setUnderlyingNetworks(
new Network[] { mCellAgent.getNetwork(), mWiFiAgent.getNetwork() });
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED)
- && caps.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED)
+ && c.hasCapability(NET_CAPABILITY_NOT_SUSPENDED));
vpnNetworkCallback.expect(RESUMED, mMockVpn);
assertDefaultNetworkCapabilities(userId, mCellAgent, mWiFiAgent);
// Disconnect cell. Receive update without even removing the dead network from the
// underlying networks – it's dead anyway. Not metered any more.
mCellAgent.disconnect();
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && c.hasCapability(NET_CAPABILITY_NOT_METERED));
assertDefaultNetworkCapabilities(userId, mWiFiAgent);
// Disconnect wifi too. No underlying networks means this is now metered.
mWiFiAgent.disconnect();
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED));
// When a network disconnects, the callbacks are fired before all state is updated, so for a
// short time, synchronous calls will behave as if the network is still connected. Wait for
// things to settle.
@@ -8814,20 +8843,22 @@
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
mCellAgent.connect(true);
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED));
// Connect to WiFi; WiFi is the new default.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.addCapability(NET_CAPABILITY_NOT_METERED);
mWiFiAgent.connect(true);
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_CELLULAR) && caps.hasTransport(TRANSPORT_WIFI)
- && caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_CELLULAR)
+ && c.hasTransport(TRANSPORT_WIFI)
+ && c.hasCapability(NET_CAPABILITY_NOT_METERED));
// Disconnect Cell. The default network did not change, so there shouldn't be any changes in
// the capabilities.
@@ -8836,10 +8867,11 @@
// Disconnect wifi too. Now we have no default network.
mWiFiAgent.disconnect();
- vpnNetworkCallback.expectCapabilitiesThat(mMockVpn,
- (caps) -> caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_CELLULAR) && !caps.hasTransport(TRANSPORT_WIFI)
- && !caps.hasCapability(NET_CAPABILITY_NOT_METERED));
+ vpnNetworkCallback.expectCaps(mMockVpn,
+ c -> c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_CELLULAR)
+ && !c.hasTransport(TRANSPORT_WIFI)
+ && !c.hasCapability(NET_CAPABILITY_NOT_METERED));
mMockVpn.disconnect();
}
@@ -8871,11 +8903,9 @@
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
mWiFiAgent.connect(true);
callback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
- callback.expectCapabilitiesThat(mMockVpn, (caps)
- -> caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_WIFI));
- callback.expectCapabilitiesThat(mWiFiAgent, (caps)
- -> caps.hasCapability(NET_CAPABILITY_VALIDATED));
+ callback.expectCaps(mMockVpn, c -> c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_WIFI));
+ callback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
doReturn(UserHandle.getUid(RESTRICTED_USER, VPN_UID)).when(mPackageManager)
.getPackageUidAsUser(ALWAYS_ON_PACKAGE, RESTRICTED_USER);
@@ -8886,35 +8916,35 @@
// Expect that the VPN UID ranges contain both |uid| and the UID range for the newly-added
// restricted user.
final UidRange rRange = UidRange.createForUser(UserHandle.of(RESTRICTED_USER));
- final Range<Integer> restrictUidRange = new Range<Integer>(rRange.start, rRange.stop);
- final Range<Integer> singleUidRange = new Range<Integer>(uid, uid);
- callback.expectCapabilitiesThat(mMockVpn, (caps)
- -> caps.getUids().size() == 2
- && caps.getUids().contains(singleUidRange)
- && caps.getUids().contains(restrictUidRange)
- && caps.hasTransport(TRANSPORT_VPN)
- && caps.hasTransport(TRANSPORT_WIFI));
+ final Range<Integer> restrictUidRange = new Range<>(rRange.start, rRange.stop);
+ final Range<Integer> singleUidRange = new Range<>(uid, uid);
+ callback.expectCaps(mMockVpn, c ->
+ c.getUids().size() == 2
+ && c.getUids().contains(singleUidRange)
+ && c.getUids().contains(restrictUidRange)
+ && c.hasTransport(TRANSPORT_VPN)
+ && c.hasTransport(TRANSPORT_WIFI));
// Change the VPN's capabilities somehow (specifically, disconnect wifi).
mWiFiAgent.disconnect();
callback.expect(LOST, mWiFiAgent);
- callback.expectCapabilitiesThat(mMockVpn, (caps)
- -> caps.getUids().size() == 2
- && caps.getUids().contains(singleUidRange)
- && caps.getUids().contains(restrictUidRange)
- && caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_WIFI));
+ callback.expectCaps(mMockVpn, c ->
+ c.getUids().size() == 2
+ && c.getUids().contains(singleUidRange)
+ && c.getUids().contains(restrictUidRange)
+ && c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_WIFI));
// User removed and expect to lose the UID range for the restricted user.
mMockVpn.onUserRemoved(RESTRICTED_USER);
// Expect that the VPN gains the UID range for the restricted user, and that the capability
// change made just before that (i.e., loss of TRANSPORT_WIFI) is preserved.
- callback.expectCapabilitiesThat(mMockVpn, (caps)
- -> caps.getUids().size() == 1
- && caps.getUids().contains(singleUidRange)
- && caps.hasTransport(TRANSPORT_VPN)
- && !caps.hasTransport(TRANSPORT_WIFI));
+ callback.expectCaps(mMockVpn, c ->
+ c.getUids().size() == 1
+ && c.getUids().contains(singleUidRange)
+ && c.hasTransport(TRANSPORT_VPN)
+ && !c.hasTransport(TRANSPORT_WIFI));
}
@Test
@@ -9162,11 +9192,6 @@
public void expectAvailableThenValidatedCallbacks(HasNetwork n, int blockedStatus) {
super.expectAvailableThenValidatedCallbacks(n.getNetwork(), blockedStatus, TIMEOUT_MS);
}
- public void expectBlockedStatusCallback(HasNetwork n, int blockedStatus) {
- // This doesn't work:
- // super.expectBlockedStatusCallback(blockedStatus, n.getNetwork());
- super.expectBlockedStatusCallback(blockedStatus, n.getNetwork(), TIMEOUT_MS);
- }
public void onBlockedStatusChanged(Network network, int blockedReasons) {
getHistory().add(new CallbackEntry.BlockedStatusInt(network, blockedReasons));
}
@@ -9194,8 +9219,9 @@
assertExtraInfoFromCmPresent(mCellAgent);
setBlockedReasonChanged(BLOCKED_REASON_BATTERY_SAVER);
- cellNetworkCallback.expectBlockedStatusCallback(true, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_REASON_BATTERY_SAVER);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_REASON_BATTERY_SAVER);
assertNull(mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
@@ -9204,21 +9230,23 @@
// If blocked state does not change but blocked reason does, the boolean callback is called.
// TODO: investigate de-duplicating.
setBlockedReasonChanged(BLOCKED_METERED_REASON_USER_RESTRICTED);
- cellNetworkCallback.expectBlockedStatusCallback(true, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent,
- BLOCKED_METERED_REASON_USER_RESTRICTED);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_METERED_REASON_USER_RESTRICTED);
setBlockedReasonChanged(BLOCKED_REASON_NONE);
- cellNetworkCallback.expectBlockedStatusCallback(false, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_REASON_NONE);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> !cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_REASON_NONE);
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertExtraInfoFromCmPresent(mCellAgent);
setBlockedReasonChanged(BLOCKED_METERED_REASON_DATA_SAVER);
- cellNetworkCallback.expectBlockedStatusCallback(true, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_METERED_REASON_DATA_SAVER);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_METERED_REASON_DATA_SAVER);
assertNull(mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
@@ -9226,28 +9254,34 @@
// Restrict the network based on UID rule and NOT_METERED capability change.
mCellAgent.addCapability(NET_CAPABILITY_NOT_METERED);
- cellNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_NOT_METERED, mCellAgent);
- cellNetworkCallback.expectBlockedStatusCallback(false, mCellAgent);
- detailedCallback.expectCapabilitiesWith(NET_CAPABILITY_NOT_METERED, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_REASON_NONE);
+ cellNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_NOT_METERED));
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> !cb.getBlocked());
+ detailedCallback.expectCaps(mCellAgent, c -> c.hasCapability(NET_CAPABILITY_NOT_METERED));
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_REASON_NONE);
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertExtraInfoFromCmPresent(mCellAgent);
mCellAgent.removeCapability(NET_CAPABILITY_NOT_METERED);
- cellNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_NOT_METERED, mCellAgent);
- cellNetworkCallback.expectBlockedStatusCallback(true, mCellAgent);
- detailedCallback.expectCapabilitiesWithout(NET_CAPABILITY_NOT_METERED, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_METERED_REASON_DATA_SAVER);
+ cellNetworkCallback.expectCaps(mCellAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_NOT_METERED));
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> cb.getBlocked());
+ detailedCallback.expectCaps(mCellAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_NOT_METERED));
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_METERED_REASON_DATA_SAVER);
assertNull(mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
assertExtraInfoFromCmBlocked(mCellAgent);
setBlockedReasonChanged(BLOCKED_REASON_NONE);
- cellNetworkCallback.expectBlockedStatusCallback(false, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_REASON_NONE);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> !cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_REASON_NONE);
assertEquals(mCellAgent.getNetwork(), mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
@@ -9259,8 +9293,9 @@
// Restrict background data. Networking is not blocked because the network is unmetered.
setBlockedReasonChanged(BLOCKED_METERED_REASON_DATA_SAVER);
- cellNetworkCallback.expectBlockedStatusCallback(true, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_METERED_REASON_DATA_SAVER);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_METERED_REASON_DATA_SAVER);
assertNull(mCm.getActiveNetwork());
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.BLOCKED);
@@ -9269,8 +9304,9 @@
cellNetworkCallback.assertNoCallback();
setBlockedReasonChanged(BLOCKED_REASON_NONE);
- cellNetworkCallback.expectBlockedStatusCallback(false, mCellAgent);
- detailedCallback.expectBlockedStatusCallback(mCellAgent, BLOCKED_REASON_NONE);
+ cellNetworkCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> !cb.getBlocked());
+ detailedCallback.expect(BLOCKED_STATUS_INT, mCellAgent,
+ cb -> cb.getReason() == BLOCKED_REASON_NONE);
assertActiveNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertNetworkInfo(TYPE_MOBILE, DetailedState.CONNECTED);
assertExtraInfoFromCmPresent(mCellAgent);
@@ -9301,7 +9337,7 @@
mCellAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR);
mCellAgent.connect(true);
defaultCallback.expectAvailableCallbacksUnvalidatedAndBlocked(mCellAgent);
- defaultCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mCellAgent);
+ defaultCallback.expectCaps(mCellAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
// Allow to use the network after switching to NOT_METERED network.
mWiFiAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
@@ -9316,8 +9352,8 @@
// Network becomes NOT_METERED.
mCellAgent.addCapability(NET_CAPABILITY_NOT_METERED);
- defaultCallback.expectCapabilitiesWith(NET_CAPABILITY_NOT_METERED, mCellAgent);
- defaultCallback.expectBlockedStatusCallback(false, mCellAgent);
+ defaultCallback.expectCaps(mCellAgent, c -> c.hasCapability(NET_CAPABILITY_NOT_METERED));
+ defaultCallback.expect(BLOCKED_STATUS, mCellAgent, cb -> !cb.getBlocked());
// Verify there's no Networkcallbacks invoked after data saver on/off.
setBlockedReasonChanged(BLOCKED_METERED_REASON_DATA_SAVER);
@@ -9458,8 +9494,8 @@
// Disable lockdown, expect to see the network unblocked.
mMockVpn.setAlwaysOnPackage(null, false /* lockdown */, allowList);
- callback.expectBlockedStatusCallback(false, mWiFiAgent);
- defaultCallback.expectBlockedStatusCallback(false, mWiFiAgent);
+ callback.expect(BLOCKED_STATUS, mWiFiAgent, cb -> !cb.getBlocked());
+ defaultCallback.expect(BLOCKED_STATUS, mWiFiAgent, cb -> !cb.getBlocked());
vpnUidCallback.assertNoCallback();
vpnUidDefaultCallback.assertNoCallback();
vpnDefaultCallbackAsUid.assertNoCallback();
@@ -9517,7 +9553,7 @@
mMockVpn.setAlwaysOnPackage(ALWAYS_ON_PACKAGE, true /* lockdown */, allowList);
waitForIdle();
expectNetworkRejectNonSecureVpn(inOrder, true, uidRangeParcels);
- defaultCallback.expectBlockedStatusCallback(true, mWiFiAgent);
+ defaultCallback.expect(BLOCKED_STATUS, mWiFiAgent, cb -> cb.getBlocked());
assertBlockedCallbackInAnyOrder(callback, true, mWiFiAgent, mCellAgent);
vpnUidCallback.assertNoCallback();
vpnUidDefaultCallback.assertNoCallback();
@@ -9530,7 +9566,7 @@
// Disable lockdown. Everything is unblocked.
mMockVpn.setAlwaysOnPackage(null, false /* lockdown */, allowList);
- defaultCallback.expectBlockedStatusCallback(false, mWiFiAgent);
+ defaultCallback.expect(BLOCKED_STATUS, mWiFiAgent, cb -> !cb.getBlocked());
assertBlockedCallbackInAnyOrder(callback, false, mWiFiAgent, mCellAgent);
vpnUidCallback.assertNoCallback();
vpnUidDefaultCallback.assertNoCallback();
@@ -9571,7 +9607,7 @@
// Enable lockdown and connect a VPN. The VPN is not blocked.
mMockVpn.setAlwaysOnPackage(ALWAYS_ON_PACKAGE, true /* lockdown */, allowList);
- defaultCallback.expectBlockedStatusCallback(true, mWiFiAgent);
+ defaultCallback.expect(BLOCKED_STATUS, mWiFiAgent, cb -> cb.getBlocked());
assertBlockedCallbackInAnyOrder(callback, true, mWiFiAgent, mCellAgent);
vpnUidCallback.assertNoCallback();
vpnUidDefaultCallback.assertNoCallback();
@@ -9886,7 +9922,7 @@
callback.expect(LOST, mWiFiAgent);
systemDefaultCallback.expect(LOST, mWiFiAgent);
b1.expectBroadcast();
- callback.expectCapabilitiesThat(mMockVpn, nc -> !nc.hasTransport(TRANSPORT_WIFI));
+ callback.expectCaps(mMockVpn, c -> !c.hasTransport(TRANSPORT_WIFI));
mMockVpn.expectStopVpnRunnerPrivileged();
callback.expect(LOST, mMockVpn);
b2.expectBroadcast();
@@ -10055,7 +10091,7 @@
// changes back to cellular.
mWiFiAgent.removeCapability(testCap);
callbackWithCap.expectAvailableCallbacksValidated(mCellAgent);
- callbackWithoutCap.expectCapabilitiesWithout(testCap, mWiFiAgent);
+ callbackWithoutCap.expectCaps(mWiFiAgent, c -> !c.hasCapability(testCap));
verify(mMockNetd).networkSetDefault(eq(mCellAgent.getNetwork().netId));
reset(mMockNetd);
@@ -10325,19 +10361,19 @@
// Expect clatd to be stopped and started with the new prefix.
mService.mResolverUnsolEventCallback.onNat64PrefixEvent(makeNat64PrefixEvent(
cellNetId, PREFIX_OPERATION_ADDED, kOtherNat64PrefixString, 96));
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- (lp) -> lp.getStackedLinks().size() == 0);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 0);
verifyClatdStop(null /* inOrder */, MOBILE_IFNAME);
assertRoutesRemoved(cellNetId, stackedDefault);
verify(mMockNetd, times(1)).networkRemoveInterface(cellNetId, CLAT_MOBILE_IFNAME);
verifyClatdStart(null /* inOrder */, MOBILE_IFNAME, cellNetId,
kOtherNat64Prefix.toString());
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- (lp) -> lp.getNat64Prefix().equals(kOtherNat64Prefix));
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getNat64Prefix().equals(kOtherNat64Prefix));
clat.interfaceLinkStateChanged(CLAT_MOBILE_IFNAME, true);
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- (lp) -> lp.getStackedLinks().size() == 1);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 1);
assertRoutesAdded(cellNetId, stackedDefault);
verify(mMockNetd, times(1)).networkAddInterface(cellNetId, CLAT_MOBILE_IFNAME);
reset(mMockNetd);
@@ -10378,7 +10414,8 @@
// Stopping prefix discovery causes netd to tell us that the NAT64 prefix is gone.
mService.mResolverUnsolEventCallback.onNat64PrefixEvent(makeNat64PrefixEvent(
cellNetId, PREFIX_OPERATION_REMOVED, kOtherNat64PrefixString, 96));
- networkCallback.expectLinkPropertiesThat(mCellAgent, lp -> lp.getNat64Prefix() == null);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getNat64Prefix() == null);
// Remove IPv4 address and expect prefix discovery and clatd to be started again.
cellLp.removeLinkAddress(myIpv4);
@@ -10395,22 +10432,24 @@
// Clat iface comes up. Expect stacked link to be added.
clat.interfaceLinkStateChanged(CLAT_MOBILE_IFNAME, true);
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- lp -> lp.getStackedLinks().size() == 1 && lp.getNat64Prefix() != null);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 1
+ && cb.getLp().getNat64Prefix() != null);
assertRoutesAdded(cellNetId, stackedDefault);
verify(mMockNetd, times(1)).networkAddInterface(cellNetId, CLAT_MOBILE_IFNAME);
// NAT64 prefix is removed. Expect that clat is stopped.
mService.mResolverUnsolEventCallback.onNat64PrefixEvent(makeNat64PrefixEvent(
cellNetId, PREFIX_OPERATION_REMOVED, kNat64PrefixString, 96));
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- lp -> lp.getStackedLinks().size() == 0 && lp.getNat64Prefix() == null);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 0
+ && cb.getLp().getNat64Prefix() == null);
assertRoutesRemoved(cellNetId, ipv4Subnet, stackedDefault);
// Stop has no effect because clat is already stopped.
verifyClatdStop(null /* inOrder */, MOBILE_IFNAME);
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- lp -> lp.getStackedLinks().size() == 0);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 0);
verify(mMockNetd, times(1)).networkRemoveInterface(cellNetId, CLAT_MOBILE_IFNAME);
verify(mMockNetd, times(1)).interfaceGetCfg(CLAT_MOBILE_IFNAME);
// Clean up.
@@ -10444,9 +10483,9 @@
verifyClatdStart(null /* inOrder */, MOBILE_IFNAME, cellNetId, kNat64Prefix.toString());
clat = getNat464Xlat(mCellAgent);
clat.interfaceLinkStateChanged(CLAT_MOBILE_IFNAME, true /* up */);
- networkCallback.expectLinkPropertiesThat(mCellAgent,
- lp -> lp.getStackedLinks().size() == 1
- && lp.getNat64Prefix().equals(kNat64Prefix));
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ cb -> cb.getLp().getStackedLinks().size() == 1
+ && cb.getLp().getNat64Prefix().equals(kNat64Prefix));
verify(mMockNetd).networkAddInterface(cellNetId, CLAT_MOBILE_IFNAME);
// assertRoutesAdded sees all calls since last mMockNetd reset, so expect IPv6 routes again.
assertRoutesAdded(cellNetId, ipv6Subnet, ipv6Default, stackedDefault);
@@ -10470,7 +10509,8 @@
private void expectNat64PrefixChange(TestNetworkCallback callback,
TestNetworkAgentWrapper agent, IpPrefix prefix) {
- callback.expectLinkPropertiesThat(agent, x -> Objects.equals(x.getNat64Prefix(), prefix));
+ callback.expect(LINK_PROPERTIES_CHANGED, agent,
+ x -> Objects.equals(x.getLp().getNat64Prefix(), prefix));
}
@Test
@@ -10705,7 +10745,7 @@
mWiFiAgent.connect(true);
networkCallback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
networkCallback.expectLosing(mCellAgent);
- networkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ networkCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
verify(mMockNetd, times(1)).idletimerAddInterface(eq(WIFI_IFNAME), anyInt(),
eq(Integer.toString(TRANSPORT_WIFI)));
verify(mMockNetd, times(1)).idletimerRemoveInterface(eq(MOBILE_IFNAME), anyInt(),
@@ -10729,7 +10769,7 @@
mWiFiAgent.connect(true);
networkCallback.expectAvailableCallbacksUnvalidated(mWiFiAgent);
networkCallback.expectLosing(mCellAgent);
- networkCallback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ networkCallback.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
verify(mMockNetd, times(1)).idletimerAddInterface(eq(WIFI_IFNAME), anyInt(),
eq(Integer.toString(TRANSPORT_WIFI)));
verify(mMockNetd, times(1)).idletimerRemoveInterface(eq(MOBILE_IFNAME), anyInt(),
@@ -11445,9 +11485,9 @@
// callback.
mWiFiAgent.setNetworkCapabilities(ncTemplate.setTransportInfo(actualTransportInfo), true);
- wifiNetworkCallback.expectCapabilitiesThat(mWiFiAgent,
- nc -> Objects.equals(expectedOwnerUid, nc.getOwnerUid())
- && Objects.equals(expectedTransportInfo, nc.getTransportInfo()));
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> Objects.equals(expectedOwnerUid, c.getOwnerUid())
+ && Objects.equals(expectedTransportInfo, c.getTransportInfo()));
}
@Test
@@ -12109,7 +12149,8 @@
lp.addRoute(rio1);
lp.addRoute(defaultRoute);
mCellAgent.sendLinkProperties(lp);
- networkCallback.expectLinkPropertiesThat(mCellAgent, x -> x.getRoutes().size() == 3);
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ x -> x.getLp().getRoutes().size() == 3);
assertRoutesAdded(netId, direct, rio1, defaultRoute);
reset(mMockNetd);
@@ -12124,7 +12165,8 @@
assertTrue(lp.getRoutes().contains(defaultWithMtu));
mCellAgent.sendLinkProperties(lp);
- networkCallback.expectLinkPropertiesThat(mCellAgent, x -> x.getRoutes().contains(rio2));
+ networkCallback.expect(LINK_PROPERTIES_CHANGED, mCellAgent,
+ x -> x.getLp().getRoutes().contains(rio2));
assertRoutesRemoved(netId, rio1);
assertRoutesAdded(netId, rio2);
@@ -12241,7 +12283,7 @@
assertNull(mService.getProxyForNetwork(null));
assertNull(mCm.getDefaultProxy());
- final ExpectedBroadcast b1 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b1 = expectProxyChangeAction();
final LinkProperties lp = new LinkProperties();
lp.setInterfaceName("tun0");
lp.addRoute(new RouteInfo(new IpPrefix(Inet4Address.ANY, 0), null));
@@ -12254,7 +12296,7 @@
b1.expectNoBroadcast(500);
// Update to new range which is old range minus APP1, i.e. only APP2
- final ExpectedBroadcast b2 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b2 = expectProxyChangeAction();
final Set<UidRange> newRanges = new HashSet<>(asList(
new UidRange(vpnRange.start, APP1_UID - 1),
new UidRange(APP1_UID + 1, vpnRange.stop)));
@@ -12268,20 +12310,20 @@
b2.expectNoBroadcast(500);
final ProxyInfo testProxyInfo = ProxyInfo.buildDirectProxy("test", 8888);
- final ExpectedBroadcast b3 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b3 = expectProxyChangeAction();
lp.setHttpProxy(testProxyInfo);
mMockVpn.sendLinkProperties(lp);
waitForIdle();
// Proxy is set, so send a proxy broadcast.
b3.expectBroadcast();
- final ExpectedBroadcast b4 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b4 = expectProxyChangeAction();
mMockVpn.setUids(vpnRanges);
waitForIdle();
// Uid has changed and proxy is already set, so send a proxy broadcast.
b4.expectBroadcast();
- final ExpectedBroadcast b5 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b5 = expectProxyChangeAction();
// Proxy is removed, send a proxy broadcast.
lp.setHttpProxy(null);
mMockVpn.sendLinkProperties(lp);
@@ -12314,7 +12356,7 @@
lp.setHttpProxy(testProxyInfo);
final UidRange vpnRange = PRIMARY_UIDRANGE;
final Set<UidRange> vpnRanges = Collections.singleton(vpnRange);
- final ExpectedBroadcast b1 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b1 = expectProxyChangeAction();
mMockVpn.setOwnerAndAdminUid(VPN_UID);
mMockVpn.registerAgent(false, vpnRanges, lp);
// In any case, the proxy broadcast won't be sent before VPN goes into CONNECTED state.
@@ -12322,7 +12364,7 @@
// proxy broadcast will get null.
b1.expectNoBroadcast(500);
- final ExpectedBroadcast b2 = registerPacProxyBroadcast();
+ final ExpectedBroadcast b2 = expectProxyChangeAction();
mMockVpn.connect(true /* validated */, true /* hasInternet */,
false /* privateDnsProbeSent */);
waitForIdle();
@@ -12358,7 +12400,7 @@
final LinkProperties cellularLp = new LinkProperties();
cellularLp.setInterfaceName(MOBILE_IFNAME);
final ProxyInfo testProxyInfo = ProxyInfo.buildDirectProxy("test", 8888);
- final ExpectedBroadcast b = registerPacProxyBroadcast();
+ final ExpectedBroadcast b = expectProxyChangeAction();
cellularLp.setHttpProxy(testProxyInfo);
mCellAgent.sendLinkProperties(cellularLp);
b.expectBroadcast();
@@ -12403,7 +12445,7 @@
// sees the network come up and validate later
allNetworksCb.expectAvailableCallbacksUnvalidated(mWiFiAgent);
allNetworksCb.expectLosing(mCellAgent);
- allNetworksCb.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mWiFiAgent);
+ allNetworksCb.expectCaps(mWiFiAgent, c -> c.hasCapability(NET_CAPABILITY_VALIDATED));
allNetworksCb.expect(LOST, mCellAgent, TEST_LINGER_DELAY_MS * 2);
// The cell network has disconnected (see LOST above) because it was outscored and
@@ -14428,10 +14470,10 @@
mDefaultNetworkCallback.expectAvailableThenValidatedCallbacks(mCellAgent);
mCellAgent.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED);
- mSystemDefaultNetworkCallback.expectCapabilitiesThat(mCellAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
- mDefaultNetworkCallback.expectCapabilitiesThat(mCellAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ mSystemDefaultNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ mDefaultNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
// default callbacks will be unregistered in tearDown
}
@@ -14818,20 +14860,19 @@
// not to the other apps.
workAgent.setNetworkValid(true /* privateDnsProbeSent */);
workAgent.mNetworkMonitor.forceReevaluation(Process.myUid());
- profileDefaultNetworkCallback.expectCapabilitiesThat(workAgent,
- nc -> nc.hasCapability(NET_CAPABILITY_VALIDATED)
- && nc.hasCapability(NET_CAPABILITY_ENTERPRISE)
- && nc.hasEnterpriseId(
- profileNetworkPreference.getPreferenceEnterpriseId())
- && nc.getEnterpriseIds().length == 1);
+ profileDefaultNetworkCallback.expectCaps(workAgent,
+ c -> c.hasCapability(NET_CAPABILITY_VALIDATED)
+ && c.hasCapability(NET_CAPABILITY_ENTERPRISE)
+ && c.hasEnterpriseId(profileNetworkPreference.getPreferenceEnterpriseId())
+ && c.getEnterpriseIds().length == 1);
if (disAllowProfileDefaultNetworkCallback != null) {
assertNoCallbacks(disAllowProfileDefaultNetworkCallback);
}
assertNoCallbacks(mSystemDefaultNetworkCallback, mDefaultNetworkCallback);
workAgent.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED);
- profileDefaultNetworkCallback.expectCapabilitiesThat(workAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ profileDefaultNetworkCallback.expectCaps(workAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
if (disAllowProfileDefaultNetworkCallback != null) {
assertNoCallbacks(disAllowProfileDefaultNetworkCallback);
}
@@ -14840,13 +14881,13 @@
// Conversely, change a capability on the system-wide default network and make sure
// that only the apps outside of the work profile receive the callbacks.
mCellAgent.addCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED);
- mSystemDefaultNetworkCallback.expectCapabilitiesThat(mCellAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
- mDefaultNetworkCallback.expectCapabilitiesThat(mCellAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ mSystemDefaultNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ mDefaultNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
if (disAllowProfileDefaultNetworkCallback != null) {
- disAllowProfileDefaultNetworkCallback.expectCapabilitiesThat(mCellAgent, nc ->
- nc.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
+ disAllowProfileDefaultNetworkCallback.expectCaps(mCellAgent,
+ c -> c.hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
}
profileDefaultNetworkCallback.assertNoCallback();
@@ -14928,12 +14969,11 @@
workAgent2.setNetworkValid(true /* privateDnsProbeSent */);
workAgent2.mNetworkMonitor.forceReevaluation(Process.myUid());
- profileDefaultNetworkCallback.expectCapabilitiesThat(workAgent2,
- nc -> nc.hasCapability(NET_CAPABILITY_ENTERPRISE)
- && !nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)
- && nc.hasEnterpriseId(
- profileNetworkPreference.getPreferenceEnterpriseId())
- && nc.getEnterpriseIds().length == 1);
+ profileDefaultNetworkCallback.expectCaps(workAgent2,
+ c -> c.hasCapability(NET_CAPABILITY_ENTERPRISE)
+ && !c.hasCapability(NET_CAPABILITY_NOT_RESTRICTED)
+ && c.hasEnterpriseId(profileNetworkPreference.getPreferenceEnterpriseId())
+ && c.getEnterpriseIds().length == 1);
if (disAllowProfileDefaultNetworkCallback != null) {
assertNoCallbacks(disAllowProfileDefaultNetworkCallback);
}
@@ -16119,7 +16159,7 @@
nc.setAllowedUids(uids);
agent.setNetworkCapabilities(nc, true /* sendToConnectivityService */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(agent, caps -> caps.getAllowedUids().equals(uids));
+ cb.expectCaps(agent, c -> c.getAllowedUids().equals(uids));
} else {
cb.assertNoCallback();
}
@@ -16136,7 +16176,7 @@
nc.setAllowedUids(uids);
agent.setNetworkCapabilities(nc, true /* sendToConnectivityService */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(agent, caps -> caps.getAllowedUids().equals(uids));
+ cb.expectCaps(agent, c -> c.getAllowedUids().equals(uids));
inOrder.verify(mMockNetd, times(1)).networkRemoveUidRangesParcel(uids200Parcel);
} else {
cb.assertNoCallback();
@@ -16147,7 +16187,7 @@
nc.setAllowedUids(uids);
agent.setNetworkCapabilities(nc, true /* sendToConnectivityService */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(agent, caps -> caps.getAllowedUids().equals(uids));
+ cb.expectCaps(agent, c -> c.getAllowedUids().equals(uids));
} else {
cb.assertNoCallback();
}
@@ -16164,7 +16204,7 @@
nc.setAllowedUids(uids);
agent.setNetworkCapabilities(nc, true /* sendToConnectivityService */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(agent, caps -> caps.getAllowedUids().isEmpty());
+ cb.expectCaps(agent, c -> c.getAllowedUids().isEmpty());
inOrder.verify(mMockNetd, times(1)).networkRemoveUidRangesParcel(uids600Parcel);
} else {
cb.assertNoCallback();
@@ -16217,8 +16257,7 @@
ncb.setAllowedUids(serviceUidSet);
mEthernetAgent.setNetworkCapabilities(ncb.build(), true /* sendToCS */);
if (SdkLevel.isAtLeastT() && hasAutomotiveFeature) {
- cb.expectCapabilitiesThat(mEthernetAgent,
- caps -> caps.getAllowedUids().equals(serviceUidSet));
+ cb.expectCaps(mEthernetAgent, c -> c.getAllowedUids().equals(serviceUidSet));
} else {
// S and no automotive feature must ignore access UIDs.
cb.assertNoCallback(TEST_CALLBACK_TIMEOUT_MS);
@@ -16271,7 +16310,7 @@
ncb.setAllowedUids(serviceUidSet);
mCellAgent.setNetworkCapabilities(ncb.build(), true /* sendToCS */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(mCellAgent, cp -> cp.getAllowedUids().equals(serviceUidSet));
+ cb.expectCaps(mCellAgent, c -> c.getAllowedUids().equals(serviceUidSet));
} else {
// S must ignore access UIDs.
cb.assertNoCallback(TEST_CALLBACK_TIMEOUT_MS);
@@ -16281,7 +16320,7 @@
ncb.setAllowedUids(nonServiceUidSet);
mCellAgent.setNetworkCapabilities(ncb.build(), true /* sendToCS */);
if (SdkLevel.isAtLeastT()) {
- cb.expectCapabilitiesThat(mCellAgent, cp -> cp.getAllowedUids().isEmpty());
+ cb.expectCaps(mCellAgent, c -> c.getAllowedUids().isEmpty());
} else {
// S must ignore access UIDs.
cb.assertNoCallback(TEST_CALLBACK_TIMEOUT_MS);
@@ -17117,40 +17156,42 @@
mWiFiAgent.setNetworkCapabilities(wifiNc2, true /* sendToConnectivityService */);
// The only thing changed in this CAPS is the BSSID, which can't be tested for in this
// test because it's redacted.
- wifiNetworkCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
- mDefaultNetworkCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent);
+ mDefaultNetworkCallback.expectCaps(mWiFiAgent);
mWiFiAgent.setNetworkPortal(TEST_REDIRECT_URL, false /* privateDnsProbeSent */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), false);
// Wi-Fi is now detected to have a portal : cell should become the default network.
mDefaultNetworkCallback.expectAvailableCallbacksValidated(mCellAgent);
- wifiNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_VALIDATED, mWiFiAgent);
- wifiNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_CAPTIVE_PORTAL, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_VALIDATED));
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
// Wi-Fi becomes valid again. The default network goes back to Wi-Fi.
mWiFiAgent.setNetworkValid(false /* privateDnsProbeSent */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
mDefaultNetworkCallback.expectAvailableCallbacksValidated(mWiFiAgent);
- wifiNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_CAPTIVE_PORTAL,
- mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL));
// Wi-Fi roaming from wifiNc2 to wifiNc1, and the network now has partial connectivity.
mWiFiAgent.setNetworkCapabilities(wifiNc1, true);
- wifiNetworkCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
- mDefaultNetworkCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent);
+ mDefaultNetworkCallback.expectCaps(mWiFiAgent);
mWiFiAgent.setNetworkPartial();
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), false);
// Wi-Fi now only offers partial connectivity, so in the absence of accepting partial
// connectivity explicitly for this network, it loses default status to cell.
mDefaultNetworkCallback.expectAvailableCallbacksValidated(mCellAgent);
- wifiNetworkCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY,
- mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
// Wi-Fi becomes valid again. The default network goes back to Wi-Fi.
mWiFiAgent.setNetworkValid(false /* privateDnsProbeSent */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), true);
mDefaultNetworkCallback.expectAvailableCallbacksValidated(mWiFiAgent);
- wifiNetworkCallback.expectCapabilitiesWithout(NET_CAPABILITY_PARTIAL_CONNECTIVITY,
- mWiFiAgent);
+ wifiNetworkCallback.expectCaps(mWiFiAgent,
+ c -> !c.hasCapability(NET_CAPABILITY_PARTIAL_CONNECTIVITY));
}
mCm.unregisterNetworkCallback(wifiNetworkCallback);
@@ -17158,7 +17199,7 @@
// failures after roam are not ignored, this will cause cell to become the default network.
// If they are ignored, this will not cause a switch until later.
mWiFiAgent.setNetworkCapabilities(wifiNc2, true);
- mDefaultNetworkCallback.expect(NETWORK_CAPS_UPDATED, mWiFiAgent);
+ mDefaultNetworkCallback.expectCaps(mWiFiAgent);
mWiFiAgent.setNetworkInvalid(false /* invalidBecauseOfPrivateDns */);
mCm.reportNetworkConnectivity(mWiFiAgent.getNetwork(), false);
diff --git a/tests/unit/java/com/android/server/IpSecServiceTest.java b/tests/unit/java/com/android/server/IpSecServiceTest.java
index 6955620..4b6857c 100644
--- a/tests/unit/java/com/android/server/IpSecServiceTest.java
+++ b/tests/unit/java/com/android/server/IpSecServiceTest.java
@@ -82,7 +82,7 @@
private static final int MAX_NUM_ENCAP_SOCKETS = 100;
private static final int MAX_NUM_SPIS = 100;
private static final int TEST_UDP_ENCAP_INVALID_PORT = 100;
- private static final int TEST_UDP_ENCAP_PORT_OUT_RANGE = 100000;
+ private static final int TEST_UDP_ENCAP_PORT_OUT_RANGE = 200000;
private static final InetAddress INADDR_ANY;
diff --git a/tests/unit/java/com/android/server/NsdServiceTest.java b/tests/unit/java/com/android/server/NsdServiceTest.java
index 98a8ed2..0680772 100644
--- a/tests/unit/java/com/android/server/NsdServiceTest.java
+++ b/tests/unit/java/com/android/server/NsdServiceTest.java
@@ -45,6 +45,7 @@
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import android.compat.testing.PlatformCompatChangeRule;
@@ -52,6 +53,7 @@
import android.content.Context;
import android.net.INetd;
import android.net.Network;
+import android.net.connectivity.ConnectivityCompatChanges;
import android.net.mdns.aidl.DiscoveryInfo;
import android.net.mdns.aidl.GetAddressInfo;
import android.net.mdns.aidl.IMDnsEventListener;
@@ -170,6 +172,9 @@
doReturn(true).when(mMockMDnsM).resolve(
anyInt(), anyString(), anyString(), anyString(), anyInt());
doReturn(false).when(mDeps).isMdnsDiscoveryManagerEnabled(any(Context.class));
+ doReturn(mDiscoveryManager).when(mDeps).makeMdnsDiscoveryManager(any(), any());
+ doReturn(mSocketProvider).when(mDeps).makeMdnsSocketProvider(any(), any());
+ doReturn(mAdvertiser).when(mDeps).makeMdnsAdvertiser(any(), any(), any());
mService = makeService();
}
@@ -183,7 +188,7 @@
}
@Test
- @DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testPreSClients() throws Exception {
// Pre S client connected, the daemon should be started.
connectClient(mService);
@@ -210,7 +215,7 @@
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testNoDaemonStartedWhenClientsConnect() throws Exception {
// Creating an NsdManager will not cause daemon startup.
connectClient(mService);
@@ -244,7 +249,7 @@
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testClientRequestsAreGCedAtDisconnection() throws Exception {
final NsdManager client = connectClient(mService);
final INsdManagerCallback cb1 = getCallback();
@@ -287,7 +292,7 @@
}
@Test
- @EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
+ @EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
public void testCleanupDelayNoRequestActive() throws Exception {
final NsdManager client = connectClient(mService);
@@ -625,7 +630,7 @@
waitForIdle();
verify(mMockMDnsM).stopOperation(resolveId);
- verify(resolveListener, timeout(TIMEOUT_MS)).onResolveStopped(argThat(ns ->
+ verify(resolveListener, timeout(TIMEOUT_MS)).onResolutionStopped(argThat(ns ->
request.getServiceName().equals(ns.getServiceName())
&& request.getServiceType().equals(ns.getServiceType())));
}
@@ -692,7 +697,7 @@
waitForIdle();
verify(mMockMDnsM).stopOperation(getAddrId);
- verify(resolveListener, timeout(TIMEOUT_MS)).onResolveStopped(argThat(ns ->
+ verify(resolveListener, timeout(TIMEOUT_MS)).onResolutionStopped(argThat(ns ->
request.getServiceName().equals(ns.getServiceName())
&& request.getServiceType().equals(ns.getServiceType())));
}
@@ -824,40 +829,50 @@
client.unregisterServiceInfoCallback(serviceInfoCallback));
}
- private void makeServiceWithMdnsDiscoveryManagerEnabled() {
+ private void setMdnsDiscoveryManagerEnabled() {
doReturn(true).when(mDeps).isMdnsDiscoveryManagerEnabled(any(Context.class));
- doReturn(mDiscoveryManager).when(mDeps).makeMdnsDiscoveryManager(any(), any());
- doReturn(mSocketProvider).when(mDeps).makeMdnsSocketProvider(any(), any());
-
- mService = makeService();
- verify(mDeps).makeMdnsDiscoveryManager(any(), any());
- verify(mDeps).makeMdnsSocketProvider(any(), any());
}
- private void makeServiceWithMdnsAdvertiserEnabled() {
+ private void setMdnsAdvertiserEnabled() {
doReturn(true).when(mDeps).isMdnsAdvertiserEnabled(any(Context.class));
- doReturn(mAdvertiser).when(mDeps).makeMdnsAdvertiser(any(), any(), any());
- doReturn(mSocketProvider).when(mDeps).makeMdnsSocketProvider(any(), any());
-
- mService = makeService();
- verify(mDeps).makeMdnsAdvertiser(any(), any(), any());
- verify(mDeps).makeMdnsSocketProvider(any(), any());
}
@Test
public void testMdnsDiscoveryManagerFeature() {
// Create NsdService w/o feature enabled.
- connectClient(mService);
- verify(mDeps, never()).makeMdnsDiscoveryManager(any(), any());
- verify(mDeps, never()).makeMdnsSocketProvider(any(), any());
+ final NsdManager client = connectClient(mService);
+ final DiscoveryListener discListenerWithoutFeature = mock(DiscoveryListener.class);
+ client.discoverServices(SERVICE_TYPE, PROTOCOL, discListenerWithoutFeature);
+ waitForIdle();
- // Create NsdService again w/ feature enabled.
- makeServiceWithMdnsDiscoveryManagerEnabled();
+ final ArgumentCaptor<Integer> legacyIdCaptor = ArgumentCaptor.forClass(Integer.class);
+ verify(mMockMDnsM).discover(legacyIdCaptor.capture(), any(), anyInt());
+ verifyNoMoreInteractions(mDiscoveryManager);
+
+ setMdnsDiscoveryManagerEnabled();
+ final DiscoveryListener discListenerWithFeature = mock(DiscoveryListener.class);
+ client.discoverServices(SERVICE_TYPE, PROTOCOL, discListenerWithFeature);
+ waitForIdle();
+
+ final String serviceTypeWithLocalDomain = SERVICE_TYPE + ".local";
+ final ArgumentCaptor<MdnsServiceBrowserListener> listenerCaptor =
+ ArgumentCaptor.forClass(MdnsServiceBrowserListener.class);
+ verify(mDiscoveryManager).registerListener(eq(serviceTypeWithLocalDomain),
+ listenerCaptor.capture(), any());
+
+ client.stopServiceDiscovery(discListenerWithoutFeature);
+ waitForIdle();
+ verify(mMockMDnsM).stopOperation(legacyIdCaptor.getValue());
+
+ client.stopServiceDiscovery(discListenerWithFeature);
+ waitForIdle();
+ verify(mDiscoveryManager).unregisterListener(serviceTypeWithLocalDomain,
+ listenerCaptor.getValue());
}
@Test
public void testDiscoveryWithMdnsDiscoveryManager() {
- makeServiceWithMdnsDiscoveryManagerEnabled();
+ setMdnsDiscoveryManagerEnabled();
final NsdManager client = connectClient(mService);
final DiscoveryListener discListener = mock(DiscoveryListener.class);
@@ -922,7 +937,7 @@
@Test
public void testDiscoveryWithMdnsDiscoveryManager_FailedWithInvalidServiceType() {
- makeServiceWithMdnsDiscoveryManagerEnabled();
+ setMdnsDiscoveryManagerEnabled();
final NsdManager client = connectClient(mService);
final DiscoveryListener discListener = mock(DiscoveryListener.class);
@@ -951,7 +966,7 @@
@Test
public void testResolutionWithMdnsDiscoveryManager() throws UnknownHostException {
- makeServiceWithMdnsDiscoveryManagerEnabled();
+ setMdnsDiscoveryManagerEnabled();
final NsdManager client = connectClient(mService);
final ResolveListener resolveListener = mock(ResolveListener.class);
@@ -1005,8 +1020,43 @@
}
@Test
+ public void testMdnsAdvertiserFeatureFlagging() {
+ // Create NsdService w/o feature enabled.
+ final NsdManager client = connectClient(mService);
+ final NsdServiceInfo regInfo = new NsdServiceInfo(SERVICE_NAME, SERVICE_TYPE);
+ regInfo.setHost(parseNumericAddress("192.0.2.123"));
+ regInfo.setPort(12345);
+ final RegistrationListener regListenerWithoutFeature = mock(RegistrationListener.class);
+ client.registerService(regInfo, PROTOCOL, regListenerWithoutFeature);
+ waitForIdle();
+
+ final ArgumentCaptor<Integer> legacyIdCaptor = ArgumentCaptor.forClass(Integer.class);
+ verify(mMockMDnsM).registerService(legacyIdCaptor.capture(), any(), any(), anyInt(),
+ any(), anyInt());
+ verifyNoMoreInteractions(mAdvertiser);
+
+ setMdnsAdvertiserEnabled();
+ final RegistrationListener regListenerWithFeature = mock(RegistrationListener.class);
+ client.registerService(regInfo, PROTOCOL, regListenerWithFeature);
+ waitForIdle();
+
+ final ArgumentCaptor<Integer> serviceIdCaptor = ArgumentCaptor.forClass(Integer.class);
+ verify(mAdvertiser).addService(serviceIdCaptor.capture(),
+ argThat(info -> matches(info, regInfo)));
+
+ client.unregisterService(regListenerWithoutFeature);
+ waitForIdle();
+ verify(mMockMDnsM).stopOperation(legacyIdCaptor.getValue());
+ verify(mAdvertiser, never()).removeService(anyInt());
+
+ client.unregisterService(regListenerWithFeature);
+ waitForIdle();
+ verify(mAdvertiser).removeService(serviceIdCaptor.getValue());
+ }
+
+ @Test
public void testAdvertiseWithMdnsAdvertiser() {
- makeServiceWithMdnsAdvertiserEnabled();
+ setMdnsAdvertiserEnabled();
final NsdManager client = connectClient(mService);
final RegistrationListener regListener = mock(RegistrationListener.class);
@@ -1045,7 +1095,7 @@
@Test
public void testAdvertiseWithMdnsAdvertiser_FailedWithInvalidServiceType() {
- makeServiceWithMdnsAdvertiserEnabled();
+ setMdnsAdvertiserEnabled();
final NsdManager client = connectClient(mService);
final RegistrationListener regListener = mock(RegistrationListener.class);
@@ -1070,7 +1120,7 @@
@Test
public void testAdvertiseWithMdnsAdvertiser_LongServiceName() {
- makeServiceWithMdnsAdvertiserEnabled();
+ setMdnsAdvertiserEnabled();
final NsdManager client = connectClient(mService);
final RegistrationListener regListener = mock(RegistrationListener.class);
diff --git a/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java b/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
index 9a5298d..e038c44 100644
--- a/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
+++ b/tests/unit/java/com/android/server/connectivity/NetworkNotificationManagerTest.java
@@ -56,8 +56,10 @@
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
+import android.os.PowerManager;
import android.os.UserHandle;
import android.telephony.TelephonyManager;
+import android.testing.PollingCheck;
import android.util.DisplayMetrics;
import android.widget.TextView;
@@ -391,7 +393,15 @@
final Instrumentation instr = InstrumentationRegistry.getInstrumentation();
final UiDevice uiDevice = UiDevice.getInstance(instr);
- UiDevice.getInstance(instr).pressHome();
+ final Context ctx = instr.getContext();
+ final PowerManager pm = ctx.getSystemService(PowerManager.class);
+
+ // Wake up the device (it has no effect if the device is already awake).
+ uiDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP");
+ uiDevice.executeShellCommand("wm dismiss-keyguard");
+ PollingCheck.check("Wait for the screen to be turned on failed, timeout=" + TEST_TIMEOUT_MS,
+ TEST_TIMEOUT_MS, () -> pm.isInteractive());
+ uiDevice.pressHome();
// UiDevice.getLauncherPackageName() requires the test manifest to have a <queries> tag for
// the launcher intent.
@@ -404,7 +414,6 @@
// Non-"no internet" notifications are not affected
verify(mNotificationManager).notify(eq(TEST_NOTIF_TAG), eq(NETWORK_SWITCH.eventId), any());
- final Context ctx = instr.getContext();
final String testAction = "com.android.connectivity.coverage.TEST_DIALOG";
final Intent intent = new Intent(testAction)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 9f34b06..93443f5 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -263,6 +263,7 @@
"-DHAVE_SYS_UIO_H",
"-DIS_PARTITION_ALLOC_IMPL",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-DPA_PCSCAN_STACK_SUPPORTED",
@@ -272,6 +273,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-O3",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -284,18 +293,29 @@
"libgtest_prod_headers",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
android_arm: {
srcs: [
"base/allocator/partition_allocator/starscan/stack/asm/arm/push_registers_asm.cc",
],
+ cflags: [
+ "-fstack-protector",
+ ],
},
android_arm64: {
srcs: [
"base/allocator/partition_allocator/starscan/stack/asm/arm64/push_registers_asm.cc",
],
cflags: [
+ "-fstack-protector",
"-march=armv8-a+memtag",
+ "-mno-outline",
+ "-mno-outline-atomics",
],
},
android_x86: {
@@ -311,6 +331,7 @@
"base/allocator/partition_allocator/starscan/stack/asm/x64/push_registers_asm.cc",
],
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -972,6 +993,7 @@
"-DHAVE_SYS_UIO_H",
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-DUSE_CHROMIUM_ICU=1",
@@ -986,6 +1008,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -1002,6 +1032,11 @@
"libgtest_prod_headers",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
android_arm: {
srcs: [
@@ -1011,11 +1046,19 @@
"base/profiler/chrome_unwinder_android_v2.cc",
"base/trace_event/cfi_backtrace_android.cc",
],
+ cflags: [
+ "-fstack-protector",
+ ],
},
android_arm64: {
srcs: [
"base/android/reached_code_profiler.cc",
],
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
},
android_x86: {
srcs: [
@@ -1030,6 +1073,7 @@
"base/android/reached_code_profiler_stub.cc",
],
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -1366,6 +1410,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -1374,6 +1419,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -1382,7 +1435,24 @@
"buildtools/third_party/libc++abi/trunk/include",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -1390,6 +1460,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -1400,7 +1471,7 @@
cc_genrule {
name: "cronet_aml_base_build_date",
cmd: "$(location build/write_build_date_header.py) $(out) " +
- "1674804594",
+ "1676008584",
out: [
"base/generated_build_date.h",
],
@@ -1463,7 +1534,7 @@
name: "cronet_aml_base_debugging_buildflags",
cmd: "if [[ ( $$CC_ARCH == 'x86_64' && $$CC_OS == 'android' ) ]]; " +
"then " +
- "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"false\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"false\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
+ "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"false\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"true\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
"$(location build/write_buildflag_header.py) --output " +
"$(out) " +
"--rulename " +
@@ -1475,7 +1546,7 @@
"fi; " +
"if [[ ( $$CC_ARCH == 'x86' && $$CC_OS == 'android' ) ]]; " +
"then " +
- "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"true\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"false\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
+ "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"false\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"true\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
"$(location build/write_buildflag_header.py) --output " +
"$(out) " +
"--rulename " +
@@ -1487,7 +1558,7 @@
"fi; " +
"if [[ ( $$CC_ARCH == 'arm' && $$CC_OS == 'android' ) ]]; " +
"then " +
- "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"false\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"true\" EXCLUDE_UNWIND_TABLES=\"false\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
+ "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"false\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"true\" EXCLUDE_UNWIND_TABLES=\"true\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
"$(location build/write_buildflag_header.py) --output " +
"$(out) " +
"--rulename " +
@@ -1499,7 +1570,7 @@
"fi; " +
"if [[ ( $$CC_ARCH == 'arm64' && $$CC_OS == 'android' ) ]]; " +
"then " +
- "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"true\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"false\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
+ "echo '--flags DCHECK_IS_CONFIGURABLE=\"false\" ENABLE_LOCATION_SOURCE=\"true\" FROM_HERE_USES_LOCATION_BUILTINS=\"true\" ENABLE_PROFILING=\"false\" CAN_UNWIND_WITH_FRAME_POINTERS=\"true\" UNSAFE_DEVELOPER_BUILD=\"false\" CAN_UNWIND_WITH_CFI_TABLE=\"false\" EXCLUDE_UNWIND_TABLES=\"true\" ENABLE_GDBINIT_WARNING=\"false\" ENABLE_LLDBINIT_WARNING=\"false\" EXPENSIVE_DCHECKS_ARE_ON=\"false\" ENABLE_STACK_TRACE_LINE_NUMBERS=\"false\"' | " +
"$(location build/write_buildflag_header.py) --output " +
"$(out) " +
"--rulename " +
@@ -1685,6 +1756,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -1693,6 +1765,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -1702,6 +1782,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -1709,6 +1801,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -1916,6 +2009,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -1924,6 +2018,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -1932,7 +2034,24 @@
"buildtools/third_party/libc++abi/trunk/include",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -1940,6 +2059,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -1963,11 +2083,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -1976,7 +2105,24 @@
"buildtools/third_party/libc++abi/trunk/include",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -1984,6 +2130,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -2222,6 +2369,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DLIBCXX_BUILDING_LIBCXXABI",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
@@ -2230,6 +2378,13 @@
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -2249,6 +2404,8 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
],
},
android_arm64: {
@@ -2256,6 +2413,10 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
],
},
android_x86: {
@@ -2263,6 +2424,7 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
"-msse3",
],
},
@@ -2271,19 +2433,22 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
"-msse3",
],
},
host: {
cflags: [
"-DCR_SYSROOT_KEY=20220331T153654Z-0",
- "-DNO_UNWIND_TABLES",
"-DUSE_AURA=1",
"-DUSE_OZONE=1",
"-DUSE_UDEV",
"-D_FILE_OFFSET_BITS=64",
"-D_LARGEFILE64_SOURCE",
"-D_LARGEFILE_SOURCE",
+ "-O2",
+ "-fstack-protector",
"-msse3",
],
},
@@ -2321,6 +2486,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DLIBCXXABI_SILENT_TERMINATE",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
@@ -2328,6 +2494,13 @@
"-D_LIBCPP_CONSTINIT=constinit",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -2350,6 +2523,8 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
],
},
android_arm64: {
@@ -2360,6 +2535,10 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
],
},
android_x86: {
@@ -2370,6 +2549,7 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
"-msse3",
],
},
@@ -2381,6 +2561,8 @@
"-DANDROID",
"-DANDROID_NDK_VERSION_ROLL=r23_1",
"-DHAVE_SYS_UIO_H",
+ "-Oz",
+ "-fstack-protector",
"-msse3",
],
},
@@ -2390,13 +2572,14 @@
],
cflags: [
"-DCR_SYSROOT_KEY=20220331T153654Z-0",
- "-DNO_UNWIND_TABLES",
"-DUSE_AURA=1",
"-DUSE_OZONE=1",
"-DUSE_UDEV",
"-D_FILE_OFFSET_BITS=64",
"-D_LARGEFILE64_SOURCE",
"-D_LARGEFILE_SOURCE",
+ "-O2",
+ "-fstack-protector",
"-msse3",
],
},
@@ -2504,6 +2687,7 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -2512,6 +2696,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -2527,10 +2719,25 @@
],
cpp_std: "c++17",
ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
"-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
],
stem: "libcronet.108.0.5359.128",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -2538,6 +2745,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3170,6 +3378,7 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3178,6 +3387,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3193,6 +3410,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3200,6 +3429,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3536,6 +3766,7 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3544,6 +3775,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3559,6 +3798,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3566,6 +3817,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3631,6 +3883,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3639,6 +3892,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3650,6 +3911,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3657,6 +3930,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3707,6 +3981,7 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3715,6 +3990,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3727,6 +4010,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3734,6 +4029,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3840,6 +4136,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3848,6 +4145,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3858,7 +4163,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3866,6 +4188,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3953,6 +4276,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -3961,6 +4285,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -3971,7 +4303,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -3979,6 +4328,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -3990,7 +4340,6 @@
name: "cronet_aml_defaults",
cflags: [
"-DGOOGLE_PROTOBUF_NO_RTTI",
- "-O2",
"-Wno-ambiguous-reversed-operator",
"-Wno-error=return-type",
"-Wno-macro-redefined",
@@ -4002,7 +4351,6 @@
"-Wno-unreachable-code-loop-increment",
"-Wno-unused-parameter",
"-fPIC",
- "-fvisibility=hidden",
],
stl: "none",
apex_available: [
@@ -4604,6 +4952,7 @@
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
"-DNET_IMPLEMENTATION",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -4612,6 +4961,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -4628,6 +4985,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -4635,6 +5004,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -4708,6 +5078,7 @@
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
"-DNET_IMPLEMENTATION",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -4716,6 +5087,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -4732,6 +5111,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -4739,6 +5130,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -4825,6 +5217,7 @@
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
"-DNET_IMPLEMENTATION",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -4833,6 +5226,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -4849,6 +5250,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -4856,6 +5269,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -5493,6 +5907,7 @@
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
"-DNET_IMPLEMENTATION",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -5501,6 +5916,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -5516,16 +5939,29 @@
"third_party/protobuf/src/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
android_arm: {
srcs: [
"net/disk_cache/blockfile/mapped_file_bypass_mmap_posix.cc",
],
+ cflags: [
+ "-fstack-protector",
+ ],
},
android_arm64: {
srcs: [
"net/disk_cache/blockfile/mapped_file_bypass_mmap_posix.cc",
],
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
},
android_x86: {
srcs: [
@@ -5540,6 +5976,7 @@
"net/disk_cache/blockfile/mapped_file_bypass_mmap_posix.cc",
],
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -5600,6 +6037,7 @@
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
"-DNET_IMPLEMENTATION",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -5608,6 +6046,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -5621,6 +6067,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -5628,6 +6086,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -5832,6 +6291,7 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -5840,6 +6300,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -5855,6 +6323,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -5862,6 +6342,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -5901,6 +6382,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -5909,6 +6391,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -5919,7 +6409,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -5927,6 +6434,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6401,6 +6909,7 @@
"-DHAVE_SYS_UIO_H",
"-DIS_QUICHE_IMPL",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -6409,6 +6918,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6423,7 +6940,24 @@
"third_party/protobuf/src/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6431,6 +6965,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6473,6 +7008,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -6481,6 +7017,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6492,6 +7036,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6499,6 +7055,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6539,6 +7096,7 @@
"-DHAVE_SYS_UIO_H",
"-DIS_URI_TEMPLATE_IMPL",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -6547,6 +7105,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6557,7 +7123,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6565,6 +7148,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6593,11 +7177,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6608,6 +7201,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6615,6 +7220,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6639,11 +7245,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6654,6 +7269,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6661,6 +7288,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6685,11 +7313,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6700,6 +7337,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6707,6 +7356,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6731,11 +7381,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6746,6 +7405,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6753,6 +7424,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6777,11 +7449,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6792,6 +7473,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6799,6 +7492,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6823,11 +7517,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6838,6 +7541,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6845,6 +7560,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6869,11 +7585,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6884,6 +7609,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6891,6 +7628,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6916,11 +7654,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6931,6 +7678,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6938,6 +7697,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -6962,11 +7722,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -6977,6 +7746,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -6984,6 +7765,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7010,11 +7792,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7025,6 +7816,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7032,6 +7835,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7056,11 +7860,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7071,6 +7884,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7078,6 +7903,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7102,11 +7928,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7117,6 +7952,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7124,6 +7971,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7148,11 +7996,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7163,6 +8020,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7170,6 +8039,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7194,11 +8064,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7209,6 +8088,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7216,6 +8107,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7240,11 +8132,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7255,6 +8156,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7262,6 +8175,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7286,11 +8200,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7301,6 +8224,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7308,6 +8243,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7332,11 +8268,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7347,6 +8292,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7354,6 +8311,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7378,11 +8336,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7393,6 +8360,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7400,6 +8379,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7424,11 +8404,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7439,6 +8428,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7446,6 +8447,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7470,11 +8472,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7485,6 +8496,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7492,6 +8515,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7517,11 +8541,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7532,6 +8565,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7539,6 +8584,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7566,11 +8612,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7581,6 +8636,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7588,6 +8655,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7615,11 +8683,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7630,6 +8707,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7637,6 +8726,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7664,11 +8754,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7679,6 +8778,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7686,6 +8797,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7713,11 +8825,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7728,6 +8849,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7735,6 +8868,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7762,11 +8896,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7777,6 +8920,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7784,6 +8939,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7811,11 +8967,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7826,6 +8991,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7833,6 +9010,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7857,11 +9035,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7872,6 +9059,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7879,6 +9078,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7903,11 +9103,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7918,6 +9127,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7925,6 +9146,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7952,11 +9174,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -7967,6 +9198,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -7974,6 +9217,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -7999,11 +9243,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8014,6 +9267,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8021,6 +9286,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8045,11 +9311,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8060,6 +9335,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8067,6 +9354,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8093,11 +9381,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8108,6 +9405,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8115,6 +9424,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8145,11 +9455,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8160,6 +9479,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8167,6 +9498,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8191,11 +9523,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8206,6 +9547,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8213,6 +9566,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8237,11 +9591,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8252,6 +9615,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8259,6 +9634,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8283,11 +9659,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8298,6 +9683,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8305,6 +9702,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8331,11 +9729,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8346,6 +9753,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8353,6 +9772,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8382,11 +9802,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8397,6 +9826,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8404,6 +9845,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8440,11 +9882,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8455,6 +9906,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8462,6 +9925,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8486,11 +9950,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8501,6 +9974,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8508,6 +9993,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8538,11 +10024,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8553,6 +10048,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8560,6 +10067,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8584,11 +10092,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8599,6 +10116,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8606,6 +10135,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8638,11 +10168,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8653,6 +10192,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8660,6 +10211,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8688,11 +10240,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8703,6 +10264,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8710,6 +10283,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8734,11 +10308,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8749,6 +10332,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8756,6 +10351,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8780,11 +10376,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8795,6 +10400,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8802,6 +10419,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8825,11 +10443,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8840,6 +10467,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8847,6 +10486,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -8870,6 +10510,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -8878,6 +10519,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -8887,6 +10536,18 @@
],
cpp_std: "c++17",
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -8894,6 +10555,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9186,12 +10848,21 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-DOPENSSL_SMALL",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9201,7 +10872,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -9209,6 +10897,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9229,6 +10918,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -9237,6 +10927,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9263,6 +10961,9 @@
"third_party/boringssl/src/crypto/curve25519/asm/x25519-asm-arm.S",
"third_party/boringssl/src/crypto/poly1305/poly1305_arm_asm.S",
],
+ cflags: [
+ "-fstack-protector",
+ ],
},
android_arm64: {
srcs: [
@@ -9280,6 +10981,11 @@
"third_party/boringssl/linux-aarch64/crypto/fipsmodule/vpaes-armv8.S",
"third_party/boringssl/linux-aarch64/crypto/test/trampoline-armv8.S",
],
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
},
android_x86: {
srcs: [
@@ -9325,6 +11031,7 @@
"third_party/boringssl/src/crypto/hrss/asm/poly_rq_mul.S",
],
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9353,6 +11060,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -9361,6 +11069,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9370,7 +11086,24 @@
"third_party/brotli/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -9378,6 +11111,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9407,11 +11141,20 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9421,7 +11164,24 @@
"third_party/brotli/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -9429,6 +11189,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9696,6 +11457,7 @@
"-DHAVE_SYS_UIO_H",
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-DUCONFIG_ONLY_HTML_CONVERSION=1",
@@ -9711,6 +11473,14 @@
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9721,8 +11491,25 @@
"third_party/icu/source/i18n/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
rtti: true,
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -9730,6 +11517,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -9953,6 +11741,7 @@
"-DHAVE_SYS_UIO_H",
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-DUCONFIG_ONLY_HTML_CONVERSION=1",
@@ -9969,6 +11758,14 @@
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -9979,8 +11776,25 @@
"third_party/icu/source/i18n/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
rtti: true,
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -9988,6 +11802,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -10025,11 +11840,20 @@
"-DHAVE_CONFIG_H",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -10039,7 +11863,24 @@
"third_party/libevent/android/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -10047,6 +11888,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -10215,6 +12057,7 @@
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -10223,6 +12066,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -10231,7 +12082,24 @@
"buildtools/third_party/libc++abi/trunk/include",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -10239,6 +12107,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -10365,6 +12234,15 @@
"-D_LARGEFILE_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fstack-protector",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
"-msse3",
],
local_include_dirs: [
@@ -10375,6 +12253,11 @@
"third_party/protobuf/src/",
],
cpp_std: "c++20",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
}
// GN: //third_party/protobuf:protobuf_lite
@@ -10432,11 +12315,20 @@
"-DHAVE_PTHREAD",
"-DHAVE_SYS_UIO_H",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_GNU_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -10446,7 +12338,24 @@
"third_party/protobuf/src/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -10454,6 +12363,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -10502,6 +12412,15 @@
"-D_LARGEFILE_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fstack-protector",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
"-msse3",
],
local_include_dirs: [
@@ -10512,6 +12431,11 @@
"third_party/protobuf/src/",
],
cpp_std: "c++20",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
}
// GN: //third_party/protobuf:protoc_lib
@@ -10637,6 +12561,15 @@
"-D_LARGEFILE_SOURCE",
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
+ "-O2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fstack-protector",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
"-msse3",
],
local_include_dirs: [
@@ -10647,6 +12580,11 @@
"third_party/protobuf/src/",
],
cpp_std: "c++20",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
}
// GN: //url:buildflags
@@ -10741,6 +12679,7 @@
"-DHAVE_SYS_UIO_H",
"-DIS_URL_IMPL",
"-DNDEBUG",
+ "-DNO_UNWIND_TABLES",
"-DNVALGRIND",
"-DOFFICIAL_BUILD",
"-D_FORTIFY_SOURCE=2",
@@ -10749,6 +12688,14 @@
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_FORMAT_MACROS",
+ "-Oz",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ "-g1",
],
local_include_dirs: [
"./",
@@ -10759,7 +12706,24 @@
"third_party/boringssl/src/include/",
],
cpp_std: "c++17",
+ ldflags: [
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
+ ],
target: {
+ android_arm: {
+ cflags: [
+ "-fstack-protector",
+ ],
+ },
+ android_arm64: {
+ cflags: [
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ ],
+ },
android_x86: {
cflags: [
"-msse3",
@@ -10767,6 +12731,7 @@
},
android_x86_64: {
cflags: [
+ "-fstack-protector",
"-msse3",
],
},
@@ -10821,15 +12786,11 @@
"SPDX-license-identifier-Apache-2.0",
"SPDX-license-identifier-BSD",
"SPDX-license-identifier-BSL-1.0",
- "SPDX-license-identifier-GPL",
- "SPDX-license-identifier-GPL-2.0",
- "SPDX-license-identifier-GPL-3.0",
"SPDX-license-identifier-ICU",
"SPDX-license-identifier-ISC",
- "SPDX-license-identifier-LGPL",
- "SPDX-license-identifier-LGPL-2.1",
"SPDX-license-identifier-MIT",
"SPDX-license-identifier-MPL",
+ "SPDX-license-identifier-MPL-1.1",
"SPDX-license-identifier-MPL-2.0",
"SPDX-license-identifier-NCSA",
"SPDX-license-identifier-OpenSSL",
diff --git a/tools/gn2bp/desc_arm.json b/tools/gn2bp/desc_arm.json
index ff1a7e2..6f72c94 100644
--- a/tools/gn2bp/desc_arm.json
+++ b/tools/gn2bp/desc_arm.json
Binary files differ
diff --git a/tools/gn2bp/desc_arm64.json b/tools/gn2bp/desc_arm64.json
index 20c942f..0732834 100644
--- a/tools/gn2bp/desc_arm64.json
+++ b/tools/gn2bp/desc_arm64.json
Binary files differ
diff --git a/tools/gn2bp/desc_x64.json b/tools/gn2bp/desc_x64.json
index b25932b..49e5cae 100644
--- a/tools/gn2bp/desc_x64.json
+++ b/tools/gn2bp/desc_x64.json
Binary files differ
diff --git a/tools/gn2bp/desc_x86.json b/tools/gn2bp/desc_x86.json
index b4bc6e9..51d4153 100644
--- a/tools/gn2bp/desc_x86.json
+++ b/tools/gn2bp/desc_x86.json
Binary files differ
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 9d2d858..592c070 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -126,6 +126,30 @@
"-msse3",
# needed for zlib:zlib
"-msse4.2",
+ # flags to reduce binary size
+ "-O1",
+ "-O2",
+ "-O3",
+ "-Oz",
+ "-g1",
+ "-g2",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-fvisibility=hidden",
+ "-fvisibility-inlines-hidden",
+ "-fstack-protector",
+ "-mno-outline",
+ "-mno-outline-atomics",
+ "-fno-asynchronous-unwind-tables",
+ "-fno-unwind-tables",
+]
+
+# Linker flags which are passed through to the blueprint.
+ldflag_allowlist = [
+ # flags to reduce binary size
+ "-Wl,--as-needed",
+ "-Wl,--gc-sections",
+ "-Wl,--icf=all",
]
def get_linker_script_ldflag(script_path):
@@ -296,6 +320,7 @@
self.export_system_include_dirs = set()
self.generated_headers = set()
self.export_generated_headers = set()
+ self.ldflags = set()
def to_string(self, output):
nested_out = []
@@ -313,6 +338,7 @@
self._output_field(nested_out, 'export_system_include_dirs')
self._output_field(nested_out, 'generated_headers')
self._output_field(nested_out, 'export_generated_headers')
+ self._output_field(nested_out, 'ldflags')
if nested_out:
output.append(' %s: {' % self.name)
@@ -1242,8 +1268,10 @@
cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in defines)
return cflags
-def set_module_flags(module, cflags, defines):
+def set_module_flags(module, module_type, cflags, defines, ldflags):
module.cflags.update(_get_cflags(cflags, defines))
+ if module_type != 'cc_object':
+ module.ldflags.update({flag for flag in ldflags if flag in ldflag_allowlist})
# TODO: implement proper cflag parsing.
for flag in cflags:
if '-std=' in flag:
@@ -1335,11 +1363,12 @@
module.rtti = target.rtti
if target.type in gn_utils.LINKER_UNIT_TYPES:
- set_module_flags(module, target.cflags, target.defines)
+ set_module_flags(module, module.type, target.cflags, target.defines, target.ldflags)
set_module_include_dirs(module, target.cflags, target.include_dirs)
# TODO: set_module_xxx is confusing, apply similar function to module and target in better way.
for arch_name, arch in target.arch.items():
- set_module_flags(module.target[arch_name], arch.cflags, arch.defines)
+ set_module_flags(module.target[arch_name], module.type,
+ arch.cflags, arch.defines, arch.ldflags)
# -Xclang -target-feature -Xclang +mte are used to enable MTE (Memory Tagging Extensions).
# Flags which does not start with '-' could not be in the cflags so enabling MTE by
# -march and -mcpu Feature Modifiers. MTE is only available on arm64. This is needed for
@@ -1607,10 +1636,8 @@
'-Wno-sign-promo',
'-Wno-unused-parameter',
'-Wno-null-pointer-subtraction', # Needed to libevent
- '-fvisibility=hidden',
'-Wno-ambiguous-reversed-operator', # needed for icui18n
'-Wno-unreachable-code-loop-increment', # needed for icui18n
- '-O2',
'-fPIC',
]
# Chromium builds do not add a dependency for headers found inside the
@@ -1667,24 +1694,20 @@
def create_license_module(blueprint):
module = Module("license", "external_cronet_license", "LICENSE")
module.license_kinds.update({
- 'SPDX-license-identifier-LGPL-2.1',
- 'SPDX-license-identifier-GPL-2.0',
'SPDX-license-identifier-MPL',
+ 'SPDX-license-identifier-MPL-1.1',
'SPDX-license-identifier-ISC',
- 'SPDX-license-identifier-GPL',
'SPDX-license-identifier-AFL-2.0',
'SPDX-license-identifier-MPL-2.0',
'SPDX-license-identifier-BSD',
'SPDX-license-identifier-Apache-2.0',
'SPDX-license-identifier-BSL-1.0',
- 'SPDX-license-identifier-LGPL',
- 'SPDX-license-identifier-GPL-3.0',
'SPDX-license-identifier-Unicode-DFS',
'SPDX-license-identifier-NCSA',
'SPDX-license-identifier-OpenSSL',
'SPDX-license-identifier-MIT',
"SPDX-license-identifier-ICU",
- 'legacy_unencumbered', # public domain
+ 'legacy_unencumbered',
})
module.license_text.update({
"LICENSE",
diff --git a/tools/gn2bp/gen_desc_json.sh b/tools/gn2bp/gen_desc_json.sh
index 1f60eb9..bf9b21d 100755
--- a/tools/gn2bp/gen_desc_json.sh
+++ b/tools/gn2bp/gen_desc_json.sh
@@ -41,27 +41,32 @@
"target_os = \"android\""
"enable_websockets = false"
"disable_file_support = true"
- "disable_brotli_filter = false"
"is_component_build = false"
"use_crash_key_stubs = true"
"use_partition_alloc = false"
"include_transport_security_state_preload_list = false"
"use_platform_icu_alternatives = true"
"default_min_sdk_version = 19"
- "use_errorprone_java_compiler = true"
"enable_reporting = true"
"use_hashed_jni_names = true"
- "treat_warnings_as_errors = false"
"enable_base_tracing = false"
"is_cronet_build = true"
"is_debug = false"
"is_official_build = true"
+ "use_nss_certs = false"
+ "clang_use_default_sample_profile = false"
+ "media_use_ffmpeg=false"
+ "use_thin_lto=false"
+ "enable_resource_allowlist_generation=false"
+ "enable_jdk_library_desugaring=false"
+ "exclude_unwind_tables=true"
+ "symbol_level=1"
)
gn_args+=("target_cpu = \"${1}\"")
# Only set arm_use_neon on arm architectures to prevent warning from being
# written to json output.
- if [[ "$1" =~ ^arm ]]; then
+ if [[ "$1" = "arm" ]]; then
gn_args+=("arm_use_neon = false")
fi
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 3d709e5..6095455 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -119,6 +119,7 @@
self.deps = set()
self.transitive_static_libs_deps = set()
self.source_set_deps = set()
+ self.ldflags = set()
# These are valid only for type == 'action'
self.inputs = set()
@@ -207,7 +208,7 @@
'libs', 'proto_paths'):
self.__dict__[key].update(other.__dict__.get(key, []))
- for key_in_arch in ('cflags', 'defines', 'include_dirs', 'source_set_deps'):
+ for key_in_arch in ('cflags', 'defines', 'include_dirs', 'source_set_deps', 'ldflags'):
self.arch[arch].__dict__[key_in_arch].update(
other.arch[arch].__dict__.get(key_in_arch, []))
@@ -250,7 +251,7 @@
return
for key in ('sources', 'cflags', 'defines', 'include_dirs', 'deps', 'source_set_deps',
- 'inputs', 'outputs', 'args', 'script', 'response_file_contents'):
+ 'inputs', 'outputs', 'args', 'script', 'response_file_contents', 'ldflags'):
self._finalize_attribute(key)
@@ -392,7 +393,7 @@
target.arch[arch].cflags.update(desc.get('cflags', []) + desc.get('cflags_cc', []))
target.libs.update(desc.get('libs', []))
- target.ldflags.update(desc.get('ldflags', []))
+ target.arch[arch].ldflags.update(desc.get('ldflags', []))
target.arch[arch].defines.update(desc.get('defines', []))
target.arch[arch].include_dirs.update(desc.get('include_dirs', []))
target.output_name = desc.get('output_name', None)