cameraservice: check performance class override in
isSessionConfigurationWithParametersSupported

The current implementation of
isSessionConfigurationWithParametersSupported simply hardcoded a
value of false for overrideForPerfClass parameter. This value
would typically for primary read and front cameras.

This CL passes the app's target SDK version to cameraservice
and uses it to calculate overrideForPerfClass based to follow suit
with all the other CameraService functions.

Bug: 332975108
Test: atest android.hardware.camera2.cts.CameraDeviceSetupTest passes
Change-Id: Ia93e1614f5fa9165383e84d8fdadd1c4dfbb42da
diff --git a/camera/aidl/android/hardware/ICameraService.aidl b/camera/aidl/android/hardware/ICameraService.aidl
index 81af7ee..885749d 100644
--- a/camera/aidl/android/hardware/ICameraService.aidl
+++ b/camera/aidl/android/hardware/ICameraService.aidl
@@ -383,6 +383,7 @@
      * has camera device support.
      *
      * @param cameraId The camera id to query session configuration for
+     * @param targetSdkVersion the target sdk level of the application calling this function.
      * @param sessionConfiguration Specific session configuration to be verified.
      * @param deviceId The device id of the context associated with the caller.
      * @param devicePolicy The camera policy of the device of the associated context (default
@@ -393,15 +394,19 @@
      *         false - in case there is no device support.
      */
     boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId,
-            in SessionConfiguration sessionConfiguration, int deviceId, int devicePolicy);
+            int targetSdkVersion, in SessionConfiguration sessionConfiguration,
+            int deviceId, int devicePolicy);
 
     /**
      * Get the camera characteristics for a particular session configuration for
      * the given camera device.
      *
      * @param cameraId ID of the device for which the session characteristics must be fetched.
+     * @param targetSdkVersion the target sdk level of the application calling this function.
+     * @param overrideToPortrait Whether to override the sensor orientation information to
+     *                           correspond to portrait.
      * @param sessionConfiguration Session configuration for which the characteristics
-     * must be fetched.
+     *                             must be fetched.
      * @param deviceId The device id of the context associated with the caller.
      * @param devicePolicy The camera policy of the device of the associated context (default
      *                     policy for default device context). Only virtual cameras would be exposed
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
index 4005c6a..18543d6 100644
--- a/camera/camera_platform.aconfig
+++ b/camera/camera_platform.aconfig
@@ -200,3 +200,13 @@
        purpose: PURPOSE_BUGFIX
      }
 }
+
+flag {
+     namespace: "camera_platform"
+     name: "calculate_perf_override_during_session_support"
+     description: "Dynamically calulate whether perf class override should be set in isSessionConfigurationWithParametersSupported."
+     bug: "332975108"
+     metadata {
+       purpose: PURPOSE_BUGFIX
+     }
+}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index dd64ff9..95355c9 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -915,11 +915,10 @@
 }
 
 Status CameraService::isSessionConfigurationWithParametersSupported(
-        const std::string& unresolvedCameraId,
+        const std::string& unresolvedCameraId, int targetSdkVersion,
         const SessionConfiguration& sessionConfiguration,
         int32_t deviceId, int32_t devicePolicy,
-        /*out*/
-        bool* supported) {
+        /*out*/ bool* supported) {
     ATRACE_CALL();
 
     if (!flags::feature_combination_query()) {
@@ -955,9 +954,12 @@
                 cameraId.c_str());
     }
 
+    bool overrideForPerfClass = flags::calculate_perf_override_during_session_support() &&
+                                SessionConfigurationUtils::targetPerfClassPrimaryCamera(
+                                        mPerfClassPrimaryCameraIds, cameraId, targetSdkVersion);
+
     return isSessionConfigurationWithParametersSupportedUnsafe(cameraId, sessionConfiguration,
-                                                               /*overrideForPerfClass=*/false,
-                                                               supported);
+                                                               overrideForPerfClass, supported);
 }
 
 Status CameraService::isSessionConfigurationWithParametersSupportedUnsafe(
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index c1ffc87..8dbd591 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -256,11 +256,10 @@
             hardware::camera2::impl::CameraMetadataNative* request);
 
     virtual binder::Status isSessionConfigurationWithParametersSupported(
-            const std::string& cameraId,
+            const std::string& cameraId, int targetSdkVersion,
             const SessionConfiguration& sessionConfiguration,
             int32_t deviceId, int32_t devicePolicy,
-            /*out*/
-            bool* supported);
+            /*out*/ bool* supported);
 
     virtual binder::Status getSessionCharacteristics(
             const std::string& cameraId, int targetSdkVersion, bool overrideToPortrait,