Merge tag 'android-security-10.0.0_r53' into int/10/fp2

Android security 10.0.0 release 53

* tag 'android-security-10.0.0_r53':
  CCodec: force array mode for linear output buffers
  CCodec: properly signal output format changed

Change-Id: I3f281ae8b7138debf2b8399bcce52f3acd22e67a
diff --git a/media/eco/ECOService.cpp b/media/eco/ECOService.cpp
index 6cc4be4..e95dee5 100644
--- a/media/eco/ECOService.cpp
+++ b/media/eco/ECOService.cpp
@@ -49,6 +49,12 @@
     ECOLOGI("ECOService::obtainSession w: %d, h: %d, isCameraRecording: %d", width, height,
             isCameraRecording);
 
+    bool disable = property_get_bool(kDisableEcoServiceProperty, false);
+    if (disable) {
+        ECOLOGE("ECOService:: Failed to obtainSession as ECOService is disable");
+        return STATUS_ERROR(ERROR_UNSUPPORTED, "ECOService is disable");
+    }
+
     if (width <= 0) {
         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Width can not be <= 0");
     }
diff --git a/media/eco/ECOSession.cpp b/media/eco/ECOSession.cpp
index 1bdfa61..a7b919f 100644
--- a/media/eco/ECOSession.cpp
+++ b/media/eco/ECOSession.cpp
@@ -209,13 +209,25 @@
             if (width != mWidth) {
                 ECOLOGW("Codec width: %d, expected: %d", width, mWidth);
             }
-            ECOLOGV("codec width is %d", width);
+            ECOLOGV("codec input width is %d", width);
         } else if (!key.compare(ENCODER_INPUT_HEIGHT)) {
             int32_t height = std::get<int32_t>(value);
             if (height != mHeight) {
                 ECOLOGW("Codec height: %d, expected: %d", height, mHeight);
             }
-            ECOLOGV("codec height is %d", height);
+            ECOLOGV("codec input height is %d", height);
+        } else if (!key.compare(ENCODER_OUTPUT_WIDTH)) {
+            mOutputWidth = std::get<int32_t>(value);
+            if (mOutputWidth != mWidth) {
+                ECOLOGW("Codec output width: %d, expected: %d", mOutputWidth, mWidth);
+            }
+            ECOLOGV("codec output width is %d", mOutputWidth);
+        } else if (!key.compare(ENCODER_OUTPUT_HEIGHT)) {
+            mOutputHeight = std::get<int32_t>(value);
+            if (mOutputHeight != mHeight) {
+                ECOLOGW("Codec output height: %d, expected: %d", mOutputHeight, mHeight);
+            }
+            ECOLOGV("codec output height is %d", mOutputHeight);
         } else {
             ECOLOGW("Unknown session stats key %s from provider.", key.c_str());
             continue;
@@ -304,7 +316,8 @@
             continue;
         } else if (!key.compare(FRAME_NUM) || !key.compare(FRAME_PTS_US) ||
                    !key.compare(FRAME_TYPE) || !key.compare(FRAME_SIZE_BYTES) ||
-                   !key.compare(ENCODER_ACTUAL_BITRATE_BPS)) {
+                   !key.compare(ENCODER_ACTUAL_BITRATE_BPS) ||
+                   !key.compare(ENCODER_FRAMERATE_FPS)) {
             // Only process the keys that are supported by ECOService 1.0.
             info.set(key, value);
         } else if (!key.compare(FRAME_AVG_QP)) {
@@ -407,8 +420,9 @@
         const sp<::android::media::eco::IECOServiceStatsProvider>& provider, bool* status) {
     std::scoped_lock<std::mutex> lock(mSessionLock);
     // Check if the provider is the same as current provider for the session.
-    if (provider.get() != mProvider.get()) {
+    if (IInterface::asBinder(provider) != IInterface::asBinder(mProvider)) {
         *status = false;
+        ECOLOGE("Failed to remove provider");
         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Provider does not match");
     }
 
@@ -484,8 +498,9 @@
         const sp<::android::media::eco::IECOServiceInfoListener>& listener, bool* _aidl_return) {
     std::scoped_lock<std::mutex> lock(mSessionLock);
     // Check if the listener is the same as current listener for the session.
-    if (listener.get() != mListener.get()) {
+    if (IInterface::asBinder(listener) != IInterface::asBinder(mListener)) {
         *_aidl_return = false;
+        ECOLOGE("Failed to remove listener");
         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Listener does not match");
     }
 
@@ -495,11 +510,12 @@
     return binder::Status::ok();
 }
 
-Status ECOSession::pushNewStats(const ::android::media::eco::ECOData& stats, bool*) {
+Status ECOSession::pushNewStats(const ::android::media::eco::ECOData& stats, bool* _aidl_return) {
     ECOLOGV("ECOSession get new stats type: %s", stats.getDataTypeString().c_str());
     std::unique_lock<std::mutex> lock(mStatsQueueLock);
     mStatsQueue.push_back(stats);
     mWorkerWaitCV.notify_all();
+    *_aidl_return = true;
     return binder::Status::ok();
 }
 
diff --git a/media/eco/include/eco/ECODebug.h b/media/eco/include/eco/ECODebug.h
index b250f64..ff0e8b5 100644
--- a/media/eco/include/eco/ECODebug.h
+++ b/media/eco/include/eco/ECODebug.h
@@ -26,11 +26,12 @@
 namespace media {
 namespace eco {
 
-static const char* kDebugLogsLevelProperty = "media.ecoservice.log.level";
-static const char* kDebugLogStats = "media.ecoservice.log.stats";
-static const char* kDebugLogStatsSize = "media.ecoservice.log.stats.size";
-static const char* kDebugLogInfos = "media.ecoservice.log.info";
-static const char* kDebugLogInfosSize = "media.ecoservice.log.info.size";
+static const char* kDisableEcoServiceProperty = "vendor.media.ecoservice.disable";
+static const char* kDebugLogsLevelProperty = "vendor.media.ecoservice.log.level";
+static const char* kDebugLogStats = "vendor.media.ecoservice.log.stats";
+static const char* kDebugLogStatsSize = "vendor.media.ecoservice.log.stats.size";
+static const char* kDebugLogInfos = "vendor.media.ecoservice.log.info";
+static const char* kDebugLogInfosSize = "vendor.media.ecoservice.log.info.size";
 
 // A debug variable that should only be accessed by ECOService through updateLogLevel. It is rare
 // that this variable will have race condition. But if so, it is ok as this is just for debugging.