Move proc fs access check outside constructor.

The car watchdog native daemon unittest, libwatchdog_test, is killed due
to sepolicy violation. This violation happens when the unittest accesses
proc fs files. Move the proc fs access check outside the constructors,
so classes that depend on the proc fs collectors can mock them safely
after calling the real constructors.

- Update UidStatsCollector to check whether UidIoStatsCollector is
  enabled.
- Refactor WatchdogPerfServiceTest to use a test class as it makes the
  tests cleaner.
- Add missing GUARDED_BY statements in UidStatsCollector.

Test: atest libwatchdog_test
Bug: 216642418
Bug: 215711169

Change-Id: If750481cb95803253c2787c7e4459b68271bb8d7
Merged-In: If750481cb95803253c2787c7e4459b68271bb8d7
(cherry picked from commit 287c8fc74d88b0c781d1ba7808730df65e2f950e)
22 files changed
tree: 3ce8ef6c40b1a622b5cb312755230a20eb57ab1e
  1. car-admin-ui-lib/
  2. car-internal-lib/
  3. car-lib/
  4. car-maps-placeholder/
  5. car-systemtest-lib/
  6. car-test-lib/
  7. car-usb-handler/
  8. car_product/
  9. cpp/
  10. data/
  11. experimental/
  12. FrameworkPackageStubs/
  13. obd2-lib/
  14. packages/
  15. procfs-inspector/
  16. service/
  17. tests/
  18. tools/
  19. user/
  20. vehicle-hal-support-lib/
  21. .clang-format
  22. .gitignore
  23. Android.mk
  24. CleanSpec.mk
  25. CPPLINT.cfg
  26. OWNERS
  27. PREUPLOAD.cfg
  28. README.md
  29. TEST_MAPPING
README.md

Native (C++) code format is required to be compatible with .clang-format file. Run

git clang-format --style=file --extension='h,cpp,cc' HEAD~

Note that clang-format is not desirable for Android java files. Therefore the command line above is limited to specific extensions.