Merge changes from topic "fsmgr_system_other"

* changes:
  fs_mgr: overlayfs clears readonly on scratch devices
  liblp: BLKROSET 0 prior to FlashPartitionTable
  fs_mgr: system_other does not want overlayfs.
diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp
index ce51b1c..20fd036 100644
--- a/adb/client/commandline.cpp
+++ b/adb/client/commandline.cpp
@@ -192,7 +192,9 @@
         " get-state                print offline | bootloader | device\n"
         " get-serialno             print <serial-number>\n"
         " get-devpath              print <device-path>\n"
-        " remount                  remount partitions read-write\n"
+        " remount [-R]\n"
+        "      remount partitions read-write. if a reboot is required, -R will\n"
+        "      will automatically reboot the device.\n"
         " reboot [bootloader|recovery|sideload|sideload-auto-reboot]\n"
         "     reboot the device; defaults to booting system image but\n"
         "     supports bootloader and recovery too. sideload reboots\n"
diff --git a/adb/daemon/mdns.cpp b/adb/daemon/mdns.cpp
index 849378f..3530f48 100644
--- a/adb/daemon/mdns.cpp
+++ b/adb/daemon/mdns.cpp
@@ -74,7 +74,7 @@
 
     if (error != kDNSServiceErr_NoError) {
         LOG(ERROR) << "Could not register mDNS service (" << error << ").";
-        mdns_registered = false;
+        return;
     }
 
     mdns_registered = true;
diff --git a/adb/daemon/remount_service.cpp b/adb/daemon/remount_service.cpp
index 80b3e06..3c9dd04 100644
--- a/adb/daemon/remount_service.cpp
+++ b/adb/daemon/remount_service.cpp
@@ -240,59 +240,57 @@
     std::vector<std::string> partitions{"/",        "/odm",   "/oem", "/product_services",
                                         "/product", "/vendor"};
 
