Support dynamically enable profiling.

* Create method configureInstrumentation to enable/disable instrumentation based
  on the corresponding system property. This method will be called every
  time setHALInstrumention is invoked for any hal.
* Add setHALInstrumention to IBase.hal

Bug: 33923655
Test: make libhidlbase.
Change-Id: I130fb903f65783568a97308e291965960abab41d
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 78bc2c8..106fb02 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -851,6 +851,10 @@
     virtual ~HidlInstrumentor();
 
  protected:
+    // Set mEnableInstrumentation based on system property
+    // hal.instrumentation.enable, register/de-register instrumentation
+    // callbacks if mEnableInstrumentation is true/false.
+    void configureInstrumentation(bool log=true);
     // Function that lookup and dynamically loads the hidl instrumentation
     // libraries and registers the instrumentation callback functions.
     //
@@ -864,18 +868,18 @@
     //
     // A no-op for user build.
     void registerInstrumentationCallbacks(
-            const std::string &profilerPrefix,
             std::vector<InstrumentationCallback> *instrumentationCallbacks);
 
     // Utility function to determine whether a give file is a instrumentation
     // library (i.e. the file name follow the expected pattern).
-    bool isInstrumentationLib(
-            const std::string &profilerPrefix,
-            const dirent *file);
+    bool isInstrumentationLib(const dirent *file);
+
     // A list of registered instrumentation callbacks.
     std::vector<InstrumentationCallback> mInstrumentationCallbacks;
     // Flag whether to enable instrumentation.
     bool mEnableInstrumentation;
+    // Prefix to lookup the instrumentation libraries.
+    std::string mInstrumentationLibPrefix;
 };
 
 }  // namespace hardware