Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 525b34d1 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

liblog: Speed up and extend the radio log redirect code

This code was supposed to be deprecated in time.  Let's make it more
efficient and add QC_RIL prefix to the list of catches to redirect
from the main logs to the radio logs.

Test: gTest liblog-unit-tests
Change-Id: I38b371b25da472ec77cbde4affeebf2eafcf6155
parent cf29755e
Loading
Loading
Loading
Loading
+40 −10
Original line number Diff line number Diff line
@@ -410,16 +410,46 @@ LIBLOG_ABI_PUBLIC int __android_log_buf_write(int bufID, int prio,
  if (!tag) tag = "";

  /* XXX: This needs to go! */
  if ((bufID != LOG_ID_RADIO) &&
      (!strcmp(tag, "HTC_RIL") ||
       !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */
       !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */
       !strcmp(tag, "AT") || !strcmp(tag, "GSM") || !strcmp(tag, "STK") ||
       !strcmp(tag, "CDMA") || !strcmp(tag, "PHONE") || !strcmp(tag, "SMS"))) {
  if (bufID != LOG_ID_RADIO) {
    switch (tag[0]) {
      case 'H':
        if (strcmp(tag + 1, "HTC_RIL" + 1)) break;
        goto inform;
      case 'R':
        /* Any log tag with "RIL" as the prefix */
        if (strncmp(tag + 1, "RIL" + 1, strlen("RIL") - 1)) break;
        goto inform;
      case 'Q':
        /* Any log tag with "QC_RIL" as the prefix */
        if (strncmp(tag + 1, "QC_RIL" + 1, strlen("QC_RIL") - 1)) break;
        goto inform;
      case 'I':
        /* Any log tag with "IMS" as the prefix */
        if (strncmp(tag + 1, "IMS" + 1, strlen("IMS") - 1)) break;
        goto inform;
      case 'A':
        if (strcmp(tag + 1, "AT" + 1)) break;
        goto inform;
      case 'G':
        if (strcmp(tag + 1, "GSM" + 1)) break;
        goto inform;
      case 'S':
        if (strcmp(tag + 1, "STK" + 1) && strcmp(tag + 1, "SMS" + 1)) break;
        goto inform;
      case 'C':
        if (strcmp(tag + 1, "CDMA" + 1)) break;
        goto inform;
      case 'P':
        if (strcmp(tag + 1, "PHONE" + 1)) break;
      /* FALLTHRU */
      inform:
        bufID = LOG_ID_RADIO;
    /* Inform third party apps/ril/radio.. to use Rlog or RLOG */
        snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag);
        tag = tmp_tag;
      /* FALLTHRU */
      default:
        break;
    }
  }

#if __BIONIC__