check_vintf: also checks deprecation

Also fix suggestion for checkUnusedHals because there might be
deprecated HALs added.

Test: replace health 2.1 with 1.0 HAL and m check-vintf-all, see error
      about incompatibility, deprecated HALs and unused HALs.
Test: add health 1.0 HAL, see error about deprecated and unused HALs.
Test: replace vibrator AIDL HAL with 1.3 HIDL HAL, see error about
      deprecated and unused HALs.

Fixes: 153370708

Change-Id: I4d3209b0dcda708ff5f8ad809a10c7d703ee9936
(cherry picked from commit 5a220b158019d823b59ad6c00b07e5bdc5e25f61)
Merged-In: I4d3209b0dcda708ff5f8ad809a10c7d703ee9936
diff --git a/check_vintf.cpp b/check_vintf.cpp
index ce32730..d38d136 100644
--- a/check_vintf.cpp
+++ b/check_vintf.cpp
@@ -397,6 +397,16 @@
         SetErrorCode(&retError, -compatibleResult) << compatibleError;
     }
 
+    auto hidlMetadata = HidlInterfaceMetadata::all();
+
+    std::string deprecateError;
+    int deprecateResult = vintfObject->checkDeprecation(hidlMetadata, &deprecateError);
+    if (deprecateResult == DEPRECATED) {
+        SetErrorCode(&retError) << deprecateError;
+    } else if (deprecateResult != NO_DEPRECATED_HALS) {
+        SetErrorCode(&retError, -deprecateResult) << deprecateError;
+    }
+
     auto hasFcmExt = vintfObject->hasFrameworkCompatibilityMatrixExtensions();
     AddResult(&retError, hasFcmExt);
 
@@ -409,7 +419,6 @@
     }
 
     if (hasFcmExt.value_or(false) || (targetFcm != Level::UNSPECIFIED && targetFcm >= Level::R)) {
-        auto hidlMetadata = HidlInterfaceMetadata::all();
         AddResult(&retError, vintfObject->checkUnusedHals(hidlMetadata));
     } else {
         LOG(INFO) << "Skip checking unused HALs.";