Merge "Import translations. DO NOT MERGE ANYWHERE" into stage-aosp-master
diff --git a/Cronet/tests/cts/src/org/chromium/net/test/CronetApiTest.java b/Cronet/tests/cts/src/org/chromium/net/test/CronetApiTest.java
deleted file mode 100644
index 6465006..0000000
--- a/Cronet/tests/cts/src/org/chromium/net/test/CronetApiTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2019 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 org.chromium.net.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.os.Handler;
-import android.os.Looper;
-
-import androidx.annotation.NonNull;
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.chromium.net.CronetEngine;
-import org.chromium.net.CronetException;
-import org.chromium.net.UrlRequest;
-import org.chromium.net.UrlResponseInfo;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.nio.ByteBuffer;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-
-@RunWith(AndroidJUnit4.class)
-public class CronetApiTest {
- private static final String TAG = CronetApiTest.class.getSimpleName();
- private static final String HTTPS_PREFIX = "https://";
- private static final int TIMEOUT_MS = 12_000;
-
- private final String[] mTestDomains = {"www.google.com", "www.android.com"};
- @NonNull private CronetEngine mCronetEngine;
- @NonNull private ConnectivityManager mCm;
- @NonNull private Executor mExecutor;
-
- @Before
- public void setUp() throws Exception {
- Context context = InstrumentationRegistry.getInstrumentation().getContext();
- mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- CronetEngine.Builder builder = new CronetEngine.Builder(context);
- builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
- .enableHttp2(true)
- // .enableBrotli(true)
- .enableQuic(true);
- mCronetEngine = builder.build();
- mExecutor = new Handler(Looper.getMainLooper())::post;
- }
-
- private static void assertGreaterThan(String msg, int first, int second) {
- assertTrue(msg + " Excepted " + first + " to be greater than " + second, first > second);
- }
-
- private void assertHasTestableNetworks() {
- assertNotNull("This test requires a working Internet connection", mCm.getActiveNetwork());
- }
-
- private String getRandomDomain() {
- int index = (new Random()).nextInt(mTestDomains.length);
- return mTestDomains[index];
- }
-
- private static class TestUrlRequestCallback extends UrlRequest.Callback {
- private final CountDownLatch mLatch = new CountDownLatch(1);
- private final String mUrl;
-
- TestUrlRequestCallback(@NonNull String url) {
- this.mUrl = url;
- }
-
- public boolean waitForAnswer() throws InterruptedException {
- return mLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void onRedirectReceived(
- UrlRequest request, UrlResponseInfo info, String newLocationUrl) {
- request.followRedirect();
- }
-
- @Override
- public void onResponseStarted(UrlRequest request, UrlResponseInfo info) {
- request.read(ByteBuffer.allocateDirect(32 * 1024));
- }
-
- @Override
- public void onReadCompleted(
- UrlRequest request, UrlResponseInfo info, ByteBuffer byteBuffer) {
- byteBuffer.clear();
- request.read(byteBuffer);
- }
-
- @Override
- public void onSucceeded(UrlRequest request, UrlResponseInfo info) {
- assertEquals(
- "Unexpected http status code from " + mUrl + ".",
- 200,
- info.getHttpStatusCode());
- assertGreaterThan(
- "Received byte from " + mUrl + " is 0.", (int) info.getReceivedByteCount(), 0);
- mLatch.countDown();
- }
-
- @Override
- public void onFailed(UrlRequest request, UrlResponseInfo info, CronetException error) {
- fail(mUrl + error.getMessage());
- }
- }
-
- @Test
- public void testUrlRequestGet_CompletesSuccessfully() throws Exception {
- assertHasTestableNetworks();
- String url = HTTPS_PREFIX + getRandomDomain();
- TestUrlRequestCallback callback = new TestUrlRequestCallback(url);
- UrlRequest.Builder builder = mCronetEngine.newUrlRequestBuilder(url, callback, mExecutor);
- builder.build().start();
- assertTrue(url + " but not complete after " + TIMEOUT_MS + "ms.", callback.waitForAnswer());
- }
-}
diff --git a/Cronet/tests/cts/src/org/chromium/net/test/CronetUrlRequestTest.java b/Cronet/tests/cts/src/org/chromium/net/test/CronetUrlRequestTest.java
new file mode 100644
index 0000000..7dd9a9a
--- /dev/null
+++ b/Cronet/tests/cts/src/org/chromium/net/test/CronetUrlRequestTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2019 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 org.chromium.net.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+
+import androidx.annotation.NonNull;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.chromium.net.CronetEngine;
+import org.chromium.net.UrlRequest;
+import org.chromium.net.UrlResponseInfo;
+import org.chromium.net.test.util.TestUrlRequestCallback;
+import org.chromium.net.test.util.TestUrlRequestCallback.ResponseStep;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Random;
+
+@RunWith(AndroidJUnit4.class)
+public class CronetUrlRequestTest {
+ private static final String TAG = CronetUrlRequestTest.class.getSimpleName();
+ private static final String HTTPS_PREFIX = "https://";
+
+ private final String[] mTestDomains = {"www.google.com", "www.android.com"};
+ @NonNull private CronetEngine mCronetEngine;
+ @NonNull private ConnectivityManager mCm;
+
+ @Before
+ public void setUp() throws Exception {
+ Context context = InstrumentationRegistry.getInstrumentation().getContext();
+ mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ CronetEngine.Builder builder = new CronetEngine.Builder(context);
+ builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
+ .enableHttp2(true)
+ // .enableBrotli(true)
+ .enableQuic(true);
+ mCronetEngine = builder.build();
+ }
+
+ private static void assertGreaterThan(String msg, int first, int second) {
+ assertTrue(msg + " Excepted " + first + " to be greater than " + second, first > second);
+ }
+
+ private void assertHasTestableNetworks() {
+ assertNotNull("This test requires a working Internet connection", mCm.getActiveNetwork());
+ }
+
+ private String getRandomDomain() {
+ int index = (new Random()).nextInt(mTestDomains.length);
+ return mTestDomains[index];
+ }
+
+ @Test
+ public void testUrlRequestGet_CompletesSuccessfully() throws Exception {
+ assertHasTestableNetworks();
+ String url = HTTPS_PREFIX + getRandomDomain();
+ TestUrlRequestCallback callback = new TestUrlRequestCallback();
+ UrlRequest.Builder builder = mCronetEngine.newUrlRequestBuilder(url, callback,
+ callback.getExecutor());
+ builder.build().start();
+
+ callback.expectCallback(ResponseStep.ON_SUCCEEDED);
+
+ UrlResponseInfo info = callback.mResponseInfo;
+ assertEquals("Unexpected http status code from " + url + ".", 200,
+ info.getHttpStatusCode());
+ assertGreaterThan(
+ "Received byte from " + url + " is 0.", (int) info.getReceivedByteCount(), 0);
+ }
+}
diff --git a/nearby/halfsheet/res/values-en-rCA/strings.xml b/nearby/halfsheet/res/values-en-rCA/strings.xml
index d4ed675..6094199 100644
--- a/nearby/halfsheet/res/values-en-rCA/strings.xml
+++ b/nearby/halfsheet/res/values-en-rCA/strings.xml
@@ -17,7 +17,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting setup…"</string>
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting Setup…"</string>
<string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
<string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
<string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
diff --git a/nearby/halfsheet/res/values-ro/strings.xml b/nearby/halfsheet/res/values-ro/strings.xml
index 5b50f15..189f698 100644
--- a/nearby/halfsheet/res/values-ro/strings.xml
+++ b/nearby/halfsheet/res/values-ro/strings.xml
@@ -18,12 +18,12 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Începe configurarea…"</string>
- <string name="fast_pair_title_setup" msgid="2894360355540593246">"Configurați dispozitivul"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Configurează dispozitivul"</string>
<string name="fast_pair_device_ready" msgid="2903490346082833101">"Dispozitivul s-a conectat"</string>
<string name="fast_pair_title_fail" msgid="5677174346601290232">"Nu s-a putut conecta"</string>
<string name="paring_action_done" msgid="6888875159174470731">"Gata"</string>
- <string name="paring_action_save" msgid="6259357442067880136">"Salvați"</string>
- <string name="paring_action_connect" msgid="4801102939608129181">"Conectați"</string>
- <string name="paring_action_launch" msgid="8940808384126591230">"Configurați"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Salvează"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Conectează"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Configurează"</string>
<string name="paring_action_settings" msgid="424875657242864302">"Setări"</string>
</resources>
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 316f9e5..4c9e3a3 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -250,6 +250,7 @@
import com.android.modules.utils.BasicShellCommandHandler;
import com.android.modules.utils.build.SdkLevel;
import com.android.net.module.util.BaseNetdUnsolicitedEventListener;
+import com.android.net.module.util.BinderUtils;
import com.android.net.module.util.BitUtils;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.DeviceConfigUtils;
@@ -5161,7 +5162,9 @@
description = settingValue + " (?)";
}
pw.println("Avoid bad wifi setting: " + description);
- final Boolean configValue = mMultinetworkPolicyTracker.deviceConfigActivelyPreferBadWifi();
+
+ final Boolean configValue = BinderUtils.withCleanCallingIdentity(
+ () -> mMultinetworkPolicyTracker.deviceConfigActivelyPreferBadWifi());
if (null == configValue) {
description = "unset";
} else if (configValue) {
diff --git a/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java b/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
index e2821cb..3c71c90 100644
--- a/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
@@ -155,6 +155,13 @@
// removing data activity tracking.
mCtsNetUtils.ensureWifiConnected();
+ // There's rate limit to update mobile battery so if ConnectivityService calls
+ // BatteryStatsManager.reportMobileRadioPowerState when default network changed,
+ // the mobile stats might not be updated. But if the mobile update due to other
+ // reasons (plug/unplug, battery level change, etc) will be unaffected. Thus here
+ // dumps the battery stats to trigger a full sync of data.
+ executeShellCommand("dumpsys batterystats");
+
// Check cellular battery stats are updated.
runAsShell(UPDATE_DEVICE_STATS,
() -> assertStatsEventually(mBsm::getCellularBatteryStats,
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index e6f3978..f8f2b6a 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -2356,31 +2356,10 @@
"base/metrics/histogram_base.h",
"base/task/task_traits.h",
"build/android/gyp/java_cpp_enum.py",
- ],
-}
-
-// GN: //base:base_java_aidl
-java_genrule {
- name: "cronet_aml_base_base_java_aidl",
- cmd: "$(location build/android/gyp/aidl.py) --aidl-path " +
- "../../third_party/android_sdk/public/build-tools/33.0.0/aidl " +
- "--imports " +
- "[\"../../third_party/android_sdk/public/platforms/android-33/framework.aidl\"] " +
- "--srcjar " +
- "gen/base/base_java_aidl.srcjar " +
- "--depfile " +
- "gen/base/base_java_aidl.d " +
- "--includes " +
- "[\"../../base/android/java/src\"] " +
- "../../base/android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl " +
- "../../base/android/java/src/org/chromium/base/process_launcher/IParentProcess.aidl",
- out: [
- "base/base_java_aidl.srcjar",
- ],
- tool_files: [
- "base/android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl",
- "base/android/java/src/org/chromium/base/process_launcher/IParentProcess.aidl",
- "build/android/gyp/aidl.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
],
}
@@ -4231,18 +4210,22 @@
"base/task/task_features.cc",
],
cmd: "$(location build/android/gyp/java_cpp_features.py) --srcjar " +
- "gen/base/java_features_srcjar.srcjar " +
+ "$(out) " +
"--template " +
- "../../base/android/java/src/org/chromium/base/BaseFeatures.java.tmpl " +
- "../../base/android/base_features.cc " +
- "../../base/features.cc " +
- "../../base/task/task_features.cc",
+ "$(location base/android/java/src/org/chromium/base/BaseFeatures.java.tmpl) " +
+ "$(location base/android/base_features.cc) " +
+ "$(location base/features.cc) " +
+ "$(location base/task/task_features.cc)",
out: [
"base/java_features_srcjar.srcjar",
],
tool_files: [
"base/android/java/src/org/chromium/base/BaseFeatures.java.tmpl",
"build/android/gyp/java_cpp_features.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
],
}
@@ -4253,16 +4236,20 @@
"base/base_switches.cc",
],
cmd: "$(location build/android/gyp/java_cpp_strings.py) --srcjar " +
- "gen/base/java_switches_srcjar.srcjar " +
+ "$(out) " +
"--template " +
- "../../base/android/java/src/org/chromium/base/BaseSwitches.java.tmpl " +
- "../../base/base_switches.cc",
+ "$(location base/android/java/src/org/chromium/base/BaseSwitches.java.tmpl) " +
+ "$(location base/base_switches.cc)",
out: [
"base/java_switches_srcjar.srcjar",
],
tool_files: [
"base/android/java/src/org/chromium/base/BaseSwitches.java.tmpl",
"build/android/gyp/java_cpp_strings.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
],
}
@@ -5698,7 +5685,10 @@
],
tool_files: [
"build/android/gyp/gcc_preprocess.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
"build/android/java/templates/BuildConfig.template",
+ "build/gn_helpers.py",
],
}
@@ -5706,7 +5696,7 @@
java_genrule {
name: "cronet_aml_build_android_native_libraries_gen",
cmd: "$(location build/android/gyp/write_native_libraries_java.py) --output " +
- "gen/build/android/native_libraries_gen.srcjar " +
+ "$(out) " +
"--cpu-family " +
"CPU_FAMILY_ARM",
out: [
@@ -7829,6 +7819,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"components/cronet/url_request_context_config.h",
],
}
@@ -7841,7 +7835,7 @@
"-f " +
"$(location build/util/LASTCHANGE) " +
"-e " +
- "API_LEVEL=20 " +
+ "'API_LEVEL=20' " +
"-o " +
"$(out) " +
"$(location components/cronet/android/java/src/org/chromium/net/impl/ImplVersion.template)",
@@ -7870,6 +7864,9 @@
],
tool_files: [
"build/android/gyp/gcc_preprocess.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/gn_helpers.py",
"components/cronet/android/java/src/org/chromium/net/impl/IntegratedModeState.template",
],
}
@@ -7882,7 +7879,7 @@
"-f " +
"$(location build/util/LASTCHANGE) " +
"-e " +
- "API_LEVEL=20 " +
+ "'API_LEVEL=20' " +
"-o " +
"$(out) " +
"$(location components/cronet/android/api/src/org/chromium/net/ApiVersion.template)",
@@ -7911,7 +7908,11 @@
],
tool_files: [
"build/android/gyp/gcc_preprocess.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/gn_helpers.py",
"components/cronet/android/java/src/org/chromium/net/impl/LoadState.template",
+ "net/base/load_states_list.h",
],
}
@@ -7926,6 +7927,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/base/idempotency.h",
],
}
@@ -7941,6 +7946,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/base/request_priority.h",
],
}
@@ -7956,6 +7965,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/nqe/network_quality_observation_source.h",
],
}
@@ -7971,6 +7984,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/nqe/network_quality.h",
],
}
@@ -7986,6 +8003,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"components/cronet/android/url_request_error.h",
],
}
@@ -8261,7 +8282,7 @@
cmd: "$(location build/util/version.py) -f " +
"$(location chrome/VERSION) " +
"-e " +
- "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " +
+ "'VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8286,7 +8307,7 @@
cmd: "$(location build/util/version.py) -f " +
"$(location chrome/VERSION) " +
"-e " +
- "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " +
+ "'VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8311,7 +8332,7 @@
cmd: "$(location build/util/version.py) -f " +
"$(location chrome/VERSION) " +
"-e " +
- "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " +
+ "'VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -8336,7 +8357,7 @@
cmd: "$(location build/util/version.py) -f " +
"$(location chrome/VERSION) " +
"-e " +
- "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH) " +
+ "'VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
"-o " +
"$(out) " +
"$(location components/cronet/version.h.in)",
@@ -9601,6 +9622,8 @@
"base/android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionFactory.java",
"base/android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionImpl.java",
"base/android/java/src/org/chromium/base/process_launcher/FileDescriptorInfo.java",
+ "base/android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl",
+ "base/android/java/src/org/chromium/base/process_launcher/IParentProcess.aidl",
"base/android/java/src/org/chromium/base/supplier/BooleanSupplier.java",
"base/android/java/src/org/chromium/base/supplier/DestroyableObservableSupplier.java",
"base/android/java/src/org/chromium/base/supplier/ObservableSupplier.java",
@@ -9765,6 +9788,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/android/cert_verify_result_android.h",
"net/android/keystore.h",
"net/base/network_change_notifier.h",
@@ -9784,7 +9811,11 @@
],
tool_files: [
"build/android/gyp/gcc_preprocess.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/gn_helpers.py",
"net/android/java/NetError.template",
+ "net/base/net_error_list.h",
],
}
@@ -11090,6 +11121,10 @@
],
tool_files: [
"build/android/gyp/java_cpp_enum.py",
+ "build/android/gyp/util/__init__.py",
+ "build/android/gyp/util/build_utils.py",
+ "build/android/gyp/util/java_cpp_utils.py",
+ "build/gn_helpers.py",
"net/nqe/effective_connection_type.h",
],
}
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index ef05126..233e6f8 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -746,6 +746,23 @@
def get_outputs(self):
return self.target.outputs
+ def get_srcs(self):
+ # gn treats inputs and sources for actions equally.
+ # soong only supports source files inside srcs, non-source files are added as
+ # tool_files dependency.
+ files = self.target.sources.union(self.target.inputs)
+ return {gn_utils.label_to_path(file) for file in files if is_supported_source_file(file)}
+
+ def get_tool_files(self):
+ # gn treats inputs and sources for actions equally.
+ # soong only supports source files inside srcs, non-source files are added as
+ # tool_files dependency.
+ files = self.target.sources.union(self.target.inputs)
+ tool_files = {gn_utils.label_to_path(file)
+ for file in files if not is_supported_source_file(file)}
+ tool_files.add(gn_utils.label_to_path(self.target.script))
+ return tool_files
+
def _sanitize_args(self):
# Handle passing parameters via response file by piping them into the script
# and reading them from /dev/stdin.
@@ -759,9 +776,13 @@
def _sanitize_outputs(self):
pass
+ def _sanitize_inputs(self):
+ pass
+
def sanitize(self):
self._sanitize_args()
self._sanitize_outputs()
+ self._sanitize_inputs()
# Whether this target generates header files
def is_header_generated(self):
@@ -803,7 +824,17 @@
self.target.outputs = {re.sub('^jni_headers/', '', out) for out in self.target.outputs}
super()._sanitize_outputs()
+ def get_tool_files(self):
+ tool_files = super().get_tool_files()
+ # android_jar.classes should be part of the tools as it list implicit classes
+ # for the script to generate JNI headers.
+ tool_files.add("base/android/jni_generator/android_jar.classes")
+ return tool_files
+
class JniRegistrationGeneratorSanitizer(BaseActionSanitizer):
+ def _sanitize_inputs(self):
+ self.target.inputs = [file for file in self.target.inputs if not file.startswith('//out/')]
+
def _sanitize_args(self):
self._update_value_arg('--depfile', self._sanitize_filepath)
self._update_value_arg('--srcjar-path', self._sanitize_filepath)
@@ -849,8 +880,15 @@
# args for the version.py contain file path without leading --arg key. So apply sanitize
# function for all the args.
self._update_all_args(self._sanitize_filepath_with_location_tag)
+ self._set_value_arg('-e', "'%s'" % self._get_value_arg('-e'))
super()._sanitize_args()
+ def get_tool_files(self):
+ tool_files = super().get_tool_files()
+ # android_chrome_version.py is not specified in anywhere but version.py imports this file
+ tool_files.add('build/util/android_chrome_version.py')
+ return tool_files
+
class JavaCppEnumSanitizer(BaseActionSanitizer):
def _sanitize_args(self):
self._update_all_args(self._sanitize_filepath_with_location_tag)
@@ -863,6 +901,23 @@
# (e.g. registry_controlled_domain.cc)
return True
+class JavaCppFeatureSanitizer(BaseActionSanitizer):
+ def _sanitize_args(self):
+ self._update_all_args(self._sanitize_filepath_with_location_tag)
+ self._set_value_arg('--srcjar', '$(out)')
+ super()._sanitize_args()
+
+class JavaCppStringSanitizer(BaseActionSanitizer):
+ def _sanitize_args(self):
+ self._update_all_args(self._sanitize_filepath_with_location_tag)
+ self._set_value_arg('--srcjar', '$(out)')
+ super()._sanitize_args()
+
+class WriteNativeLibrariesJavaSanitizer(BaseActionSanitizer):
+ def _sanitize_args(self):
+ self._set_value_arg('--output', '$(out)')
+ super()._sanitize_args()
+
def get_action_sanitizer(target, type):
if target.script == "//build/write_buildflag_header.py":
return WriteBuildFlagHeaderSanitizer(target)
@@ -881,6 +936,12 @@
return JavaCppEnumSanitizer(target)
elif target.script == "//net/tools/dafsa/make_dafsa.py":
return MakeDafsaSanitizer(target)
+ elif target.script == '//build/android/gyp/java_cpp_features.py':
+ return JavaCppFeatureSanitizer(target)
+ elif target.script == '//build/android/gyp/java_cpp_strings.py':
+ return JavaCppStringSanitizer(target)
+ elif target.script == '//build/android/gyp/write_native_libraries_java.py':
+ return WriteNativeLibrariesJavaSanitizer(target)
else:
# TODO: throw exception here once all script hacks have been converted.
return BaseActionSanitizer(target)
@@ -921,39 +982,14 @@
def create_action_module(blueprint, target, type):
sanitizer = get_action_sanitizer(target, type)
sanitizer.sanitize()
+
module = Module(type, sanitizer.get_name(), target.name)
module.cmd = sanitizer.get_cmd()
module.out = sanitizer.get_outputs()
if sanitizer.is_header_generated():
module.genrule_headers.add(module.name)
-
- if target.script == '//base/android/jni_generator/jni_generator.py':
- # android_jar.classes should be part of the tools as it list implicit classes
- # for the script to generate JNI headers.
- module.tool_files.add("base/android/jni_generator/android_jar.classes")
-
- elif target.script == '//base/android/jni_generator/jni_registration_generator.py':
- # jni_registration_generator.py pulls in some config dependencies that we
- # do not handle. Remove them.
- # TODO: find a better way to do this.
- target.deps.clear()
-
- target.inputs = [file for file in target.inputs if not file.startswith('//out/')]
- elif target.script == "//build/util/version.py":
- # android_chrome_version.py is not specified in anywhere but version.py imports this file
- module.tool_files.add('build/util/android_chrome_version.py')
-
- script = gn_utils.label_to_path(target.script)
- module.tool_files.add(script)
-
- # gn treats inputs and sources for actions equally.
- # soong only supports source files inside srcs, non-source files are added as
- # tool_files dependency.
- for it in target.sources or target.inputs:
- if is_supported_source_file(it):
- module.srcs.add(gn_utils.label_to_path(it))
- else:
- module.tool_files.add(gn_utils.label_to_path(it))
+ module.srcs = sanitizer.get_srcs()
+ module.tool_files = sanitizer.get_tool_files()
blueprint.add_module(module)
return module
@@ -1230,7 +1266,8 @@
# TODO: java_sources might not contain all the required java files
module.srcs.update([gn_utils.label_to_path(source)
- for source in gn.java_sources if source not in deny_list])
+ for source in gn.java_sources
+ if source.endswith('.java') and source not in deny_list])
def create_blueprint_for_targets(gn, targets):
"""Generate a blueprint for a list of GN targets."""
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 0511e8a..130f8ff 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -429,7 +429,13 @@
java_srcs = [src for src in dep.inputs if _is_java_source(src)]
self.java_sources.update(java_srcs)
if dep.type in ["action"] and target.type == "java_group":
- self.java_actions.add(dep.name)
+ # //base:base_java_aidl generates srcjar from .aidl files. But java_library in soong can
+ # directly have .aidl files in srcs. So adding .aidl files to the java_sources.
+ # TODO: Find a better way/place to do this.
+ if dep.name == '//base:base_java_aidl':
+ self.java_sources.update(dep.arch[arch].sources)
+ else:
+ self.java_actions.add(dep.name)
return target
def get_proto_exports(self, proto_desc):