libchrome: build libchrome on Android target with OS_ANDROID

Android target is now built with OS_ANDROID.
Note __ANDROID__ remains defined by the Android toolchain when building
for Android target.

(For Android hosts, __ANDROID_HOST__ and __linux__ is defined, and
OS_LINUX is used. This is not in the scope of this CL.)

In the original Chromium browser code, OS_ANDROID is used to build the
browser on Android.
With this change, most local libchrome patches that changed
"\#if defined(OS_ANDROID)" to
"\#if defined(OS_ANDROID) || defined(__ANDROID__)"
(or the negation) are removed which simplifies maintenance.

Note there is code that applies to Chromium browser on Android but not
libchrome on Android targets.
Since for libchrome, OS_ANDROID implies the latter and never the former,
to avoid confusion caused by use of macros if-else, those cases are now
guarded by "\#if defined(OS_ANDROID) && 0" (or equivalent logic).

In Android.bp, some Android specific code are added to the source list
and the conflicting posix specific code are excluded when building for
Android. Necessary dependencies are also added.

Android specific code (e.g.
base/memory/platform_shared_memory_region_android.cc) introduces use of
ashmem_get_prot_region which is not implemented in Android libcutils.
Since ashmem is largely deprecated in upstream (migiration to memfd is
on-going), add local implementation to third_party/ashmem/ashmem.h.
(See b/153118750 for detailed discussion.)

trace_event is not supported in libchrome.
To maintain build compatibility, in base/trace_event/trace_event.h, more
empty trace macros are defined.
To avoid includes of more trace_event code by
base/memory/shared_memory_tracker.h, in (its only usage in)
b/m/platform_shared_memory_region_android.cc, replace
SharedMemoryTracker::GetDumpNameForTracing by the actual implementation.

Support for MessageLoopForUI is dropped to avoid dependency on
libandroid ALooper.
The Android UI thread is tied to the Android framework and is not used.

Bug: 109925343
Test: presumbit
Test: cherry-picked to ChromeOS libchrome, passes pre-CQ
Change-Id: Ib698eaccb1741c7c9cdba8452a967caa788bb547
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/external/libchrome/+/2220416
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Qijiang Fan <fqj@google.com>
Tested-by: Qijiang Fan <fqj@google.com>

(Reconstructed from 144774bb4c8d73cc610760d7826ed43a9076b99a)
15 files changed
tree: 90d5f3bf638779874d89f7b9ade99479d8e75665
  1. base/
  2. build/
  3. components/
  4. crypto/
  5. dbus/
  6. device/
  7. ipc/
  8. libchrome_tools/
  9. mojo/
  10. soong/
  11. testing/
  12. third_party/
  13. ui/
  14. .gitignore
  15. Android.bp
  16. BUILD.gn
  17. BUILD.IGNORE
  18. MODULE_LICENSE_BSD
  19. NOTICE
  20. OWNERS
  21. PRESUBMIT.cfg
  22. README.md
  23. testrunner.cc
README.md

libchrome

Overview

This directory includes the source from Chrome's libbase for use in Chrome OS.

See libchrome.md for more info.