omx: only list existing OMX codecs in OmxStore

Bug: 129710438
Change-Id: Iaeba313ec94838880a8d20d775866f20454104be
diff --git a/services/mediacodec/main_codecservice.cpp b/services/mediacodec/main_codecservice.cpp
index 6ffbd26..f668c33 100644
--- a/services/mediacodec/main_codecservice.cpp
+++ b/services/mediacodec/main_codecservice.cpp
@@ -49,12 +49,6 @@
 
     // Default codec services
     using namespace ::android::hardware::media::omx::V1_0;
-    sp<IOmxStore> omxStore = new implementation::OmxStore();
-    if (omxStore == nullptr) {
-        LOG(ERROR) << "Cannot create IOmxStore HAL service.";
-    } else if (omxStore->registerAsService() != OK) {
-        LOG(ERROR) << "Cannot register IOmxStore HAL service.";
-    }
     sp<IOmx> omx = new implementation::Omx();
     if (omx == nullptr) {
         LOG(ERROR) << "Cannot create IOmx HAL service.";
@@ -63,6 +57,12 @@
     } else {
         LOG(INFO) << "IOmx HAL service created.";
     }
+    sp<IOmxStore> omxStore = new implementation::OmxStore(omx);
+    if (omxStore == nullptr) {
+        LOG(ERROR) << "Cannot create IOmxStore HAL service.";
+    } else if (omxStore->registerAsService() != OK) {
+        LOG(ERROR) << "Cannot register IOmxStore HAL service.";
+    }
 
     ::android::hardware::joinRpcThreadpool();
 }