Convert boot, memtrack and power hal to use service name aware testing.

Motivation:
1) Support running the test against each hal service instance for the 
   registered hal.
2) Support testability checker to determine whether we should run the 
   test on the taget device.
3) Help to determine the process we want to profile for coverage data
   if running on coverage build. 
Bug: 64203181
Test: make vts
      vts-tradefed run vts -m VtsHalBootV1_0Target
      vts-tradefed run vts -m VtsHalMemtrackV1_0Target
      vts-tradefed run vts -m VtsHalPowerV1_0Target
      vts-tradefed run vts -m VtsHalPowerV1_1Target
Change-Id: Ie0bbd9ef9d9fbe11de5aee70fad9028fa0ae897c
diff --git a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
index f48a95d..d1d7f73 100644
--- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
+++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
@@ -22,6 +22,7 @@
 #include <android/hardware/boot/1.0/IBootControl.h>
 
 #include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
 
 using ::android::hardware::boot::V1_0::IBootControl;
 using ::android::hardware::boot::V1_0::CommandResult;
@@ -33,12 +34,25 @@
 using std::string;
 using std::vector;
 
+// Test environment for Boot HIDL HAL.
+class BootHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+   public:
+    // get the test environment singleton
+    static BootHidlEnvironment* Instance() {
+        static BootHidlEnvironment* instance = new BootHidlEnvironment;
+        return instance;
+    }
+
+    virtual void registerTestServices() override { registerTestService<IBootControl>(); }
+};
+
 // The main test class for the Boot HIDL HAL.
 class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase {
  public:
   virtual void SetUp() override {
-    boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>();
-    ASSERT_NE(boot, nullptr);
+      boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>(
+          BootHidlEnvironment::Instance()->getServiceName<IBootControl>());
+      ASSERT_NE(boot, nullptr);
   }
 
   virtual void TearDown() override {}
@@ -171,8 +185,10 @@
 }
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
-  int status = RUN_ALL_TESTS();
-  LOG(INFO) << "Test result = " << status;
-  return status;
+    ::testing::AddGlobalTestEnvironment(BootHidlEnvironment::Instance());
+    ::testing::InitGoogleTest(&argc, argv);
+    BootHidlEnvironment::Instance()->init(&argc, argv);
+    int status = RUN_ALL_TESTS();
+    LOG(INFO) << "Test result = " << status;
+    return status;
 }