Reland: libmemtrack: Add support for AIDL memtrack HAL

________________

Regarding the issues caused by the reverted version of these changes.


Root cause of the reported issues is that ServiceManager cannot get
the IMemtrack AIDL service, and getService() will busy loop for 5 seconds
trying to get the service.

```
12-22 12:22:22.501  1827 10885 W ServiceManager: Service android.hardware.memtrack.IMemtrack/default didn't start. Returning NULL
12-22 12:22:22.501  1827 10885 I ServiceManager: Waiting for service 'android.hardware.memtrack.IMemtrack/default' on '/dev/binder'...
```

Also because the results of this getService() was not cached, we will
attempt to get this service each time there is a new request from
libmemtrack, causing another 5 seconds delay each time.


Fix:

We check if the service is declared before attempting to retrieve it.
We use the more efficient waitForService(), instead of getService()
which can busy loop for 5 seconds.
Cache the results of these operations so that we don’t have to retrieve
the service each time there is a request from libmemtrack.


Boot Time Regression Test

Test: adb shell logcat -b all | grep TotalBootTime

Old version of this topic:       44209ms
LKGB:                            19823ms
New version of this topic:       20058ms


Cts Graphics Test

Test: atest CtsGraphicsTestCases:android.graphics.cts.BitmapTest#testWrappedHardwareBufferBitmapNotLeaking


Old version of this topic:       Fails
LKGB:                            Passes
New version of this topic:       Passes


Memoinfo Test

Test: adb shell dumpsys meminfo

Old version of this topic:       `*** SERVICE 'meminfo' DUMP TIMEOUT (10000ms) EXPIRED ***`
LKGB:                            <Expected output>
New version of this topic:       <Expected output>


Battery Saver Test

Test: Unplug Device; Tap Battery Save Icon from the pull down menu

Old version of this topic:       Battery Saver Icon does not become enabled (blue highlight)
LKGB:                            Battery Saver Icon Enabled
New version of this topic:       Battery Saver Icon Enabled


Bug: 175021432
Test: memtrack_test
Change-Id: I6ce5c454e6a5c9b718277b4b3004f600dd0f6786
2 files changed
tree: 7a75a66773a0fa7e5af32778e67aaf3c76efd723
  1. Android.bp
  2. OWNERS
  3. include/
  4. memtrack.cpp
  5. memtrack_test.cpp