Revert "Add media.c2 AIDL service to media.swcodec"

Revert submission 2758286-c2aidl-swcodec

Reason for revert: b/308991806

Reverted changes: /q/submissionid:2758286-c2aidl-swcodec

Bug: 308991806
Change-Id: If37e7b6ba5a0597690e2ee16762fc930370ff1d7
diff --git a/media/codec2/hal/aidl/Android.bp b/media/codec2/hal/aidl/Android.bp
index 68d7152..44f85fd 100644
--- a/media/codec2/hal/aidl/Android.bp
+++ b/media/codec2/hal/aidl/Android.bp
@@ -6,6 +6,7 @@
 // use libcodec2-aidl-client-defaults instead
 cc_library {
     name: "libcodec2_aidl_client",
+    min_sdk_version: "31",
 
     srcs: [
         "BufferTypes.cpp",
@@ -35,6 +36,7 @@
     ],
 
     static_libs: [
+        "libPlatformProperties",
         "libaidlcommonsupport",
     ],
 
@@ -53,7 +55,7 @@
 // use libcodec2-aidl-defaults instead
 cc_library {
     name: "libcodec2_aidl",
-    min_sdk_version: "30",
+    min_sdk_version: "31",
     vendor_available: true,
     apex_available: [
         "//apex_available:platform",
@@ -96,6 +98,7 @@
     ],
 
     static_libs: [
+        "libPlatformProperties",
         "libaidlcommonsupport",
     ],
 
@@ -131,7 +134,7 @@
 // public dependency for Codec 2.0 HAL service implementations
 cc_defaults {
     name: "libcodec2-aidl-defaults",
-    min_sdk_version: "30",
+    min_sdk_version: "31",
     defaults: ["libcodec2-impl-defaults"],
 
     shared_libs: [
@@ -144,6 +147,7 @@
 // public dependency for Codec 2.0 HAL client
 cc_defaults {
     name: "libcodec2-aidl-client-defaults",
+    min_sdk_version: "31",
     defaults: ["libcodec2-impl-defaults"],
 
     shared_libs: [
diff --git a/media/codec2/hal/aidl/ParamTypes.cpp b/media/codec2/hal/aidl/ParamTypes.cpp
index 495e748..41e6f50 100644
--- a/media/codec2/hal/aidl/ParamTypes.cpp
+++ b/media/codec2/hal/aidl/ParamTypes.cpp
@@ -19,9 +19,7 @@
 #include <android-base/logging.h>
 
 #include <android/binder_manager.h>
-// NOTE: due to dependency from mainline modules cannot use libsysprop
-// #include <android/sysprop/MediaProperties.sysprop.h>
-#include <android-base/properties.h>
+#include <android/sysprop/MediaProperties.sysprop.h>
 #include <codec2/aidl/ParamTypes.h>
 #include <codec2/common/ParamTypes.h>
 
@@ -169,8 +167,6 @@
         // Cannot select AIDL if not enabled
         return false;
     }
-#if 0
-    // NOTE: due to dependency from mainline modules cannot use libsysprop
     using ::android::sysprop::MediaProperties::codec2_hal_selection;
     using ::android::sysprop::MediaProperties::codec2_hal_selection_values;
     constexpr codec2_hal_selection_values AIDL = codec2_hal_selection_values::AIDL;
@@ -184,16 +180,6 @@
     default:
         LOG(FATAL) << "Unexpected codec2 HAL selection value: " << (int)selection;
     }
-#else
-    std::string selection = ::android::base::GetProperty("media.c2.hal.selection", "hidl");
-    if (selection == "aidl") {
-        return true;
-    } else if (selection == "hidl") {
-        return false;
-    } else {
-        LOG(FATAL) << "Unexpected codec2 HAL selection value: " << selection;
-    }
-#endif
 
     return false;
 }
diff --git a/media/codec2/hal/client/client.cpp b/media/codec2/hal/client/client.cpp
index 5311b31..ab6505e 100644
--- a/media/codec2/hal/client/client.cpp
+++ b/media/codec2/hal/client/client.cpp
@@ -45,7 +45,6 @@
 #include <aidl/android/hardware/media/c2/StructDescriptor.h>
 
 #include <aidlcommonsupport/NativeHandle.h>
-#include <android/api-level.h>
 #include <android/binder_auto_utils.h>
 #include <android/binder_ibinder.h>
 #include <android/binder_manager.h>
@@ -1440,16 +1439,12 @@
     std::vector<std::string> names;
 
     if (c2_aidl::utils::IsSelected()) {
-        if (__builtin_available(android __ANDROID_API_S__, *)) {
-            // Get AIDL service names
-            AServiceManager_forEachDeclaredInstance(
-                    AidlBase::descriptor, &names, [](const char *name, void *context) {
-                        std::vector<std::string> *names = (std::vector<std::string> *)context;
-                        names->emplace_back(name);
-                    });
-        } else {
-            LOG(FATAL) << "C2 AIDL cannot be selected on Android version older than 35";
-        }
+        // Get AIDL service names
+        AServiceManager_forEachDeclaredInstance(
+                AidlBase::descriptor, &names, [](const char *name, void *context) {
+                    std::vector<std::string> *names = (std::vector<std::string> *)context;
+                    names->emplace_back(name);
+                });
     } else {
         // Get HIDL service names
         using ::android::hardware::media::c2::V1_0::IComponentStore;
@@ -1551,25 +1546,21 @@
     LOG(VERBOSE) << "Creating a Codec2 client to service \"" << name << "\"";
 
     if (c2_aidl::utils::IsSelected()) {
-        if (__builtin_available(android __ANDROID_API_S__, *)) {
-            std::string instanceName =
-                ::android::base::StringPrintf("%s/%s", AidlBase::descriptor, name.c_str());
-            if (AServiceManager_isDeclared(instanceName.c_str())) {
-                std::shared_ptr<AidlBase> baseStore = AidlBase::fromBinder(
-                        ::ndk::SpAIBinder(AServiceManager_waitForService(instanceName.c_str())));
-                CHECK(baseStore) << "Codec2 AIDL service \"" << name << "\""
-                                    " inaccessible for unknown reasons.";
-                LOG(VERBOSE) << "Client to Codec2 AIDL service \"" << name << "\" created";
-                std::shared_ptr<c2_aidl::IConfigurable> configurable;
-                ::ndk::ScopedAStatus transStatus = baseStore->getConfigurable(&configurable);
-                CHECK(transStatus.isOk()) << "Codec2 AIDL service \"" << name << "\""
-                                            "does not have IConfigurable.";
-                return std::make_shared<Codec2Client>(baseStore, configurable, index);
-            } else {
-                LOG(ERROR) << "Codec2 AIDL service \"" << name << "\" is not declared";
-            }
+        std::string instanceName =
+            ::android::base::StringPrintf("%s/%s", AidlBase::descriptor, name.c_str());
+        if (AServiceManager_isDeclared(instanceName.c_str())) {
+            std::shared_ptr<AidlBase> baseStore = AidlBase::fromBinder(
+                    ::ndk::SpAIBinder(AServiceManager_waitForService(instanceName.c_str())));
+            CHECK(baseStore) << "Codec2 AIDL service \"" << name << "\""
+                                " inaccessible for unknown reasons.";
+            LOG(VERBOSE) << "Client to Codec2 AIDL service \"" << name << "\" created";
+            std::shared_ptr<c2_aidl::IConfigurable> configurable;
+            ::ndk::ScopedAStatus transStatus = baseStore->getConfigurable(&configurable);
+            CHECK(transStatus.isOk()) << "Codec2 AIDL service \"" << name << "\""
+                                        "does not have IConfigurable.";
+            return std::make_shared<Codec2Client>(baseStore, configurable, index);
         } else {
-            LOG(FATAL) << "C2 AIDL cannot be selected on Android version older than 35";
+            LOG(ERROR) << "Codec2 AIDL service \"" << name << "\" is not declared";
         }
     } else {
         std::string instanceName = "android.hardware.media.c2/" + name;