Make Codec2 software service public

This CL makes the software Codec2 service present the public Codec2 HAL
interface, and makes the framework use it.

Test: make cts -j123 && cts-tradefed run cts-dev -m \
CtsMediaTestCases --compatibility:module-arg \
CtsMediaTestCases:include-annotation:\
android.platform.test.annotations.RequiresDevice

Bug: 112362730
Bug: 119853704

Change-Id: I047c6948a883a6e085d988a3fa542129ebb9571f
diff --git a/media/codec2/hidl/client/client.cpp b/media/codec2/hidl/client/client.cpp
index ddeb4ff..26bd96c 100644
--- a/media/codec2/hidl/client/client.cpp
+++ b/media/codec2/hidl/client/client.cpp
@@ -76,7 +76,11 @@
 
 // Convenience methods to obtain known clients.
 std::shared_ptr<Codec2Client> getClient(size_t index) {
-    return Codec2Client::CreateFromService(kClientNames[index]);
+    uint32_t serviceMask = ::android::base::GetUintProperty(
+            "debug.media.codec2", uint32_t(0));
+    return Codec2Client::CreateFromService(
+            kClientNames[index],
+            (serviceMask & (1 << index)) != 0);
 }
 
 ClientList getClientList() {
@@ -633,9 +637,13 @@
             Base::tryGetService(instanceName);
     if (!baseStore) {
         if (waitForService) {
-            ALOGE("Codec2.0 service inaccessible. Check the device manifest.");
+            ALOGW("Codec2.0 service \"%s\" inaccessible. "
+                  "Check the device manifest.",
+                  instanceName);
         } else {
-            ALOGW("Codec2.0 service not available right now. Try again later.");
+            ALOGD("Codec2.0 service \"%s\" unavailable right now. "
+                  "Try again later.",
+                  instanceName);
         }
         return nullptr;
     }
diff --git a/media/codec2/hidl/services/Android.bp b/media/codec2/hidl/services/Android.bp
index 965971e..216525e 100644
--- a/media/codec2/hidl/services/Android.bp
+++ b/media/codec2/hidl/services/Android.bp
@@ -37,58 +37,3 @@
     compile_multilib: "32",
 }
 
-cc_library_shared {
-    name: "libcodec2_serviceregistrant",
-    // need vendor version for update packaging, system version may have more dependencies
-    vendor_available: true,
-    srcs: [
-        "C2SoftwareCodecServiceRegistrant.cpp",
-    ],
-
-    header_libs: [
-        "libmedia_headers",
-    ],
-
-    shared_libs: [
-        "android.hardware.media.c2@1.0",
-        "libcodec2_hidl@1.0",
-        "libcodec2_vndk",
-        "liblog",
-        "libutils",
-    ],
-
-    // Codecs
-    runtime_libs: [
-        "libcodec2_soft_avcdec",
-        "libcodec2_soft_avcenc",
-        "libcodec2_soft_aacdec",
-        "libcodec2_soft_aacenc",
-        "libcodec2_soft_amrnbdec",
-        "libcodec2_soft_amrnbenc",
-        "libcodec2_soft_amrwbdec",
-        "libcodec2_soft_amrwbenc",
-        "libcodec2_soft_hevcdec",
-        "libcodec2_soft_g711alawdec",
-        "libcodec2_soft_g711mlawdec",
-        "libcodec2_soft_mpeg2dec",
-        "libcodec2_soft_h263dec",
-        "libcodec2_soft_h263enc",
-        "libcodec2_soft_mpeg4dec",
-        "libcodec2_soft_mpeg4enc",
-        "libcodec2_soft_mp3dec",
-        "libcodec2_soft_vorbisdec",
-        "libcodec2_soft_opusdec",
-        "libcodec2_soft_vp8dec",
-        "libcodec2_soft_vp9dec",
-        "libcodec2_soft_vp8enc",
-        "libcodec2_soft_vp9enc",
-        "libcodec2_soft_rawdec",
-        "libcodec2_soft_flacdec",
-        "libcodec2_soft_flacenc",
-        "libcodec2_soft_gsmdec",
-        "libcodec2_soft_xaacdec",
-    ],
-
-    compile_multilib: "32",
-}
-
diff --git a/media/codec2/hidl/services/C2SoftwareCodecServiceRegistrant.cpp b/media/codec2/hidl/services/C2SoftwareCodecServiceRegistrant.cpp
deleted file mode 100644
index e10ae6e..0000000
--- a/media/codec2/hidl/services/C2SoftwareCodecServiceRegistrant.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "C2SoftwareCodecServiceRegistrant"
-
-#include <C2PlatformSupport.h>
-#include <codec2/hidl/1.0/ComponentStore.h>
-#include <media/CodecServiceRegistrant.h>
-#include <log/log.h>
-
-extern "C" void RegisterCodecServices() {
-    using namespace ::android::hardware::media::c2::V1_0;
-    android::sp<IComponentStore> store =
-        new utils::ComponentStore(
-                android::GetCodec2PlatformComponentStore());
-    if (store == nullptr) {
-        ALOGE("Cannot create Codec2's IComponentStore software service.");
-    } else {
-        if (store->registerAsService("software") != android::OK) {
-            ALOGE("Cannot register Codec2's "
-                    "IComponentStore software service.");
-        } else {
-            ALOGI("Codec2's IComponentStore software service created.");
-        }
-    }
-}
-