-    bool verity_enabled = (system_verified || vendor_verified);
+    if (system_verified || vendor_verified) {
+        // Disable verity automatically (reboot will be required).
+        set_verity_enabled_state_service(unique_fd(dup(fd.get())), false);
 
-    // If we can use overlayfs, lets get it in place first
-    // before we struggle with determining deduplication operations.
-    if (!verity_enabled && fs_mgr_overlayfs_setup()) {
+        // If overlayfs is not supported, we try and remount or set up
+        // un-deduplication. If it is supported, we can go ahead and wait for
+        // a reboot.
+        if (fs_mgr_overlayfs_valid() != OverlayfsValidResult::kNotSupported) {
+            if (user_requested_reboot) {
+                if (android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot")) {
+                    WriteFdExactly(fd.get(), "rebooting device\n");
+                } else {
+                    WriteFdExactly(fd.get(), "reboot failed\n");
+                }
+            }
+            return;
+        }
+    } else if (fs_mgr_overlayfs_setup()) {
+        // If we can use overlayfs, lets get it in place first before we
+        // struggle with determining deduplication operations.
         Fstab fstab;
         if (ReadDefaultFstab(&fstab) && fs_mgr_overlayfs_mount_all(&fstab)) {
             WriteFdExactly(fd.get(), "overlayfs mounted\n");
         }
     }
 
-    // Find partitions that are deduplicated, and can be un-deduplicated.
+    // If overlayfs is supported, we don't bother trying to un-deduplicate
+    // partitions.
     std::set<std::string> dedup;
-    for (const auto& part : partitions) {
-        auto partition = part;
-        if ((part == "/") && !find_mount("/system", false).empty()) partition = "/system";
-        std::string dev = find_mount(partition.c_str(), partition == "/");
-        if (dev.empty() || !fs_mgr_has_shared_blocks(partition, dev)) {
-            continue;
-        }
-        if (can_unshare_blocks(fd.get(), dev.c_str())) {
-            dedup.emplace(partition);
-        }
-    }
-
-    // Reboot now if the user requested it (and an operation needs a reboot).
-    if (user_requested_reboot) {
-        if (!dedup.empty() || verity_enabled) {
-            if (verity_enabled) {
-                set_verity_enabled_state_service(unique_fd(dup(fd.get())), false);
+    if (fs_mgr_overlayfs_valid() == OverlayfsValidResult::kNotSupported) {
+        // Find partitions that are deduplicated, and can be un-deduplicated.
+        for (const auto& part : partitions) {
+            auto partition = part;
+            if ((part == "/") && !find_mount("/system", false).empty()) partition = "/system";
+            std::string dev = find_mount(partition.c_str(), partition == "/");
+            if (dev.empty() || !fs_mgr_has_shared_blocks(partition, dev)) {
+                continue;
             }
-            reboot_for_remount(fd.get(), !dedup.empty());
-            return;
+            if (can_unshare_blocks(fd.get(), dev.c_str())) {
+                dedup.emplace(partition);
+            }
         }
-        WriteFdExactly(fd.get(), "No reboot needed, skipping -R.\n");
-    }
 
-    // If we need to disable-verity, but we also need to perform a recovery
-    // fsck for deduplicated partitions, hold off on warning about verity. We
-    // can handle both verity and the recovery fsck in the same reboot cycle.
-    if (verity_enabled && dedup.empty()) {
-        // Allow remount but warn of likely bad effects
-        bool both = system_verified && vendor_verified;
-        WriteFdFmt(fd.get(), "dm_verity is enabled on the %s%s%s partition%s.\n",
-                   system_verified ? "system" : "", both ? " and " : "",
-                   vendor_verified ? "vendor" : "", both ? "s" : "");
-        WriteFdExactly(fd.get(),
-                       "Use \"adb disable-verity\" to disable verity.\n"
-                       "If you do not, remount may succeed, however, you will still "
-                       "not be able to write to these volumes.\n");
-        WriteFdExactly(fd.get(),
-                       "Alternately, use \"adb remount -R\" to disable verity "
-                       "and automatically reboot.\n");
+        // Reboot now if the user requested it (and an operation needs a reboot).
+        if (user_requested_reboot) {
+            if (!dedup.empty()) {
+                reboot_for_remount(fd.get(), !dedup.empty());
+                return;
+            }
+            WriteFdExactly(fd.get(), "No reboot needed, skipping -R.\n");
+        }
     }
 
     bool success = true;
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index 160e076..a849578 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -366,7 +366,7 @@
 fi
 D=`adb_sh df -k </dev/null` &&
   H=`echo "${D}" | head -1` &&
-  D=`echo "${D}" | grep "^overlay "` &&
+  D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` &&
   echo "${H}" &&
   echo "${D}" &&
   echo "${ORANGE}[  WARNING ]${NORMAL} overlays present before setup" >&2 ||
@@ -410,7 +410,7 @@
   fi
   D=`adb_sh df -k </dev/null` &&
     H=`echo "${D}" | head -1` &&
-    D=`echo "${D}" | grep "^overlay " || true` &&
+    D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay " || true` &&
     [ -z "${D}" ] ||
     ( echo "${H}" && echo "${D}" && false ) ||
     die -t ${T} "overlay takeover unexpected at this phase"
@@ -443,7 +443,7 @@
   echo "${H}"
   D=`adb_sh df -k </dev/null` &&
     H=`echo "${D}" | head -1` &&
-    D=`echo "${D}" | grep "^overlay " || true` &&
+    D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay " || true` &&
     [ -z "${D}" ] ||
     ( echo "${H}" && echo "${D}" && false ) ||
     ( [ -n "${L}" ] && echo "${L}" && false ) ||
@@ -463,7 +463,7 @@
   die -t "${T}" "adb remount failed"
 D=`adb_sh df -k </dev/null` &&
   H=`echo "${D}" | head -1` &&
-  D=`echo "${D}" | grep "^overlay "` ||
+  D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` ||
   ( [ -n "${L}" ] && echo "${L}" && false )
 ret=${?}
 uses_dynamic_scratch=false
@@ -506,7 +506,7 @@
     echo "${D}" &&
     echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
     die  "overlay takeover after remount"
-  !(adb_sh grep "^overlay " /proc/mounts </dev/null | grep " overlay ro,") &&
+  !(adb_sh grep "^overlay " /proc/mounts </dev/null | grep -v "^overlay /vendor/..* overlay ro," | grep " overlay ro,") &&
     !(adb_sh grep " rw," /proc/mounts </dev/null |
       skip_administrative_mounts data) ||
     die "remount overlayfs missed a spot (ro)"
@@ -539,7 +539,7 @@
 if ${overlayfs_needed}; then
   D=`adb_su df -k </dev/null` &&
     H=`echo "${D}" | head -1` &&
-    D=`echo "${D}" | grep "^overlay "` ||
+    D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` ||
     ( echo "${L}" && false ) ||
     die -d "overlay takeover failed after reboot"
 
@@ -621,7 +621,7 @@
     adb_root &&
       D=`adb_sh df -k </dev/null` &&
       H=`echo "${D}" | head -1` &&
-      D=`echo "${D}" | grep "^overlay "` &&
+      D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` &&
       echo "${H}" &&
       echo "${D}" &&
       echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
diff --git a/init/Android.bp b/init/Android.bp
index e7b8516..c920dc2 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -85,6 +85,7 @@
         "libselinux",
         "libutils",
     ],
+    bootstrap: true,
 }
 
 cc_library_static {
diff --git a/init/main.cpp b/init/main.cpp
index 868c409..2ce46ef 100644
--- a/init/main.cpp
+++ b/init/main.cpp
@@ -57,27 +57,22 @@
         return ueventd_main(argc, argv);
     }
 
-    if (argc < 2) {
-        return FirstStageMain(argc, argv);
+    if (argc > 1) {
+        if (!strcmp(argv[1], "subcontext")) {
+            android::base::InitLogging(argv, &android::base::KernelLogger);
+            const BuiltinFunctionMap function_map;
+
+            return SubcontextMain(argc, argv, &function_map);
+        }
+
+        if (!strcmp(argv[1], "selinux_setup")) {
+            return SetupSelinux(argv);
+        }
+
+        if (!strcmp(argv[1], "second_stage")) {
+            return SecondStageMain(argc, argv);
+        }
     }
 
-    if (!strcmp(argv[1], "subcontext")) {
-        android::base::InitLogging(argv, &android::base::KernelLogger);
-        const BuiltinFunctionMap function_map;
-
-        return SubcontextMain(argc, argv, &function_map);
-    }
-
-    if (!strcmp(argv[1], "selinux_setup")) {
-        return SetupSelinux(argv);
-    }
-
-    if (!strcmp(argv[1], "second_stage")) {
-        return SecondStageMain(argc, argv);
-    }
-
-    android::base::InitLogging(argv, &android::base::KernelLogger);
-
-    LOG(ERROR) << "Unknown argument passed to init '" << argv[1] << "'";
-    return 1;
+    return FirstStageMain(argc, argv);
 }
diff --git a/init/selinux.cpp b/init/selinux.cpp
index 04ca207..e4da52c 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -432,24 +432,6 @@
     selinux_android_restorecon("/dev/urandom", 0);
     selinux_android_restorecon("/dev/__properties__", 0);
 
-    selinux_android_restorecon("/plat_file_contexts", 0);
-    selinux_android_restorecon("/nonplat_file_contexts", 0);
-    selinux_android_restorecon("/vendor_file_contexts", 0);
-    selinux_android_restorecon("/plat_property_contexts", 0);
-    selinux_android_restorecon("/nonplat_property_contexts", 0);
-    selinux_android_restorecon("/vendor_property_contexts", 0);
-    selinux_android_restorecon("/plat_seapp_contexts", 0);
-    selinux_android_restorecon("/nonplat_seapp_contexts", 0);
-    selinux_android_restorecon("/vendor_seapp_contexts", 0);
-    selinux_android_restorecon("/plat_service_contexts", 0);
-    selinux_android_restorecon("/nonplat_service_contexts", 0);
-    selinux_android_restorecon("/vendor_service_contexts", 0);
-    selinux_android_restorecon("/plat_hwservice_contexts", 0);
-    selinux_android_restorecon("/nonplat_hwservice_contexts", 0);
-    selinux_android_restorecon("/vendor_hwservice_contexts", 0);
-    selinux_android_restorecon("/sepolicy", 0);
-    selinux_android_restorecon("/vndservice_contexts", 0);
-
     selinux_android_restorecon("/dev/block", SELINUX_ANDROID_RESTORECON_RECURSE);
     selinux_android_restorecon("/dev/device-mapper", 0);
 
diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h
index 58b9f09..79b4b35 100644
--- a/libcutils/include/cutils/trace.h
+++ b/libcutils/include/cutils/trace.h
@@ -75,7 +75,8 @@
 #define ATRACE_TAG_VIBRATOR         (1<<23)
 #define ATRACE_TAG_AIDL             (1<<24)
 #define ATRACE_TAG_NNAPI            (1<<25)
-#define ATRACE_TAG_LAST             ATRACE_TAG_NNAPI
+#define ATRACE_TAG_RRO              (1<<26)
+#define ATRACE_TAG_LAST             ATRACE_TAG_RRO
 
 // Reserved for initialization.
 #define ATRACE_TAG_NOT_READY        (1ULL<<63)
diff --git a/liblog/.clang-format b/liblog/.clang-format
deleted file mode 100644
index 9db87a8..0000000
--- a/liblog/.clang-format
+++ /dev/null
@@ -1,9 +0,0 @@
-BasedOnStyle: Google
-AllowShortFunctionsOnASingleLine: false
-
-CommentPragmas: NOLINT:.*
-DerivePointerAlignment: false
-PointerAlignment: Left
-PenaltyExcessCharacter: 32
-
-Cpp11BracedListStyle: false
diff --git a/liblog/.clang-format b/liblog/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/liblog/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/liblog/README b/liblog/README
deleted file mode 100644
index 5a845be..0000000
--- a/liblog/README
+++ /dev/null
@@ -1,209 +0,0 @@
-LIBLOG(3)          Android Internal NDK Programming Manual           LIBLOG(3)
-
-
-
-NAME
-       liblog - Android Internal NDK logger interfaces
-
-SYNOPSIS
-       /*
-        * Please limit to 24 characters for runtime is loggable,
-        * 16 characters for persist is loggable, and logcat pretty
-        * alignment with limit of 7 characters.
-        */
-       #define LOG_TAG "yourtag"
-       #include <log/log.h>
-
-       ALOG(android_priority, tag, format, ...)
-       IF_ALOG(android_priority, tag)
-       LOG_PRI(priority, tag, format, ...)
-       LOG_PRI_VA(priority, tag, format, args)
-       #define LOG_TAG NULL
-       ALOGV(format, ...)
-       SLOGV(format, ...)
-       RLOGV(format, ...)
-       ALOGV_IF(cond, format, ...)
-       SLOGV_IF(cond, format, ...)
-       RLOGV_IF(cond, format, ...)
-       IF_ALOGC()
-       ALOGD(format, ...)
-       SLOGD(format, ...)
-       RLOGD(format, ...)
-       ALOGD_IF(cond, format, ...)
-       SLOGD_IF(cond, format, ...)
-       RLOGD_IF(cond, format, ...)
-       IF_ALOGD()
-       ALOGI(format, ...)
-       SLOGI(format, ...)
-       RLOGI(format, ...)
-       ALOGI_IF(cond, format, ...)
-       SLOGI_IF(cond, format, ...)
-       RLOGI_IF(cond, format, ...)
-       IF_ALOGI()
-       ALOGW(format, ...)
-       SLOGW(format, ...)
-       RLOGW(format, ...)
-       ALOGW_IF(cond, format, ...)
-       SLOGW_IF(cond, format, ...)
-       RLOGW_IF(cond, format, ...)
-       IF_ALOGW()
-       ALOGE(format, ...)
-       SLOGE(format, ...)
-       RLOGE(format, ...)
-       ALOGE_IF(cond, format, ...)
-       SLOGE_IF(cond, format, ...)
-       RLOGE_IF(cond, format, ...)
-       IF_ALOGE()
-       LOG_FATAL(format, ...)
-       LOG_ALWAYS_FATAL(format, ...)
-       LOG_FATAL_IF(cond, format, ...)
-       LOG_ALWAYS_FATAL_IF(cond, format, ...)
-       ALOG_ASSERT(cond, format, ...)
-       LOG_EVENT_INT(tag, value)
-       LOG_EVENT_LONG(tag, value)
-
-       clockid_t android_log_clockid()
-
-       log_id_t android_logger_get_id(struct logger *logger)
-       int android_logger_clear(struct logger *logger)
-       int android_logger_get_log_size(struct logger *logger)
-       int android_logger_get_log_readable_size(struct logger *logger)
-       int android_logger_get_log_version(struct logger *logger)
-
-       struct logger_list *android_logger_list_alloc(int mode,
-                                                     unsigned int tail,
-                                                     pid_t pid)
-       struct logger *android_logger_open(struct logger_list *logger_list,
-                                          log_id_t id)
-       struct logger_list *android_logger_list_open(log_id_t id, int mode,
-                                                    unsigned int tail,
-                                                    pid_t pid)
-       int android_logger_list_read(struct logger_list *logger_list,
-                                    struct log_msg *log_msg)
-       void android_logger_list_free(struct logger_list *logger_list)
-
-       log_id_t android_name_to_log_id(const char *logName)
-       const char *android_log_id_to_name(log_id_t log_id)
-
-       android_log_context create_android_logger(uint32_t tag)
-
-       int android_log_write_list_begin(android_log_context ctx)
-       int android_log_write_list_end(android_log_context ctx)
-
-       int android_log_write_int32(android_log_context ctx, int32_t value)
-       int android_log_write_int64(android_log_context ctx, int64_t value)
-       int android_log_write_string8(android_log_context ctx,
-                                     const char *value)
-       int android_log_write_string8_len(android_log_context ctx,
-                                         const char *value, size_t maxlen)
-       int android_log_write_float32(android_log_context ctx, float value)
-
-       int android_log_write_list(android_log_context ctx,
-                                  log_id_t id = LOG_ID_EVENTS)
-
-       android_log_context create_android_log_parser(const char *msg,
-                                                     size_t len)
-       android_log_list_element android_log_read_next(android_log_context ctx)
-       android_log_list_element android_log_peek_next(android_log_context ctx)
-
-       int android_log_destroy(android_log_context *ctx)
-
-       #include <log/log_transport.h>
-
-       int android_set_log_transport(int transport_flag)
-       int android_get_log_transport()
-
-       Link with -llog
-
-DESCRIPTION
-       liblog  represents  an interface to the volatile Android Logging system
-       for NDK (Native) applications  and  libraries.  Interfaces  for  either
-       writing  or reading logs.  The log buffers are divided up in Main, Sys‐
-       tem, Radio and Events sub-logs.
-
-       The logging interfaces are a series of macros,  all  of  which  can  be
-       overridden individually in order to control the verbosity of the appli‐
-       cation or library.  [ASR]LOG[VDIWE] calls are used  to  log  to  BAsic,
-       System or Radio sub-logs in either the Verbose, Debug, Info, Warning or
-       Error priorities.  [ASR]LOG[VDIWE]_IF calls are used  to  perform  thus
-       based  on a condition being true.  IF_ALOG[VDIWE] calls are true if the
-       current LOG_TAG is enabled at the specified priority.  LOG_ALWAYS_FATAL
-       is  used to ALOG a message, then kill the process.  LOG_FATAL call is a
-       variant of LOG_ALWAYS_FATAL,  only  enabled  in  engineering,  and  not
-       release builds.  ALOG_ASSERT is used to ALOG a message if the condition
-       is  false;   the   condition   is   part   of   the   logged   message.
-       LOG_EVENT_(INT|LONG)  is  used  to  drop binary content into the Events
-       sub-log.
-
-       The log reading interfaces permit opening the  logs  either  singly  or
-       multiply,  retrieving  a  log  entry  at  a  time in time sorted order,
-       optionally limited to a specific pid and tail of the log(s) and finally
-       a  call closing the logs.  A single log can be opened with android_log‐
-       ger_list_open;  or  multiple  logs  can  be  opened  with  android_log‐
-       ger_list_alloc,  calling  in  turn the android_logger_open for each log
-       id.  Each entry can be retrieved  with  android_logger_list_read.   The
-       log(s) can be closed with android_logger_list_free.  The logs should be
-       opened  with an  ANDROID_LOG_RDONLY  mode.   ANDROID_LOG_NONBLOCK  mode
-       will report when the  log reading is done with an  EAGAIN  error return
-       code,  otherwise the  android_logger_list_read  call will block for new
-       entries.
-
-       The  ANDROID_LOG_WRAP  mode flag to the  android_logger_list_alloc_time
-       signals  logd to quiesce  the reader until the buffer is about to prune
-       at the start time then proceed to dumping content.
-
-       The  ANDROID_LOG_PSTORE mode flag to the android_logger_open is used to
-       switch from the active logs to the persistent logs from before the last
-       reboot.
-
-       The value returned by android_logger_open can be used as a parameter to
-       the  android_logger_clear  function to empty the sub-log.  It is recom‐
-       mended to only open log ANDROID_LOG_WRONLY in that case.
-
-       The value returned by android_logger_open can be used as a parameter to
-       the android_logger_get_log_(size|readable_size|version) to retrieve the
-       sub-log maximum size, readable size and log buffer format protocol ver‐
-       sion  respectively.  android_logger_get_id returns the id that was used
-       when  opening  the  sub-log.    It  is  recommended  to  open  the  log
-       ANDROID_LOG_RDONLY in these cases.
-
-       android_set_log_transport()  selects  transport  filters.  Argument  is
-       either LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to
-       logger daemon for default or logd, drop contents on floor,  or log into
-       local   memory   respectively.       Both   android_set_log_transport()
-       and android_get_log_transport() return the current  transport mask,  or
-       a negative errno for any problems.
-
-ERRORS
-       If messages fail, a negative error code will be returned to the caller.
-
-       The -ENOTCONN return code indicates that the logger daemon is stopped.
-
-       The  -EBADF return code indicates that the log access point can not be
-       opened, or the log buffer id is out of range.
-
-       For the  -EAGAIN  return code,  this means that the logging message was
-       temporarily backed-up either because of Denial Of Service (DOS) logging
-       pressure from some chatty application or service in the Android system,
-       or if too small of a value is set in /proc/sys/net/unix/max_dgram_qlen.
-       To aid in diagnosing the occurence of this,  a binary event from liblog
-       will be sent to the  log  daemon  once a  new  message  can get through
-       indicating how many  messages were  dropped  as a result.   Please take
-       action to resolve the structural problems at the source.
-
-       It is generally not advised for the caller to retry the  -EAGAIN return
-       code as  this  will  only  make the  problem(s)  worse  and  cause your
-       application to temporarily drop to the  logger daemon  priority,  BATCH
-       scheduling policy and background task cgroup. If you require a group of
-       messages to be passed atomically,  merge  them  into  one  message with
-       embedded newlines to the maximum length LOGGER_ENTRY_MAX_PAYLOAD.
-
-       Other return codes  from  writing operation can be returned.  Since the
-       library retries on EINTR, -EINTR should never be returned.
-
-SEE ALSO
-       syslogd(8), klogd, auditd(8)
-
-
-
-                                  08 Feb 2017                        LIBLOG(3)
diff --git a/liblog/README.md b/liblog/README.md
new file mode 100644
index 0000000..886fe25
--- /dev/null
+++ b/liblog/README.md
@@ -0,0 +1,177 @@
+Android liblog
+--------------
+
+Public Functions and Macros
+---------------------------
+
+    /*
+     * Please limit to 24 characters for runtime is loggable,
+     * 16 characters for persist is loggable, and logcat pretty
+     * alignment with limit of 7 characters.
+    */
+    #define LOG_TAG "yourtag"
+    #include <log/log.h>
+
+    ALOG(android_priority, tag, format, ...)
+    IF_ALOG(android_priority, tag)
+    LOG_PRI(priority, tag, format, ...)
+    LOG_PRI_VA(priority, tag, format, args)
+    #define LOG_TAG NULL
+    ALOGV(format, ...)
+    SLOGV(format, ...)
+    RLOGV(format, ...)
+    ALOGV_IF(cond, format, ...)
+    SLOGV_IF(cond, format, ...)
+    RLOGV_IF(cond, format, ...)
+    IF_ALOGC()
+    ALOGD(format, ...)
+    SLOGD(format, ...)
+    RLOGD(format, ...)
+    ALOGD_IF(cond, format, ...)
+    SLOGD_IF(cond, format, ...)
+    RLOGD_IF(cond, format, ...)
+    IF_ALOGD()
+    ALOGI(format, ...)
+    SLOGI(format, ...)
+    RLOGI(format, ...)
+    ALOGI_IF(cond, format, ...)
+    SLOGI_IF(cond, format, ...)
+    RLOGI_IF(cond, format, ...)
+    IF_ALOGI()
+    ALOGW(format, ...)
+    SLOGW(format, ...)
+    RLOGW(format, ...)
+    ALOGW_IF(cond, format, ...)
+    SLOGW_IF(cond, format, ...)
+    RLOGW_IF(cond, format, ...)
+    IF_ALOGW()
+    ALOGE(format, ...)
+    SLOGE(format, ...)
+    RLOGE(format, ...)
+    ALOGE_IF(cond, format, ...)
+    SLOGE_IF(cond, format, ...)
+    RLOGE_IF(cond, format, ...)
+    IF_ALOGE()
+    LOG_FATAL(format, ...)
+    LOG_ALWAYS_FATAL(format, ...)
+    LOG_FATAL_IF(cond, format, ...)
+    LOG_ALWAYS_FATAL_IF(cond, format, ...)
+    ALOG_ASSERT(cond, format, ...)
+    LOG_EVENT_INT(tag, value)
+    LOG_EVENT_LONG(tag, value)
+
+    clockid_t android_log_clockid()
+
+    log_id_t android_logger_get_id(struct logger *logger)
+    int android_logger_clear(struct logger *logger)
+    int android_logger_get_log_size(struct logger *logger)
+    int android_logger_get_log_readable_size(struct logger *logger)
+    int android_logger_get_log_version(struct logger *logger)
+
+    struct logger_list *android_logger_list_alloc(int mode, unsigned int tail, pid_t pid)
+    struct logger *android_logger_open(struct logger_list *logger_list, log_id_t id)
+    struct logger_list *android_logger_list_open(log_id_t id, int mode, unsigned int tail, pid_t pid)
+    int android_logger_list_read(struct logger_list *logger_list, struct log_msg *log_msg)
+    void android_logger_list_free(struct logger_list *logger_list)
+
+    log_id_t android_name_to_log_id(const char *logName)
+    const char *android_log_id_to_name(log_id_t log_id)
+
+    android_log_context create_android_logger(uint32_t tag)
+
+    int android_log_write_list_begin(android_log_context ctx)
+    int android_log_write_list_end(android_log_context ctx)
+
+    int android_log_write_int32(android_log_context ctx, int32_t value)
+    int android_log_write_int64(android_log_context ctx, int64_t value)
+    int android_log_write_string8(android_log_context ctx, const char *value)
+    int android_log_write_string8_len(android_log_context ctx, const char *value, size_t maxlen)
+    int android_log_write_float32(android_log_context ctx, float value)
+
+    int android_log_write_list(android_log_context ctx, log_id_t id = LOG_ID_EVENTS)
+
+    android_log_context create_android_log_parser(const char *msg, size_t len)
+    android_log_list_element android_log_read_next(android_log_context ctx)
+    android_log_list_element android_log_peek_next(android_log_context ctx)
+
+    int android_log_destroy(android_log_context *ctx)
+
+    #include <log/log_transport.h>
+
+    int android_set_log_transport(int transport_flag)
+    int android_get_log_transport()
+
+Description
+-----------
+
+liblog represents an interface to the volatile Android Logging system for NDK (Native) applications
+and libraries.  Interfaces for either writing or reading logs.  The log buffers are divided up in
+Main, System, Radio and Events sub-logs.
+
+The logging interfaces are a series of macros, all of which can be overridden individually in order
+to control the verbosity of the application or library.  `[ASR]LOG[VDIWE]` calls are used to log to
+BAsic, System or Radio sub-logs in either the Verbose, Debug, Info, Warning or Error priorities.
+`[ASR]LOG[VDIWE]_IF` calls are used to perform thus based on a condition being true.
+`IF_ALOG[VDIWE]` calls are true if the current `LOG_TAG` is enabled at the specified priority.
+`LOG_ALWAYS_FATAL` is used to `ALOG` a message, then kill the process.  `LOG_FATAL` call is a
+variant of `LOG_ALWAYS_FATAL`, only enabled in engineering, and not release builds.  `ALOG_ASSERT`
+is used to `ALOG` a message if the condition is false; the condition is part of the logged message.
+`LOG_EVENT_(INT|LONG)` is used to drop binary content into the Events sub-log.
+
+The log reading interfaces permit opening the logs either singly or multiply, retrieving a log entry
+at a time in time sorted order, optionally limited to a specific pid and tail of the log(s) and
+finally a call closing the logs.  A single log can be opened with `android_logger_list_open()`; or
+multiple logs can be opened with `android_logger_list_alloc()`, calling in turn the
+`android_logger_open()` for each log id.  Each entry can be retrieved with
+`android_logger_list_read()`.  The log(s) can be closed with `android_logger_list_free()`.  The logs
+should be opened with an `ANDROID_LOG_RDONLY` mode.  `ANDROID_LOG_NONBLOCK` mode will report when
+the log reading is done with an `EAGAIN` error return code, otherwise the
+`android_logger_list_read()` call will block for new entries.
+
+The `ANDROID_LOG_WRAP` mode flag to the `android_logger_list_alloc_time()` signals logd to quiesce
+the reader until the buffer is about to prune at the start time then proceed to dumping content.
+
+The `ANDROID_LOG_PSTORE` mode flag to the `android_logger_open()` is used to switch from the active
+logs to the persistent logs from before the last reboot.
+
+The value returned by `android_logger_open()` can be used as a parameter to the
+`android_logger_clear()` function to empty the sub-log.  It is recommended to only open log
+`ANDROID_LOG_WRONLY` in that case.
+
+The value returned by `android_logger_open()` can be used as a parameter to the
+`android_logger_get_log_(size|readable_size|version)` to retrieve the sub-log maximum size, readable
+size and log buffer format protocol version respectively.  `android_logger_get_id()` returns the id
+that was used when opening the sub-log.  It is recommended to open the log `ANDROID_LOG_RDONLY` in
+these cases.
+
+`android_set_log_transport()` selects transport filters.  Argument is either `LOGGER_DEFAULT`,
+`LOGGER_LOGD`, `LOGGER_NULL` or `LOGGER_LOCAL`. Log to logger daemon for default or logd, drop
+contents on floor, or log into local memory respectively.  `Both android_set_log_transport()` and
+`android_get_log_transport()` return the current transport mask, or a negative errno for any
+problems.
+
+Errors
+------
+
+If messages fail, a negative error code will be returned to the caller.
+
+The `-ENOTCONN` return code indicates that the logger daemon is stopped.
+
+The `-EBADF` return code indicates that the log access point can not be opened, or the log buffer id
+is out of range.
+
+For the `-EAGAIN` return code, this means that the logging message was temporarily backed-up either
+because of Denial Of Service (DOS) logging pressure from some chatty application or service in the
+Android system, or if too small of a value is set in /proc/sys/net/unix/max_dgram_qlen.  To aid in
+diagnosing the occurence of this, a binary event from liblog will be sent to the log daemon once a
+new message can get through indicating how many messages were dropped as a result.  Please take
+action to resolve the structural problems at the source.
+
+It is generally not advised for the caller to retry the `-EAGAIN` return code as this will only make
+the problem(s) worse and cause your application to temporarily drop to the logger daemon priority,
+BATCH scheduling policy and background task cgroup. If you require a group of messages to be passed
+atomically, merge them into one message with embedded newlines to the maximum length
+`LOGGER_ENTRY_MAX_PAYLOAD`.
+
+Other return codes from writing operation can be returned.  Since the library retries on `EINTR`,
+`-EINTR` should never be returned.