mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2026-05-28 18:06:32 +03:00
android: base: Add Android stubs
This commit is contained in:
@@ -1183,113 +1183,40 @@ component("base") {
|
||||
# Android.
|
||||
if (is_android) {
|
||||
sources += [
|
||||
"android/android_info.cc",
|
||||
"android/android_info.h",
|
||||
"android/android_input_receiver_compat.cc",
|
||||
"android/android_input_receiver_compat.h",
|
||||
"android/apk_assets.cc",
|
||||
"android/apk_assets.h",
|
||||
"android/apk_info.cc",
|
||||
"android/android_info_stub.cc",
|
||||
"android/apk_info.h",
|
||||
"android/application_status_listener.cc",
|
||||
"android/apk_info_stub.cc",
|
||||
"android/application_status_listener.h",
|
||||
"android/application_status_listener_stub.cc",
|
||||
"android/background_thread_pool_field_trial.cc",
|
||||
"android/background_thread_pool_field_trial.h",
|
||||
"android/base_feature_map.cc",
|
||||
"android/bundle_utils.cc",
|
||||
"android/bundle_utils.h",
|
||||
"android/child_process_binding_types.h",
|
||||
"android/child_process_service.cc",
|
||||
"android/child_process_service.h",
|
||||
"android/content_uri_utils.cc",
|
||||
"android/content_uri_utils.h",
|
||||
"android/cpu_features.cc",
|
||||
"android/device_info.cc",
|
||||
"android/content_uri_utils_stub.cc",
|
||||
"android/device_info.h",
|
||||
"android/early_trace_event_binding.cc",
|
||||
"android/early_trace_event_binding.h",
|
||||
"android/event_log.cc",
|
||||
"android/event_log.h",
|
||||
"android/feature_list_jni.cc",
|
||||
"android/feature_map.cc",
|
||||
"android/feature_map.h",
|
||||
"android/features_jni.cc",
|
||||
"android/field_trial_list.cc",
|
||||
"android/important_file_writer_android.cc",
|
||||
"android/input_hint_checker.cc",
|
||||
"android/input_hint_checker.h",
|
||||
"android/java_handler_thread.cc",
|
||||
"android/java_handler_thread.h",
|
||||
"android/java_heap_dump_generator.cc",
|
||||
"android/java_heap_dump_generator.h",
|
||||
"android/java_runtime.cc",
|
||||
"android/java_runtime.h",
|
||||
"android/locale_utils.cc",
|
||||
"android/locale_utils.h",
|
||||
"android/meminfo_dump_provider.cc",
|
||||
"android/meminfo_dump_provider.h",
|
||||
"android/memory_pressure_listener_android.cc",
|
||||
"android/memory_pressure_listener_android.h",
|
||||
"android/memory_purge_manager_android.cc",
|
||||
"android/memory_purge_manager_android.h",
|
||||
"android/path_service_android.cc",
|
||||
"android/path_utils.cc",
|
||||
"android/path_utils.h",
|
||||
"android/pmf_utils.cc",
|
||||
"android/pmf_utils.h",
|
||||
"android/pre_freeze_background_memory_trimmer.cc",
|
||||
"android/pre_freeze_background_memory_trimmer.h",
|
||||
"android/radio_utils.cc",
|
||||
"android/radio_utils.h",
|
||||
"android/requires_api.h",
|
||||
"android/scoped_input_event.cc",
|
||||
"android/scoped_input_event.h",
|
||||
"android/scoped_service_binding_batch.cc",
|
||||
"android/scoped_service_binding_batch.h",
|
||||
"android/self_compaction_manager.cc",
|
||||
"android/self_compaction_manager.h",
|
||||
"android/shared_preferences/shared_preferences_manager.cc",
|
||||
"android/shared_preferences/shared_preferences_manager.h",
|
||||
"android/sys_utils.cc",
|
||||
"android/sys_utils.h",
|
||||
"android/task_scheduler/post_task_android.cc",
|
||||
"android/task_scheduler/post_task_android.h",
|
||||
"android/task_scheduler/task_runner_android.cc",
|
||||
"android/task_scheduler/task_runner_android.h",
|
||||
"android/task_scheduler/task_traits_android.h",
|
||||
"android/thread_instruction_count.cc",
|
||||
"android/thread_instruction_count.h",
|
||||
"android/device_info_stub.cc",
|
||||
"android/virtual_document_path.cc",
|
||||
"android/virtual_document_path.h",
|
||||
"android/yield_to_looper_checker.cc",
|
||||
"android/yield_to_looper_checker.h",
|
||||
"android/sys_utils.h",
|
||||
"android/sys_utils_stub.cc",
|
||||
"debug/stack_trace_android.cc",
|
||||
"files/file_android.cc",
|
||||
"files/file_android.h",
|
||||
"files/file_util_android.cc",
|
||||
"files/scoped_file_android.cc",
|
||||
"memory/platform_shared_memory_mapper_android.cc",
|
||||
"memory/platform_shared_memory_region_android.cc",
|
||||
"message_loop/message_pump_android.cc",
|
||||
"message_loop/message_pump_android.h",
|
||||
"os_compat_android.cc",
|
||||
"os_compat_android.h",
|
||||
"power_monitor/energy_monitor_android.h",
|
||||
"process/process_android.cc",
|
||||
"profiler/native_unwinder_android_map_delegate.h",
|
||||
"profiler/native_unwinder_android_memory_regions_map.h",
|
||||
"profiler/stack_sampler_android.cc",
|
||||
"system/sys_info_android.cc",
|
||||
"threading/platform_thread_android.cc",
|
||||
"version_info/android/channel_getter.cc",
|
||||
"version_info/android/channel_getter.h",
|
||||
"threading/platform_thread_android_stub.cc",
|
||||
|
||||
# Android uses some Linux sources.
|
||||
"debug/elf_reader.cc",
|
||||
"debug/elf_reader.h",
|
||||
"debug/proc_maps_linux.cc",
|
||||
"debug/proc_maps_linux.h",
|
||||
"power_monitor/power_monitor_device_source_android.cc",
|
||||
"process/internal_linux.cc",
|
||||
"process/internal_linux.h",
|
||||
"process/memory_linux.cc",
|
||||
@@ -1358,7 +1285,7 @@ component("base") {
|
||||
# Make jni.h available.
|
||||
configs += [ "//third_party/jdk" ]
|
||||
}
|
||||
if (is_android || is_robolectric) {
|
||||
if (is_robolectric) {
|
||||
sources += [
|
||||
"android/base_jni_init.cc",
|
||||
"android/base_jni_init.h",
|
||||
@@ -1401,21 +1328,11 @@ component("base") {
|
||||
"android/unguessable_token_android.h",
|
||||
]
|
||||
deps += [
|
||||
":callback_jni($default_toolchain)",
|
||||
":command_line_jni($default_toolchain)",
|
||||
":java_exception_reporter_jni($default_toolchain)",
|
||||
":jni_android_jni($default_toolchain)",
|
||||
":jni_callback_jni($default_toolchain)",
|
||||
":jni_utils_jni($default_toolchain)",
|
||||
":library_loader_jni($default_toolchain)",
|
||||
":metrics_jni($default_toolchain)",
|
||||
":tasks_minimal_jni($default_toolchain)",
|
||||
":token_jni($default_toolchain)",
|
||||
]
|
||||
public_deps += [
|
||||
":uuid_jni($default_toolchain)",
|
||||
"//third_party/jni_zero",
|
||||
"//build:robolectric_buildflags",
|
||||
]
|
||||
}
|
||||
if (is_android || is_robolectric) {
|
||||
public_deps += [ "//third_party/jni_zero" ]
|
||||
} # is_android || is_robolectric
|
||||
|
||||
# Chromeos.
|
||||
|
||||
79
src/base/android/android_info_stub.cc
Normal file
79
src/base/android/android_info_stub.cc
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/android/android_info.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
static constexpr std::string empty;
|
||||
|
||||
namespace base::android::android_info {
|
||||
void Set(const IAndroidInfo& info) {
|
||||
}
|
||||
|
||||
const std::string& device() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& manufacturer() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& model() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& brand() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& android_build_id() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& build_type() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& board() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& android_build_fp() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
int sdk_int() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_debug_android() {
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string& version_incremental() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& hardware() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& codename() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& soc_manufacturer() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& abi_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& security_patch() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
} // namespace base::android::android_info
|
||||
59
src/base/android/apk_info_stub.cc
Normal file
59
src/base/android/apk_info_stub.cc
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/android/apk_info.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
static constexpr std::string empty;
|
||||
|
||||
namespace base::android::apk_info {
|
||||
|
||||
void Set(const IApkInfo& info) {
|
||||
}
|
||||
|
||||
const std::string& host_package_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& host_version_code() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& host_package_label() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& package_version_code() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& package_version_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& package_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& resources_version() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const std::string& installer_package_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
bool is_debug_app() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int target_sdk_version() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string host_signing_cert_sha256() {
|
||||
return empty;
|
||||
}
|
||||
} // namespace base::android::apk_info
|
||||
35
src/base/android/application_status_listener_stub.cc
Normal file
35
src/base/android/application_status_listener_stub.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2014 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 "base/android/application_status_listener.h"
|
||||
|
||||
namespace base {
|
||||
namespace android {
|
||||
|
||||
ApplicationStatusListener::ApplicationStatusListener() = default;
|
||||
ApplicationStatusListener::~ApplicationStatusListener() = default;
|
||||
|
||||
// static
|
||||
std::unique_ptr<ApplicationStatusListener> ApplicationStatusListener::New(
|
||||
const ApplicationStateChangeCallback& callback) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
void ApplicationStatusListener::NotifyApplicationStateChange(
|
||||
ApplicationState state) {
|
||||
}
|
||||
|
||||
// static
|
||||
ApplicationState ApplicationStatusListener::GetState() {
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
bool ApplicationStatusListener::HasVisibleActivities() {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace base
|
||||
73
src/base/android/build_info_stub.cc
Normal file
73
src/base/android/build_info_stub.cc
Normal file
@@ -0,0 +1,73 @@
|
||||
// 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 <cstdlib>
|
||||
|
||||
#include "base/android/build_info.h"
|
||||
#include "base/notreached.h"
|
||||
|
||||
int __system_property_get(const char* name, char* value);
|
||||
|
||||
namespace {
|
||||
int GetSdkInt() {
|
||||
constexpr int kPropNameMax = 32;
|
||||
char prop_info[kPropNameMax];
|
||||
__system_property_get("ro.build.version.sdk", prop_info);
|
||||
return std::atoi(prop_info);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace base {
|
||||
namespace android {
|
||||
|
||||
struct BuildInfoSingletonTraits {
|
||||
static BuildInfo* New() { return new BuildInfo(); }
|
||||
|
||||
static void Delete(BuildInfo* x) {
|
||||
// We're leaking this type, see kRegisterAtExit.
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
static const bool kRegisterAtExit = false;
|
||||
};
|
||||
|
||||
BuildInfo::BuildInfo()
|
||||
: brand_(""),
|
||||
device_(""),
|
||||
android_build_id_(""),
|
||||
manufacturer_(""),
|
||||
model_(""),
|
||||
sdk_int_(GetSdkInt()),
|
||||
build_type_(""),
|
||||
board_(""),
|
||||
host_package_name_(""),
|
||||
host_version_code_(""),
|
||||
host_package_label_(""),
|
||||
package_name_(""),
|
||||
package_version_code_(""),
|
||||
package_version_name_(""),
|
||||
android_build_fp_(""),
|
||||
installer_package_name_(""),
|
||||
abi_name_(""),
|
||||
resources_version_(""),
|
||||
target_sdk_version_(0),
|
||||
is_debug_android_(false),
|
||||
is_tv_(false),
|
||||
version_incremental_(""),
|
||||
hardware_(""),
|
||||
is_automotive_(false),
|
||||
codename_(""),
|
||||
vulkan_deqp_level_(0),
|
||||
is_foldable_(false),
|
||||
soc_manufacturer_(""),
|
||||
is_debug_app_(false),
|
||||
is_desktop_(false) {}
|
||||
|
||||
// static
|
||||
BuildInfo* BuildInfo::GetInstance() {
|
||||
return Singleton<BuildInfo, BuildInfoSingletonTraits>::get();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace base
|
||||
77
src/base/android/content_uri_utils_stub.cc
Normal file
77
src/base/android/content_uri_utils_stub.cc
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2013 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 "base/android/content_uri_utils.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
|
||||
bool ContentUriExists(const FilePath&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<std::string> TranslateOpenFlagsToJavaMode(uint32_t) {
|
||||
return {};
|
||||
}
|
||||
|
||||
base::android::ScopedJavaLocalRef<jobject> OpenContentUri(const FilePath&, uint32_t) {
|
||||
return {};
|
||||
}
|
||||
|
||||
int ContentUriGetFd(const base::android::JavaRef<jobject>&) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ContentUriClose(const base::android::JavaRef<jobject>&) {
|
||||
}
|
||||
|
||||
bool ContentUriGetFileInfo(const FilePath&, FileEnumerator::FileInfo*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<FileEnumerator::FileInfo> ListContentUriDirectory(const FilePath&, int) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DeleteContentUri(const FilePath& content_uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsDocumentUri(const FilePath& content_uri) {
|
||||
return false;
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
std::string GetContentUriMimeType(const FilePath& content_uri) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool MaybeGetFileDisplayName(const FilePath& content_uri,
|
||||
std::u16string* file_display_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath ContentUriBuildDocumentUriUsingTree(const FilePath&,
|
||||
const std::string&) {
|
||||
return {};
|
||||
}
|
||||
|
||||
FilePath
|
||||
ContentUriGetChildDocumentOrQuery(const FilePath&,
|
||||
const std::string&,
|
||||
const std::string&,
|
||||
bool,
|
||||
bool) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ContentUriIsCreateChildDocumentQuery(const FilePath&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath
|
||||
ContentUriGetDocumentFromQuery(const FilePath&, bool) {
|
||||
return {};
|
||||
}
|
||||
} // namespace base
|
||||
61
src/base/android/device_info_stub.cc
Normal file
61
src/base/android/device_info_stub.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/android/device_info.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
static constexpr std::string empty;
|
||||
|
||||
namespace base::android::device_info {
|
||||
void Set(const IDeviceInfo& info) {
|
||||
}
|
||||
|
||||
const std::string& gms_version_code() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
void set_gms_version_code_for_test(const std::string& gms_version_code) {
|
||||
}
|
||||
|
||||
bool is_tv() {
|
||||
return false;
|
||||
}
|
||||
bool is_automotive() {
|
||||
return false;
|
||||
}
|
||||
bool is_foldable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_desktop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t vulkan_deqp_level() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_xr() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_tablet() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool was_launched_on_large_display() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string device_name() {
|
||||
return empty;
|
||||
}
|
||||
|
||||
void set_is_xr_for_testing() {
|
||||
}
|
||||
|
||||
void reset_is_xr_for_testing() {
|
||||
}
|
||||
} // namespace base::android::device_info
|
||||
@@ -70,7 +70,7 @@ class BASE_EXPORT InputHintChecker {
|
||||
// Throttles the calls to one every few milliseconds. When a call is made
|
||||
// before the minimal time interval passed since the previous call, returns
|
||||
// false.
|
||||
static bool HasInput();
|
||||
static bool HasInput() { return false; }
|
||||
|
||||
// RAII override of GetInstance() for testing.
|
||||
struct ScopedOverrideInstance {
|
||||
|
||||
97
src/base/android/jni_android_stub.cc
Normal file
97
src/base/android/jni_android_stub.cc
Normal file
@@ -0,0 +1,97 @@
|
||||
// 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 "base/android/jni_android.h"
|
||||
|
||||
#include "base/debug/debugging_buildflags.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/threading/thread_local.h"
|
||||
#include "third_party/abseil-cpp/absl/base/attributes.h"
|
||||
|
||||
namespace base {
|
||||
namespace android {
|
||||
void InitVM(JavaVM* vm) {
|
||||
}
|
||||
|
||||
void InitGlobalClassLoader(JNIEnv* env) {
|
||||
}
|
||||
|
||||
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env,
|
||||
const char* class_name,
|
||||
const char* split_name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This is duplicated with LazyGetClass below because these are performance
|
||||
// sensitive.
|
||||
jclass LazyGetClass(JNIEnv* env,
|
||||
const char* class_name,
|
||||
const char* split_name,
|
||||
std::atomic<jclass>* atomic_class_id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This is duplicated with LazyGetClass above because these are performance
|
||||
// sensitive.
|
||||
jclass LazyGetClass(JNIEnv* env,
|
||||
const char* class_name,
|
||||
std::atomic<jclass>* atomic_class_id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<MethodID::Type type>
|
||||
jmethodID MethodID::Get(JNIEnv* env,
|
||||
jclass clazz,
|
||||
const char* method_name,
|
||||
const char* jni_signature) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If |atomic_method_id| set, it'll return immediately. Otherwise, it'll call
|
||||
// into ::Get() above. If there's a race, it's ok since the values are the same
|
||||
// (and the duplicated effort will happen only once).
|
||||
template<MethodID::Type type>
|
||||
jmethodID MethodID::LazyGet(JNIEnv* env,
|
||||
jclass clazz,
|
||||
const char* method_name,
|
||||
const char* jni_signature,
|
||||
std::atomic<jmethodID>* atomic_method_id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Various template instantiations.
|
||||
template jmethodID MethodID::Get<MethodID::TYPE_STATIC>(
|
||||
JNIEnv* env, jclass clazz, const char* method_name,
|
||||
const char* jni_signature);
|
||||
|
||||
template jmethodID MethodID::Get<MethodID::TYPE_INSTANCE>(
|
||||
JNIEnv* env, jclass clazz, const char* method_name,
|
||||
const char* jni_signature);
|
||||
|
||||
template jmethodID MethodID::LazyGet<MethodID::TYPE_STATIC>(
|
||||
JNIEnv* env, jclass clazz, const char* method_name,
|
||||
const char* jni_signature, std::atomic<jmethodID>* atomic_method_id);
|
||||
|
||||
template jmethodID MethodID::LazyGet<MethodID::TYPE_INSTANCE>(
|
||||
JNIEnv* env, jclass clazz, const char* method_name,
|
||||
const char* jni_signature, std::atomic<jmethodID>* atomic_method_id);
|
||||
|
||||
void CheckException(JNIEnv* env) {
|
||||
}
|
||||
|
||||
std::string GetJavaExceptionInfo(JNIEnv* env,
|
||||
const JavaRef<jthrowable>& java_throwable) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string GetJavaStackTraceIfPresent() {
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace base
|
||||
16
src/base/android/sys_utils_stub.cc
Normal file
16
src/base/android/sys_utils_stub.cc
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2013 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/android/sys_utils.h"
|
||||
|
||||
namespace base {
|
||||
namespace android {
|
||||
|
||||
int GetCachedLowMemoryDeviceThresholdMb() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
} // namespace base
|
||||
@@ -10,9 +10,6 @@
|
||||
#include "base/android/jni_array.h"
|
||||
#include "base/android/jni_string.h"
|
||||
|
||||
// Must come after all headers that specialize FromJniType() / ToJniType().
|
||||
#include "base/virtual_document_path_jni/VirtualDocumentPath_jni.h"
|
||||
|
||||
namespace base::files_internal {
|
||||
|
||||
VirtualDocumentPath::VirtualDocumentPath(
|
||||
@@ -29,53 +26,28 @@ VirtualDocumentPath::~VirtualDocumentPath() = default;
|
||||
|
||||
std::optional<VirtualDocumentPath> VirtualDocumentPath::Parse(
|
||||
const std::string& path) {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
base::android::ScopedJavaLocalRef<jobject> obj =
|
||||
Java_VirtualDocumentPath_parse(env, path);
|
||||
if (obj.is_null()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return VirtualDocumentPath(obj);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<std::string> VirtualDocumentPath::ResolveToContentUri() const {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
std::string uri =
|
||||
Java_VirtualDocumentPath_resolveToContentUriString(env, obj_);
|
||||
if (uri.empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return uri;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::string VirtualDocumentPath::ToString() const {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
return Java_VirtualDocumentPath_toString(env, obj_);
|
||||
return {};
|
||||
}
|
||||
|
||||
bool VirtualDocumentPath::Mkdir(mode_t mode) const {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
return Java_VirtualDocumentPath_mkdir(env, obj_);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VirtualDocumentPath::WriteFile(span<const uint8_t> data) const {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
base::android::ScopedJavaLocalRef<jbyteArray> bs =
|
||||
base::android::ToJavaByteArray(env, data);
|
||||
return Java_VirtualDocumentPath_writeFile(env, obj_, bs);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<std::pair<std::string, bool>> VirtualDocumentPath::CreateOrOpen()
|
||||
const {
|
||||
JNIEnv* env = android::AttachCurrentThread();
|
||||
base::android::ScopedJavaLocalRef<jobject> result =
|
||||
Java_VirtualDocumentPath_createOrOpen(env, obj_);
|
||||
if (result.is_null()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
std::string uri = Java_CreateOrOpenResult_getContentUriString(env, result);
|
||||
bool created = Java_CreateOrOpenResult_getCreated(env, result);
|
||||
return std::make_pair(uri, created);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace base::files_internal
|
||||
|
||||
@@ -9,19 +9,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
|
||||
// Must come after all headers that specialize FromJniType() / ToJniType().
|
||||
#include "base/file_utils_jni/FileUtils_jni.h"
|
||||
|
||||
namespace base {
|
||||
namespace android {
|
||||
|
||||
static std::string JNI_FileUtils_GetAbsoluteFilePath(
|
||||
JNIEnv* env,
|
||||
const std::string& file_path) {
|
||||
return MakeAbsoluteFilePath(base::FilePath(file_path)).value();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
bool GetShmemTempDir(bool executable, base::FilePath* path) {
|
||||
return PathService::Get(base::DIR_CACHE, path);
|
||||
|
||||
@@ -497,7 +497,6 @@ void MessagePumpAndroid::DoNonDelayedLooperWork(bool do_idle_work) {
|
||||
// initialization, in multi-window cases, or when a previous value is
|
||||
// cached to throttle polling the input channel.
|
||||
if (InputHintChecker::HasInput()) {
|
||||
InputHintChecker::GetInstance().set_is_after_input_yield(true);
|
||||
ScheduleWork();
|
||||
return;
|
||||
}
|
||||
@@ -599,12 +598,6 @@ void MessagePumpAndroid::OnReturnFromLooper() {
|
||||
if (!is_type_ui_) {
|
||||
return;
|
||||
}
|
||||
auto& checker = InputHintChecker::GetInstance();
|
||||
if (checker.is_after_input_yield()) {
|
||||
InputHintChecker::GetInstance().RecordInputHintResult(
|
||||
InputHintResult::kBackToNative);
|
||||
}
|
||||
checker.set_is_after_input_yield(false);
|
||||
}
|
||||
|
||||
void MessagePumpAndroid::ScheduleDelayedWork(
|
||||
|
||||
106
src/base/threading/platform_thread_android_stub.cc
Normal file
106
src/base/threading/platform_thread_android_stub.cc
Normal file
@@ -0,0 +1,106 @@
|
||||
// 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 "base/threading/platform_thread.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/threading/platform_thread_internal_posix.h"
|
||||
#include "base/threading/thread_id_name_manager.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace internal {
|
||||
|
||||
// - kRealtimeAudio corresponds to Android's PRIORITY_AUDIO = -16 value.
|
||||
// - kDisplay corresponds to Android's PRIORITY_DISPLAY = -4 value.
|
||||
// - kBackground corresponds to Android's PRIORITY_BACKGROUND = 10 value and can
|
||||
// result in heavy throttling and force the thread onto a little core on
|
||||
// big.LITTLE devices.
|
||||
const ThreadTypeToNiceValuePairForTest kThreadTypeToNiceValueMapForTest[7] = {
|
||||
{ThreadType::kRealtimeAudio, -16}, {ThreadType::kPresentation, -4},
|
||||
{ThreadType::kDefault, 0}, {ThreadType::kUtility, 1},
|
||||
{ThreadType::kBackground, 10},
|
||||
};
|
||||
|
||||
// - kBackground corresponds to Android's PRIORITY_BACKGROUND = 10 value and can
|
||||
// result in heavy throttling and force the thread onto a little core on
|
||||
// big.LITTLE devices.
|
||||
// - kUtility corresponds to Android's THREAD_PRIORITY_LESS_FAVORABLE = 1 value.
|
||||
// - kDisplayCritical corresponds to Android's PRIORITY_DISPLAY = -4 value.
|
||||
// - kRealtimeAudio corresponds to Android's PRIORITY_AUDIO = -16 value.
|
||||
|
||||
int ThreadTypeToNiceValue(const ThreadType thread_type) {
|
||||
switch (thread_type) {
|
||||
case ThreadType::kBackground:
|
||||
return 10;
|
||||
case ThreadType::kUtility:
|
||||
return 1;
|
||||
case ThreadType::kDefault:
|
||||
return 0;
|
||||
case ThreadType::kPresentation:
|
||||
case ThreadType::kAudioProcessing:
|
||||
return -4;
|
||||
case ThreadType::kRealtimeAudio:
|
||||
return -16;
|
||||
}
|
||||
}
|
||||
|
||||
bool CanSetThreadTypeToRealtimeAudio() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetCurrentThreadTypeImpl(ThreadType thread_type,
|
||||
MessagePumpType pump_type_hint) {}
|
||||
|
||||
PlatformPriorityOverride SetThreadTypeOverride(
|
||||
PlatformThreadHandle thread_handle,
|
||||
ThreadType thread_type) {
|
||||
return {};
|
||||
}
|
||||
void RemoveThreadTypeOverride(
|
||||
PlatformThreadHandle thread_handle,
|
||||
const PlatformPriorityOverride& priority_override_handle,
|
||||
ThreadType initial_thread_type) {}
|
||||
} // namespace internal
|
||||
|
||||
void PlatformThread::SetName(const std::string& name) {
|
||||
ThreadIdNameManager::GetInstance()->SetName(name);
|
||||
|
||||
// Like linux, on android we can get the thread names to show up in the
|
||||
// debugger by setting the process name for the LWP.
|
||||
// We don't want to do this for the main thread because that would rename
|
||||
// the process, causing tools like killall to stop working.
|
||||
if (PlatformThread::CurrentId().raw() == getpid())
|
||||
return;
|
||||
|
||||
// Set the name for the LWP (which gets truncated to 15 characters).
|
||||
int err = prctl(PR_SET_NAME, name.c_str());
|
||||
if (err < 0 && errno != EPERM)
|
||||
DPLOG(ERROR) << "prctl(PR_SET_NAME)";
|
||||
}
|
||||
|
||||
void InitThreading() {}
|
||||
|
||||
void TerminateOnThread() {}
|
||||
|
||||
size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
|
||||
#if !defined(ADDRESS_SANITIZER)
|
||||
return 0;
|
||||
#else
|
||||
// AddressSanitizer bloats the stack approximately 2x. Default stack size of
|
||||
// 1Mb is not enough for some tests (see http://crbug.com/263749 for example).
|
||||
return 2 * (1 << 20); // 2Mb
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
Reference in New Issue
Block a user