.. | ||
javatests | ||
jni_generator | ||
library_loader | ||
linker | ||
orderfile | ||
proguard | ||
shared_preferences | ||
task_scheduler | ||
android_hardware_buffer_compat.cc | ||
android_hardware_buffer_compat.h | ||
android_image_reader_compat.cc | ||
android_image_reader_compat.h | ||
android_input_receiver_compat.cc | ||
android_input_receiver_compat.h | ||
apk_assets.cc | ||
apk_assets.h | ||
application_status_listener_stub.cc | ||
application_status_listener.cc | ||
application_status_listener.h | ||
base_feature_map.cc | ||
base_jni_onload.cc | ||
base_jni_onload.h | ||
binder_box.cc | ||
binder_box.h | ||
binder.cc | ||
binder.h | ||
build_info_stub.cc | ||
build_info.cc | ||
build_info.h | ||
bundle_utils.cc | ||
bundle_utils.h | ||
callback_android.cc | ||
callback_android.h | ||
child_process_binding_types.h | ||
child_process_service.cc | ||
command_line_android.cc | ||
COMMON_METADATA | ||
content_uri_utils_stub.cc | ||
content_uri_utils.cc | ||
content_uri_utils.h | ||
cpu_features.cc | ||
DIR_METADATA | ||
early_trace_event_binding.cc | ||
early_trace_event_binding.h | ||
event_log.cc | ||
event_log.h | ||
feature_list_jni.cc | ||
feature_map.cc | ||
feature_map.h | ||
features_jni.cc | ||
field_trial_list.cc | ||
important_file_writer_android.cc | ||
input_hint_checker.cc | ||
input_hint_checker.h | ||
int_string_callback.cc | ||
int_string_callback.h | ||
jank_metric_uma_recorder.cc | ||
jank_metric_uma_recorder.h | ||
java_exception_reporter.cc | ||
java_exception_reporter.h | ||
java_handler_thread.cc | ||
java_handler_thread.h | ||
java_heap_dump_generator.cc | ||
java_heap_dump_generator.h | ||
java_runtime.cc | ||
java_runtime.h | ||
jni_android_stub.cc | ||
jni_android.cc | ||
jni_android.h | ||
jni_array.cc | ||
jni_array.h | ||
jni_bytebuffer.cc | ||
jni_bytebuffer.h | ||
jni_registrar.cc | ||
jni_registrar.h | ||
jni_string.cc | ||
jni_string.h | ||
jni_utils.cc | ||
jni_utils.h | ||
jni_weak_ref.h | ||
locale_utils.cc | ||
locale_utils.h | ||
meminfo_dump_provider.cc | ||
meminfo_dump_provider.h | ||
memory_pressure_listener_android.cc | ||
memory_pressure_listener_android.h | ||
memory_purge_manager_android.cc | ||
memory_purge_manager_android.h | ||
native_uma_recorder.cc | ||
OWNERS | ||
path_service_android.cc | ||
path_utils.cc | ||
path_utils.h | ||
pmf_utils.cc | ||
pmf_utils.h | ||
pre_freeze_background_memory_trimmer.cc | ||
pre_freeze_background_memory_trimmer.h | ||
radio_utils.cc | ||
radio_utils.h | ||
README.md | ||
requires_api.h | ||
resource_exclusions.gni | ||
robolectric_jni_onload.cc | ||
scoped_hardware_buffer_fence_sync.cc | ||
scoped_hardware_buffer_fence_sync.h | ||
scoped_hardware_buffer_handle.cc | ||
scoped_hardware_buffer_handle.h | ||
scoped_java_ref.h | ||
statistics_recorder_android.cc | ||
sys_utils.cc | ||
sys_utils.h | ||
thread_instruction_count.cc | ||
thread_instruction_count.h | ||
timezone_utils.cc | ||
timezone_utils.h | ||
token_android.cc | ||
token_android.h | ||
trace_event_binding.cc | ||
trace_event_binding.h | ||
unguessable_token_android.cc | ||
unguessable_token_android.h |
//base/android
This directory contains:
- C++ APIs that are broadly useful and are unique to
target_os="android"
, and - Java APIs that are broadly useful, along C++ bindings when necessary.
This directory does not contain Android-specific implementations / extensions
to APIs declared directly in //base
. Those live in //base/*_android.cc
, or
behind #ifdef
s.
Adding New APIs
The advice laid out in //base/README.md applies to this directory as well. The bars for what APIs should exist and for code quality are generally higher than for other directories. If you find yourself wanting to add a new API, you should expect that code reviews take multiple revisions and that they be met with (respectful) scrutiny.
If you are not sure whether an API would make sense to add, you can ask via
java@chromium.org.
It is common to add APIs to //chrome
(or elsewhere) first, and move them into
//base
after their usefulness has been proven.
What Uses //base/android?
The main two clients are Chrome and WebView, but it is also used by other
Chromium-based apps, such as Chromecast and Chrome Remote desktop. Some
//base/android
classes are used by //build
(this is a layering violation,
tracked in crbug/1364192 and crbug/1377351).
Two considerations for WebView:
- The application Context is that of the host app's.
- The UI thread might be different from the main thread.
New API Checklist
Here is a list of checks you should go through when adding a new API:
- The functionality does not already exist in system libraries (Java APIs,
Android SDK) or in already adopted
third_party
libraries, such as AndroidX. - Reasonable effort has been made to ensure the new API is discoverable. E.g.: Coordinate refactorings of existing patterns to it, add a [presubmit check], to recommend it, etc.
- Tests (ideally Robolectric) are added.
- Thought has been put into API design.
- E.g. adding
@Nullable
, or@DoNotMock
- E.g. adding test helpers, such as
ForTesting()
methods orTestRule
s - E.g. adding asserts or comments about thread-safety
- E.g. could usage of the API be made harder to get wrong?
- E.g. adding
Choosing a Reviewer
All members of //base/android/OWNERS
will be CC'ed on reviews through a
//WATCHLIST
entry. For new APIs, feel free to pick a reviewer at random.
For modifying existing files, it is best to use a reviewer from prior changes to
the file.