1. 13 Jul, 2015 1 commit
    • Arman Uguray's avatar
      gn-build: Add BUILD files for libchrome · 0ca99052
      Arman Uguray authored
      This CL adds GN build files for libchrome, which is the ChromeOS/Brillo library
      for many C++ tools, include libbase. I added a new GN build target for "base"
      under secondary sources with a GN build file for libchrome which currently lives
      in platform/external/libchrome in AOSP.
      
      To build, clone libchrome into third_party/libchrome and remove
      third_party/libchrome/base/BUILD.gn. Also clone external/modp_b64 into
      third_party/modp_b64. Eventually I will have scripts set up to do
      this automatically.
      
      This means that we can start developing against libbase while running GN builds
      on Goobuntu but this would break the tree until libchrome is buildable within
      the Android build system (http://r.android.com/158392). So Brillo/Android builds
      will depend on libchrome using the conventional Android.mk means.
      
      Bug: 22175181
      Change-Id: I9a737aa785488e5bc0ca1adc087d1d5dfcdf3bea
      0ca99052
  2. 06 Jul, 2015 1 commit
    • Marie Janssen's avatar
      build: Update osi log functions, use consistently · db554581
      Marie Janssen authored
      Update the LOG_* functions to take a tag argument which makes them more
      consistent with the Android Log.*(TAG, s) common syntax and removes
      some #define-dependency with osi/include/log.h.
      
      Also update to never use Android log functions directly.
      
      Also contains minor cleanup of some header includes.
      
      Bug: 21569831
      Change-Id: If07385cafbea062232ecdbc7c673f908d5ef8921
      db554581
  3. 24 Jun, 2015 1 commit
    • Miao Chou's avatar
      build: Eliminate cutils/sockets dependencies from system/bt · 10969128
      Miao Chou authored
      Eliminate cutils/sockets dependencies by pulling sources files from
      core/libcutils into osi/.
         - Pulled source files from cutils/ into osi/ and modified GN files and
           Android.mk
         - Updated includes to use the headers in osi/ and removed unused/duplicated
           headers.
         - Renamed the functions of osi/sockets and updated wherever they are called
           to avoid usign symbols from cutils/sockets, since other cutils
           dependencies have not been eliminated yet.
      
      Bug: 21667795
      Change-Id: I3dd4371d585f120d97ac0433ab1f35edb820dbb9
      10969128
  4. 15 Jun, 2015 1 commit
    • Sharvil Nanavati's avatar
      Reduce CPU utilization from ~60% to ~10% on busy HCI reads. · 08019f3e
      Sharvil Nanavati authored
      This patch improves RFCOMM throughput and reduces CPU utilization.
      Instead of using a counting semaphore to measure bytes and reading
      one at a time from the eager reader's buffer, read in bulk based
      on the incoming read request size.
      
      Change-Id: I17046bfbc3ca49576a9c82b38911aeb84234881a
      08019f3e
  5. 12 Jun, 2015 1 commit
  6. 11 Jun, 2015 1 commit
  7. 10 Jun, 2015 3 commits
    • Pavlin Radoslavov's avatar
      Moved the OSI alarm_shutdown() operations to alarm_cleanup() · 0933b407
      Pavlin Radoslavov authored
      Also, removed the OSI module's start_up and shut_down steps,
      because now they are no-op.
      
      Bug: 21558791
      Change-Id: I24259b327f399af57c37937111158baa9704f644
      0933b407
    • Pavlin Radoslavov's avatar
      Disable the OSI allocation tracker. · 5febd64b
      Pavlin Radoslavov authored
      Temporary disable the allocation tracker initialization
      (even for BLUEDROID_DEBUG) when initializing Bluetooth.
      This is a short-term workaround solution for several issues related to
      the usage of the allocation tracker.
      
      * Inconsistent usage of osi_malloc()/osi_calloc() and osi_free()
        - Within some of the Bluetooth-related unit tests we have two copies
          of the same libosi library: one copy statically linked against the
          unit test, and another dlopen() at runtime as part of bluetooth.default.so
          Each of those copy has its own static variables.
        - For the dlopen() copy we do call allocation_tracker_init(), while for the
          static copy within the unit test we don't call allocation_tracker_init()
        - Occasionally, there is a  memory allocation via osi_calloc()
          within the dlopen()-ed library, and then it is osi_free()-ed
          within the statically linked library.
       Such (mis)usage creates issues in two ways: (1) free()-ing incorrect
       pointer, and (2) the osi hash_map() in the dlopen()-ed library still considers
       the osi-tracked memory as allocated.
       NOTE: (1) could trigger random crashes, while (2) is the reason the unit
       test triggers an assert
      
      * Avoid potential issues that could result from the fact that calling
        allocation_tracker_init() is not mandatory; i.e., the same
        issue described above could be triggered if osi_malloc()/osi_callod()
        was called before the call to allocation_tracker_init()
      
      * There is still code that uses malloc(3)/calloc(3) and free(3) instead
        of osi_malloc()/osi_calloc() and osi_free()
      
      Also, add missing pthread_mutex_lock()/pthread_mutex_unlock() guards,
      and fix the allocation_tracker_uninit() implementation so it works
      properly even if void allocation_tracker_init() wasn't called.
      
      Bug: 21561735
      Change-Id: Ic83d6cd40af1189c4ee9c1dbfd0ad8e4666e1502
      5febd64b
    • Pavlin Radoslavov's avatar
      Add missing clean_up step for the OSI module. · 7dac79e3
      Pavlin Radoslavov authored
      Now the OSI module's shut_down processing is split into "shut_down"
      and "clean_up".
      
      Previously, there was an ordering issue manipulating some of the
      internal state during graceful shutdown/cleanup. Some of the modules
      had two steps: shut_down, followed by clean_up, while other had only
      shut_down step. This triggered the following assert in file alarm.c
      
          alarm_cancel: assertion "alarms != NULL" failed
      
      Bug: 21406940
      Change-Id: Iab1f033a69cbff646a6b0f346760ae82f8b00b8f
      7dac79e3
  8. 08 Jun, 2015 4 commits
  9. 01 Jun, 2015 1 commit
    • Arman Uguray's avatar
      gn-build: Clean up GN files · 2c494e15
      Arman Uguray authored
      Removed unnecessary library and include flags from build files. To make the
      initial build outputs more similar to Android, this CL changes the usage of the
      GN "source_set" idiom to "static_library". This comes at a performance loss
      while keeping the builds similar until we get the whole stack to compile.
      
      BUG=21339022
      
      Change-Id: I46f70b3b64b2537634a1dbb517a5168566230efb
      2c494e15
  10. 29 May, 2015 1 commit
    • Arman Uguray's avatar
      gn-build: Add tinyxml2 as a secondary source · bbb12526
      Arman Uguray authored
      Added tinyxml2 as a secondary source. Moved //build/secondary/testing to
      //build/secondary/third_party in the process. This means that all third_party
      sources (gtest, tinyxml2) should be placed in a top-level third_party directory.
      
      BUG=21339022
      
      Change-Id: If324ef1eb0d5061e005f62a80d23fef25e7e78a4
      bbb12526
  11. 28 May, 2015 1 commit
  12. 26 May, 2015 2 commits
    • Arman Uguray's avatar
      build: Build net_test_osi using GN + ninja · bb6836b8
      Arman Uguray authored
      This CL adds support to build the net_test_osi target using GN + ninja.
      The BUILD.gn file now pulls in gtest as a dependency. Missing libc
      includes have been added to sources that prevented compilation on
      Goobuntu (14.04).
      
      The osi/include/log.h header has been modified to conditionally call the
      Android log utilities vs plain-old printf on non-Android builds.
      
      BUG=21339022
      
      Change-Id: If3c356360c56c63b3bf551b41dc8d3269d8e7e09
      bb6836b8
    • Arman Uguray's avatar
      build: Add missing copyright headers to new GN build files · 9ca3fb82
      Arman Uguray authored
      BUG=21339022
      
      Change-Id: I946fad7bf8116054f9081e064748793e79a6f85a
      9ca3fb82
  13. 12 May, 2015 1 commit
  14. 07 May, 2015 1 commit
    • Chih-Hung Hsieh's avatar
      Work around clang/llvm compilation problems. · 4b04b8d4
      Chih-Hung Hsieh authored
      These patches will allow us to compile the whole AOSP with clang/llvm
      before all the following problems are fixed.
      * Suppress warnings on unused variables.
        * Remove unused static variables.
      * Use only gcc to compile code that requires gcc atomic functions.
        They should be converted to standard atomic functions later.
      * Suppress warnings on redefined typedefs.
      
      BUG: 20765701
      Change-Id: Ib1d6e2ef86c255ba87c1d51f9fdeabe5c8de2ada
      (cherry picked from commit 23546918)
      4b04b8d4
  15. 16 Apr, 2015 1 commit
    • Mark Salyzyn's avatar
      bluedroid: compile error hammerhead-userdebug_clang · a9962ce6
      Mark Salyzyn authored
      - This was a clang complaint, not a gcc complaint
      - memset event to be portable to all compile environments
      - error as follows:
      
      external/bluetooth/bluedroid/osi/./src/reactor.c:90:34:
          error: missing field data initializer [-Werror,-Wmissing-field-initializers]
        struct epoll_event event = { 0 };
                                       ^
      external/bluetooth/bluedroid/osi/./src/reactor.c:151:34:
          error: missing field data initializer [-Werror,-Wmissing-field-initializers]
        struct epoll_event event = { 0 };
                                       ^
      external/bluetooth/bluedroid/osi/./src/reactor.c:174:34:
          error: missing field data initializer [-Werror,-Wmissing-field-initializers]
        struct epoll_event event = { 0 };
                                       ^
      3 errors generated.
      make: *** [out/target/product/hammerhead/obj/STATIC_LIBRARIES/libosi_intermediates/./src/reactor.o] Error 1
      
      Change-Id: I14b884cf1665c68aff1e5afd3df65ac10af474d2
      a9962ce6
  16. 15 Apr, 2015 1 commit
  17. 07 Apr, 2015 1 commit
  18. 02 Apr, 2015 4 commits
    • Scott James Remnant's avatar
      osi: add compat code for glibc · 47d68ee6
      Scott James Remnant authored
      glibc doesn't declare strlcpy(), strlcat() or gettid(). Add a header
      of compatibility routines that only get included when compiling on this.
      
      Change-Id: I889ac7f1d22cf7056757890fcff0403107488d62
      47d68ee6
    • Scott James Remnant's avatar
      Make atomic functions static, as well as inline · 2a14bc08
      Scott James Remnant authored
      'inline' is only a hint for the compiler, and if ignored this results
      in extern functions being created. Add 'static' so that the resulting
      functions are also only local to the compilation unit.
      
      Change-Id: I947201b8170c8c73f15e7ccdd68cfc7f07cde1e9
      2a14bc08
    • Scott James Remnant's avatar
      Fix missing #includes needed for glibc · 933926c9
      Scott James Remnant authored
      Some standard library functions are used while relying on bionic headers
      including the headers the functions were actually declared on. Add those
      missing #includes so that bluetooth.default.so will compile on glibc.
      
      Change-Id: Ied9f89ce5a05911fca63f6bfe1b8cc8196ab3b1c
      933926c9
    • Nitin Arora's avatar
      Using generic format specifier for logging pointers · a74fcdfe
      Nitin Arora authored
      This change uses generic format specifier for logging the
      pointers which can be 64 bit or 32 bit depending upon the
      system used for compilation.
      Also address of operator is used before casting a int variable
      to void pointer.
      
      Change-Id: Ie9dec408f3a5f674079f77c047d8192f65a004ca
      a74fcdfe
  19. 01 Apr, 2015 1 commit
  20. 30 Mar, 2015 1 commit
    • Nitin Arora's avatar
      Using generic format specifier for logging pointers · 9742bf5b
      Nitin Arora authored
      This change uses generic format specifier for logging the
      pointers which can be 64 bit or 32 bit depending upon the
      system used for compilation.
      Also address of operator is used before casting a int variable
      to void pointer.
      
      Change-Id: Ie9dec408f3a5f674079f77c047d8192f65a004ca
      9742bf5b
  21. 27 Mar, 2015 3 commits
    • Zach Johnson's avatar
      Add option for schedule_next_instance to force rescheduling · b866b696
      Zach Johnson authored
      If we're rescheduling a periodic timer in the context of an alarm
      expiration we want to force rescheduling to happen.
      
      The alarm at the front of the list after scheduling the next
      instance may be a different alarm. The old code would assume it was
      already scheduled correctly, meaning nothing would ever get scheduled
      after that.
      
      Change-Id: I8accf5d004e69dfd6477ab7ec529eea42b3a88f8
      b866b696
    • Zach Johnson's avatar
      Ensure alarms are called back when they expire in the past · 4ae5e3ec
      Zach Johnson authored
      Turns out the posix timers we're dealing with aren't well behaved.
      
      If the timer is TIMER_ABSTIME the following is supposed to be true:
      "If the specified time has already passed, the function shall succeed
      and the expiration notification shall be made."
      
      But alas, this is not the case. If the expiration time happens to be
      in the past (e.g. very short timer which gets hit with a context switch
      before the timer can be set) the timer decides to disarm itself. This
      means no more callbacks happen, and no more alarms are processed ever.
      
      sadness.
      
      But thankfully, we can use timer_gettime to check the state of the timer
      after timer_settime. If timer_gettime tells us the timer is disarmed
      right after we armed it, we want to perform the alarm callback
      ourselves.
      
      Put all timer callbacks on the same thread (as would be the case in the
      underlying timer implementation already) and used a sempahore to signal
      when an alarm expires in the normal posix timer callback and also in the
      timer didn't set case.
      
      Change-Id: I39854b241369b2da52afbaaba0c01d3167a47e32
      4ae5e3ec
    • Zach Johnson's avatar
      Rewrite alarms to use a single posix timer instance · a7bd03e0
      Zach Johnson authored
      This means we lose the ability to send the intended alarm
      as context with the posix timer, but this can be handled
      gracefully enough by making sure we actually have an
      expired alarm at the front of the list when the timer
      callback occurs.
      
      Change-Id: I909195b5c3155075096328c529655eeb5b7d80d0
      a7bd03e0
  22. 26 Mar, 2015 3 commits
    • Zach Johnson's avatar
      Add option for schedule_next_instance to force rescheduling · 952d180f
      Zach Johnson authored
      If we're rescheduling a periodic timer in the context of an alarm
      expiration we want to force rescheduling to happen.
      
      The alarm at the front of the list after scheduling the next
      instance may be a different alarm. The old code would assume it was
      already scheduled correctly, meaning nothing would ever get scheduled
      after that.
      
      Change-Id: I8accf5d004e69dfd6477ab7ec529eea42b3a88f8
      952d180f
    • Zach Johnson's avatar
      Ensure alarms are called back when they expire in the past · 081e4b67
      Zach Johnson authored
      Turns out the posix timers we're dealing with aren't well behaved.
      
      If the timer is TIMER_ABSTIME the following is supposed to be true:
      "If the specified time has already passed, the function shall succeed
      and the expiration notification shall be made."
      
      But alas, this is not the case. If the expiration time happens to be
      in the past (e.g. very short timer which gets hit with a context switch
      before the timer can be set) the timer decides to disarm itself. This
      means no more callbacks happen, and no more alarms are processed ever.
      
      sadness.
      
      But thankfully, we can use timer_gettime to check the state of the timer
      after timer_settime. If timer_gettime tells us the timer is disarmed
      right after we armed it, we want to perform the alarm callback
      ourselves.
      
      Put all timer callbacks on the same thread (as would be the case in the
      underlying timer implementation already) and used a sempahore to signal
      when an alarm expires in the normal posix timer callback and also in the
      timer didn't set case.
      
      Change-Id: I39854b241369b2da52afbaaba0c01d3167a47e32
      081e4b67
    • Zach Johnson's avatar
      Rewrite alarms to use a single posix timer instance · 518a94e7
      Zach Johnson authored
      This means we lose the ability to send the intended alarm
      as context with the posix timer, but this can be handled
      gracefully enough by making sure we actually have an
      expired alarm at the front of the list when the timer
      callback occurs.
      
      Change-Id: I909195b5c3155075096328c529655eeb5b7d80d0
      518a94e7
  23. 24 Mar, 2015 1 commit
  24. 16 Mar, 2015 4 commits
    • Chris Manton's avatar
      Demote, cleanup and extend observed logging · f8027005
      Chris Manton authored
      f8027005
    • Sharvil Nanavati's avatar
      0f9b91e1
    • Sharvil Nanavati's avatar
      Atomically update config files. · 8772a378
      Sharvil Nanavati authored
      There's a race condition on shutdown between Java and native code.
      A stack shutdown is issued from Java and in the meantime the
      calling thread calls System.exit(0). If that line is reached before
      the native code has had a chance to shut down cleanly, the system
      could be stuck in a bad state.
      
      This change uses rename(2) to replace an existing config file
      atomically instead of truncating, writing, and then flushing. In
      case of a crash or the race condition above, the config file will
      still be valid.
      
      There's an implementation gotcha. The config saving code uses ".new"
      as a suffix on the original filename to write to a temporary file.
      If a file by that name already exists, it will be overwritten.
      8772a378
    • Zach Johnson's avatar
      Add ability to set periodic alarms · 71864f49
      Zach Johnson authored
      Adds alarm_set_periodic so the alarm code can have more
      contextual information when rescheduling alarms.
      
      Problem: A2DP would stream for a few seconds and then
      stop working.
      
      Cause: The Java garbage collector. Bluedroid reaches out
      to javaland to acquire and release the wake lock. Alarm was
      always reaching out to get the wake lock when it scheduled a
      short timeout. If GC kicked in during that call out to make
      sure we have the wake lock, it could take more than 100ms to
      get back us. That would screw over the alarm implementation
      particularly for small 20ms timers.
      
      So now if the wake lock was already acquired, we don't try to
      reacquire it.
      
      Cool. But we still have thrashing. Why? Because the alarm code
      doesn't know the alarm is actually being used in a periodic way.
      
      Here's what used to happen:
      
      alarm expires
      alarm is removed
      reschedule
      alarm callback is called
      alarm callback sets the alarm again
      alarm is added
      reschedule
      
      The problem is the first reschedule will get rid of the wake lock
      if the next alarm is too far out or doesn't exist, meaning the next
      reschedule needs to get the wake lock again.
      
      With the extra periodicity information we can eliminate the
      unnecessary intermediate reschedule, meaning no thrashing on the
      wake lock. yay!
      71864f49