From b86694adf49a9c86823fc4923040f7ba5d7883f8 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sun, 16 May 2021 10:10:09 +0800 Subject: [PATCH] android: net: Add Android stubs --- src/net/BUILD.gn | 20 +--- .../network_activation_request_stub.cc | 27 +++++ src/net/android/network_library_stub.cc | 98 +++++++++++++++++++ .../android/radio_activity_tracker_stub.cc | 19 ++++ 4 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 src/net/android/network_activation_request_stub.cc create mode 100644 src/net/android/network_library_stub.cc create mode 100644 src/net/android/radio_activity_tracker_stub.cc diff --git a/src/net/BUILD.gn b/src/net/BUILD.gn index b485ec5260..ee32d30136 100644 --- a/src/net/BUILD.gn +++ b/src/net/BUILD.gn @@ -1207,32 +1207,18 @@ component("net") { if (is_android) { sources += [ - "android/android_http_util.cc", - "android/cert_verify_result_android.cc", "android/cert_verify_result_android.h", - "android/gurl_utils.cc", - "android/http_auth_negotiate_android.cc", "android/http_auth_negotiate_android.h", - "android/keystore.cc", "android/keystore.h", - "android/network_change_notifier_android.cc", "android/network_change_notifier_android.h", - "android/network_change_notifier_delegate_android.cc", "android/network_change_notifier_delegate_android.h", - "android/network_change_notifier_factory_android.cc", "android/network_change_notifier_factory_android.h", - "android/network_library.cc", + "android/network_library_stub.cc", "android/network_library.h", - "android/traffic_stats.cc", "android/traffic_stats.h", - "cert/cert_verify_proc_android.cc", "cert/cert_verify_proc_android.h", "cert/test_root_certs_android.cc", - "cert/x509_util_android.cc", - "proxy_resolution/proxy_config_service_android.cc", "proxy_resolution/proxy_config_service_android.h", - "ssl/ssl_platform_key_android.cc", - "ssl/ssl_platform_key_android.h", ] } @@ -1764,7 +1750,7 @@ source_set("net_deps") { } if (is_android) { - public_deps += [ ":net_jni_headers" ] + public_deps += [] } if (is_fuchsia) { @@ -1777,7 +1763,7 @@ source_set("net_deps") { if (use_platform_icu_alternatives) { if (is_android) { - public_deps += [ ":net_jni_headers" ] + public_deps += [] } } else { public_deps += [ diff --git a/src/net/android/network_activation_request_stub.cc b/src/net/android/network_activation_request_stub.cc new file mode 100644 index 0000000000..8596d008c9 --- /dev/null +++ b/src/net/android/network_activation_request_stub.cc @@ -0,0 +1,27 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/android/network_activation_request.h" + +namespace net { +namespace android { + +NetworkActivationRequest::NetworkActivationRequest(TransportType transport) + : task_runner_(base::SequencedTaskRunnerHandle::Get()) { + weak_self_ = weak_ptr_factory_.GetWeakPtr(); +} + +NetworkActivationRequest::~NetworkActivationRequest() { +} + +void NetworkActivationRequest::NotifyAvailable(JNIEnv* env, + NetworkHandle network) { +} + +void NetworkActivationRequest::NotifyAvailableOnCorrectSequence( + NetworkHandle network) { +} + +} // namespace android +} // namespace net diff --git a/src/net/android/network_library_stub.cc b/src/net/android/network_library_stub.cc new file mode 100644 index 0000000000..8632eba439 --- /dev/null +++ b/src/net/android/network_library_stub.cc @@ -0,0 +1,98 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/android/network_library.h" + +#include "net/base/net_errors.h" + +namespace net { +namespace android { + +void VerifyX509CertChain(const std::vector& cert_chain, + std::string_view auth_type, + std::string_view host, + CertVerifyStatusAndroid* status, + bool* is_issued_by_known_root, + std::vector* verified_chain) { +} + +void AddTestRootCertificate(const uint8_t* cert, size_t len) { +} + +void ClearTestRootCertificates() { +} + +bool IsCleartextPermitted(std::string_view host) { + return true; +} + +bool HaveOnlyLoopbackAddresses() { + return false; +} + +bool GetMimeTypeFromExtension(std::string_view extension, + std::string* result) { + return false; +} + +std::string GetTelephonyNetworkOperator() { + return {}; +} + +std::string GetTelephonySimOperator() { + return {}; +} + +bool GetIsRoaming() { + return false; +} + +bool GetIsCaptivePortal() { + return false; +} + +std::string GetWifiSSID() { + return {}; +} + +std::optional GetWifiSignalLevel() { + return {}; +} + +bool GetCurrentDnsServers(std::vector* dns_servers, + bool* dns_over_tls_active, + std::string* dns_over_tls_hostname, + std::vector* search_suffixes) { + return false; +} + +bool GetDnsServersForNetwork(std::vector* dns_servers, + bool* dns_over_tls_active, + std::string* dns_over_tls_hostname, + std::vector* search_suffixes, + handles::NetworkHandle network) { + return false; +} + +bool ReportBadDefaultNetwork() { + return false; +} + +void TagSocket(SocketDescriptor socket, uid_t uid, int32_t tag) { +} + +int BindToNetwork(SocketDescriptor socket, handles::NetworkHandle network) { + return ERR_NOT_IMPLEMENTED; +} + +int GetAddrInfoForNetwork(handles::NetworkHandle network, + const char* node, + const char* service, + const struct addrinfo* hints, + struct addrinfo** res) { + return EAI_SYSTEM; +} + +} // namespace android +} // namespace net diff --git a/src/net/android/radio_activity_tracker_stub.cc b/src/net/android/radio_activity_tracker_stub.cc new file mode 100644 index 0000000000..34b8ea3cdf --- /dev/null +++ b/src/net/android/radio_activity_tracker_stub.cc @@ -0,0 +1,19 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/android/radio_activity_tracker.h" + +#include "net/traffic_annotation/network_traffic_annotation.h" + +namespace net { +namespace android { + +void MaybeRecordTCPWriteForWakeupTrigger( + const NetworkTrafficAnnotationTag& traffic_annotation) {} + +void MaybeRecordUDPWriteForWakeupTrigger( + const NetworkTrafficAnnotationTag& traffic_annotation) {} + +} // namespace android +} // namespace net