tree: e8fdb3e7e5187c657173922177ecd4b515ef0530 [path history] [tgz]
  1. java/
  2. javatests/
  3. jni_generator/
  4. junit/
  5. library_loader/
  6. linker/
  7. orderfile/
  8. proguard/
  9. shared_preferences/
  10. task_scheduler/
  11. android_hardware_buffer_compat.cc
  12. android_hardware_buffer_compat.h
  13. android_image_reader_compat.cc
  14. android_image_reader_compat.h
  15. android_input_receiver_compat.cc
  16. android_input_receiver_compat.h
  17. android_input_receiver_compat_unittest.cc
  18. apk_assets.cc
  19. apk_assets.h
  20. application_status_listener.cc
  21. application_status_listener.h
  22. application_status_listener_unittest.cc
  23. base_feature_map.cc
  24. base_jni_onload.cc
  25. base_jni_onload.h
  26. binder.cc
  27. binder.h
  28. binder_box.cc
  29. binder_box.h
  30. binder_unittest.cc
  31. build_info.cc
  32. build_info.h
  33. bundle_utils.cc
  34. bundle_utils.h
  35. callback_android.cc
  36. callback_android.h
  37. child_process_binding_types.h
  38. child_process_service.cc
  39. child_process_unittest.cc
  40. command_line_android.cc
  41. COMMON_METADATA
  42. content_uri_utils.cc
  43. content_uri_utils.h
  44. content_uri_utils_unittest.cc
  45. cpu_features.cc
  46. DIR_METADATA
  47. early_trace_event_binding.cc
  48. early_trace_event_binding.h
  49. event_log.cc
  50. event_log.h
  51. feature_list_jni.cc
  52. feature_map.cc
  53. feature_map.h
  54. features_jni.cc
  55. field_trial_list.cc
  56. important_file_writer_android.cc
  57. input_hint_checker.cc
  58. input_hint_checker.h
  59. int_string_callback.cc
  60. int_string_callback.h
  61. jank_metric_uma_recorder.cc
  62. jank_metric_uma_recorder.h
  63. jank_metric_uma_recorder_unittest.cc
  64. java_exception_reporter.cc
  65. java_exception_reporter.h
  66. java_handler_thread.cc
  67. java_handler_thread.h
  68. java_handler_thread_unittest.cc
  69. java_heap_dump_generator.cc
  70. java_heap_dump_generator.h
  71. java_runtime.cc
  72. java_runtime.h
  73. jni_android.cc
  74. jni_android.h
  75. jni_android_unittest.cc
  76. jni_array.cc
  77. jni_array.h
  78. jni_array_unittest.cc
  79. jni_bytebuffer.cc
  80. jni_bytebuffer.h
  81. jni_bytebuffer_unittest.cc
  82. jni_registrar.cc
  83. jni_registrar.h
  84. jni_string.cc
  85. jni_string.h
  86. jni_string_unittest.cc
  87. jni_utils.cc
  88. jni_utils.h
  89. jni_weak_ref.h
  90. locale_utils.cc
  91. locale_utils.h
  92. meminfo_dump_provider.cc
  93. meminfo_dump_provider.h
  94. meminfo_dump_provider_unittest.cc
  95. memory_pressure_listener_android.cc
  96. memory_pressure_listener_android.h
  97. memory_purge_manager_android.cc
  98. memory_purge_manager_android.h
  99. native_uma_recorder.cc
  100. OWNERS
  101. path_service_android.cc
  102. path_utils.cc
  103. path_utils.h
  104. path_utils_unittest.cc
  105. pmf_utils.cc
  106. pmf_utils.h
  107. pmf_utils_unittest.cc
  108. pre_freeze_background_memory_trimmer.cc
  109. pre_freeze_background_memory_trimmer.h
  110. pre_freeze_background_memory_trimmer_unittest.cc
  111. radio_utils.cc
  112. radio_utils.h
  113. radio_utils_unittest.cc
  114. README.md
  115. requires_api.h
  116. resource_exclusions.gni
  117. robolectric_jni_onload.cc
  118. scoped_hardware_buffer_fence_sync.cc
  119. scoped_hardware_buffer_fence_sync.h
  120. scoped_hardware_buffer_handle.cc
  121. scoped_hardware_buffer_handle.h
  122. scoped_java_ref.h
  123. scoped_java_ref_unittest.cc
  124. statistics_recorder_android.cc
  125. sys_utils.cc
  126. sys_utils.h
  127. sys_utils_unittest.cc
  128. thread_instruction_count.cc
  129. thread_instruction_count.h
  130. timezone_utils.cc
  131. timezone_utils.h
  132. token_android.cc
  133. token_android.h
  134. token_android_unittest.cc
  135. trace_event_binding.cc
  136. trace_event_binding.h
  137. unguessable_token_android.cc
  138. unguessable_token_android.h
  139. unguessable_token_android_unittest.cc
base/android/README.md

//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 #ifdefs.

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:

  1. The application Context is that of the host app's.
  2. 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:

  1. The functionality does not already exist in system libraries (Java APIs, Android SDK) or in already adopted third_party libraries, such as AndroidX.
  2. 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.
  3. Tests (ideally Robolectric) are added.
  4. Thought has been put into API design.
    • E.g. adding @Nullable, or @DoNotMock
    • E.g. adding test helpers, such as ForTesting() methods or TestRules
    • E.g. adding asserts or comments about thread-safety
    • E.g. could usage of the API be made harder to get wrong?

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.