Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 17 | #include <android/content/AttributionSourceState.h> |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 18 | #include <android/hardware/BnCameraServiceListener.h> |
| 19 | #include <android/hardware/BnCameraServiceProxy.h> |
| 20 | #include <android/hardware/camera2/BnCameraDeviceCallbacks.h> |
| 21 | #include <android/hardware/ICameraService.h> |
| 22 | |
| 23 | #include <private/android_filesystem_config.h> |
| 24 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 25 | #include <camera/CameraUtils.h> |
| 26 | |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 27 | #include "../CameraService.h" |
| 28 | #include "../utils/CameraServiceProxyWrapper.h" |
| 29 | |
| 30 | #include <gtest/gtest.h> |
| 31 | |
| 32 | #include <memory> |
| 33 | #include <vector> |
| 34 | |
| 35 | using namespace android; |
| 36 | using namespace android::hardware::camera; |
| 37 | |
| 38 | // Empty service listener. |
| 39 | class TestCameraServiceListener : public hardware::BnCameraServiceListener { |
| 40 | public: |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 41 | virtual ~TestCameraServiceListener() {} |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 42 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 43 | virtual binder::Status onStatusChanged(int32_t , const std::string&, int32_t) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 44 | return binder::Status::ok(); |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 45 | } |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 46 | |
| 47 | virtual binder::Status onPhysicalCameraStatusChanged(int32_t /*status*/, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 48 | const std::string& /*cameraId*/, const std::string& /*physicalCameraId*/, |
| 49 | int32_t /*deviceId*/) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 50 | // No op |
| 51 | return binder::Status::ok(); |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 52 | } |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 53 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 54 | virtual binder::Status onTorchStatusChanged(int32_t /*status*/, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 55 | const std::string& /*cameraId*/, int32_t /*deviceId*/) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 56 | return binder::Status::ok(); |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 57 | } |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 58 | |
| 59 | virtual binder::Status onCameraAccessPrioritiesChanged() { |
| 60 | // No op |
| 61 | return binder::Status::ok(); |
| 62 | } |
| 63 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 64 | virtual binder::Status onCameraOpened(const std::string& /*cameraId*/, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 65 | const std::string& /*clientPackageName*/, int32_t /*deviceId*/) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 66 | // No op |
| 67 | return binder::Status::ok(); |
| 68 | } |
| 69 | |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 70 | virtual binder::Status onCameraClosed(const std::string& /*cameraId*/, int32_t /*deviceId*/) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 71 | // No op |
| 72 | return binder::Status::ok(); |
| 73 | } |
| 74 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 75 | virtual binder::Status onTorchStrengthLevelChanged(const std::string& /*cameraId*/, |
Biswarup Pal | 37a7518 | 2024-01-16 15:53:35 +0000 | [diff] [blame] | 76 | int32_t /*torchStrength*/, int32_t /*deviceId*/) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 77 | // No op |
| 78 | return binder::Status::ok(); |
| 79 | } |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 80 | |
| 81 | virtual binder::Status onCameraOpenedInSharedMode(const std::string& /*cameraId*/, |
| 82 | const std::string& /*clientPackageName*/, int32_t /*deviceId*/, |
| 83 | bool /*isPrimaryClient*/) { |
| 84 | // No op |
| 85 | return binder::Status::ok(); |
| 86 | } |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | // Empty device callback. |
| 90 | class TestCameraDeviceCallbacks : public hardware::camera2::BnCameraDeviceCallbacks { |
| 91 | public: |
| 92 | TestCameraDeviceCallbacks() {} |
| 93 | |
| 94 | virtual ~TestCameraDeviceCallbacks() {} |
| 95 | |
| 96 | virtual binder::Status onDeviceError(int /*errorCode*/, |
| 97 | const CaptureResultExtras& /*resultExtras*/) { |
| 98 | return binder::Status::ok(); |
| 99 | } |
| 100 | |
| 101 | virtual binder::Status onDeviceIdle() { |
| 102 | return binder::Status::ok(); |
| 103 | } |
| 104 | |
| 105 | virtual binder::Status onCaptureStarted(const CaptureResultExtras& /*resultExtras*/, |
| 106 | int64_t /*timestamp*/) { |
| 107 | return binder::Status::ok(); |
| 108 | } |
| 109 | |
| 110 | virtual binder::Status onResultReceived(const CameraMetadata& /*metadata*/, |
| 111 | const CaptureResultExtras& /*resultExtras*/, |
| 112 | const std::vector<PhysicalCaptureResultInfo>& /*physicalResultInfos*/) { |
| 113 | return binder::Status::ok(); |
| 114 | } |
| 115 | |
| 116 | virtual binder::Status onPrepared(int /*streamId*/) { |
| 117 | return binder::Status::ok(); |
| 118 | } |
| 119 | |
| 120 | virtual binder::Status onRepeatingRequestError( |
| 121 | int64_t /*lastFrameNumber*/, int32_t /*stoppedSequenceId*/) { |
| 122 | return binder::Status::ok(); |
| 123 | } |
| 124 | |
| 125 | virtual binder::Status onRequestQueueEmpty() { |
| 126 | return binder::Status::ok(); |
| 127 | } |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 128 | |
| 129 | virtual binder::Status onClientSharedAccessPriorityChanged(bool /*isPrimaryClient*/) { |
| 130 | return binder::Status::ok(); |
| 131 | } |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | // Override isCameraDisabled from the CameraServiceProxy with a flag. |
| 135 | class CameraServiceProxyOverride : public ::android::hardware::BnCameraServiceProxy { |
| 136 | public: |
| 137 | CameraServiceProxyOverride() : |
| 138 | mCameraServiceProxy(CameraServiceProxyWrapper::getDefaultCameraServiceProxy()), |
Greg Kaiser | f18ea7c | 2022-06-06 09:39:00 -0700 | [diff] [blame] | 139 | mCameraDisabled(false), mOverrideCameraDisabled(false) |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 140 | { } |
| 141 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 142 | virtual binder::Status getRotateAndCropOverride(const std::string& packageName, int lensFacing, |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 143 | int userId, int *ret) override { |
| 144 | return mCameraServiceProxy->getRotateAndCropOverride(packageName, lensFacing, |
| 145 | userId, ret); |
| 146 | } |
| 147 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 148 | virtual binder::Status getAutoframingOverride(const std::string& packageName, int *ret) override { |
Bharatt Kukreja | 7146ced | 2022-10-25 15:45:29 +0000 | [diff] [blame] | 149 | return mCameraServiceProxy->getAutoframingOverride(packageName, ret); |
| 150 | } |
| 151 | |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 152 | virtual binder::Status pingForUserUpdate() override { |
| 153 | return mCameraServiceProxy->pingForUserUpdate(); |
| 154 | } |
| 155 | |
| 156 | virtual binder::Status notifyCameraState( |
| 157 | const hardware::CameraSessionStats& cameraSessionStats) override { |
| 158 | return mCameraServiceProxy->notifyCameraState(cameraSessionStats); |
| 159 | } |
| 160 | |
Shuzhen Wang | e3e8e73 | 2024-05-22 17:48:01 -0700 | [diff] [blame] | 161 | virtual binder::Status notifyFeatureCombinationStats( |
| 162 | const hardware::CameraFeatureCombinationStats& featureCombStats) override { |
| 163 | return mCameraServiceProxy->notifyFeatureCombinationStats(featureCombStats); |
| 164 | } |
| 165 | |
Austin Borger | 9bfa0a7 | 2022-08-03 17:50:40 -0700 | [diff] [blame] | 166 | virtual binder::Status isCameraDisabled(int userId, bool *ret) override { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 167 | if (mOverrideCameraDisabled) { |
| 168 | *ret = mCameraDisabled; |
| 169 | return binder::Status::ok(); |
| 170 | } |
Austin Borger | 9bfa0a7 | 2022-08-03 17:50:40 -0700 | [diff] [blame] | 171 | return mCameraServiceProxy->isCameraDisabled(userId, ret); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | void setCameraDisabled(bool cameraDisabled) { |
| 175 | mCameraDisabled = cameraDisabled; |
| 176 | } |
| 177 | |
| 178 | void setOverrideCameraDisabled(bool overrideCameraDisabled) { |
| 179 | mOverrideCameraDisabled = overrideCameraDisabled; |
| 180 | } |
| 181 | |
| 182 | protected: |
| 183 | sp<hardware::ICameraServiceProxy> mCameraServiceProxy; |
| 184 | bool mCameraDisabled; |
| 185 | bool mOverrideCameraDisabled; |
| 186 | }; |
| 187 | |
| 188 | class AutoDisconnectDevice { |
| 189 | public: |
| 190 | AutoDisconnectDevice(sp<hardware::camera2::ICameraDeviceUser> device) : |
| 191 | mDevice(device) |
| 192 | { } |
| 193 | |
| 194 | ~AutoDisconnectDevice() { |
Austin Borger | 9bfa0a7 | 2022-08-03 17:50:40 -0700 | [diff] [blame] | 195 | if (mDevice != nullptr) { |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 196 | mDevice->disconnect(); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | private: |
| 201 | sp<hardware::camera2::ICameraDeviceUser> mDevice; |
| 202 | }; |
| 203 | |
| 204 | class CameraPermissionsTest : public ::testing::Test { |
| 205 | protected: |
| 206 | static sp<CameraService> sCameraService; |
| 207 | static sp<CameraServiceProxyOverride> sCameraServiceProxy; |
| 208 | static std::shared_ptr<CameraServiceProxyWrapper> sCameraServiceProxyWrapper; |
| 209 | static uid_t sOldUid; |
| 210 | |
| 211 | static void SetUpTestSuite() { |
| 212 | sOldUid = getuid(); |
| 213 | setuid(AID_CAMERASERVER); |
| 214 | sCameraServiceProxy = new CameraServiceProxyOverride(); |
| 215 | sCameraServiceProxyWrapper = |
| 216 | std::make_shared<CameraServiceProxyWrapper>(sCameraServiceProxy); |
| 217 | sCameraService = new CameraService(sCameraServiceProxyWrapper); |
| 218 | sCameraService->clearCachedVariables(); |
| 219 | } |
| 220 | |
| 221 | static void TearDownTestSuite() { |
| 222 | sCameraServiceProxyWrapper = nullptr; |
| 223 | sCameraServiceProxy = nullptr; |
| 224 | sCameraService = nullptr; |
| 225 | setuid(sOldUid); |
| 226 | } |
| 227 | }; |
| 228 | |
| 229 | sp<CameraService> CameraPermissionsTest::sCameraService = nullptr; |
| 230 | sp<CameraServiceProxyOverride> CameraPermissionsTest::sCameraServiceProxy = nullptr; |
| 231 | std::shared_ptr<CameraServiceProxyWrapper> |
| 232 | CameraPermissionsTest::sCameraServiceProxyWrapper = nullptr; |
| 233 | uid_t CameraPermissionsTest::sOldUid = 0; |
| 234 | |
| 235 | // Test that camera connections fail with ERROR_DISABLED when the camera is disabled via device |
| 236 | // policy, and succeed when it isn't. |
| 237 | TEST_F(CameraPermissionsTest, TestCameraDisabled) { |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 238 | AttributionSourceState clientAttribution; |
| 239 | clientAttribution.deviceId = kDefaultDeviceId; |
| 240 | clientAttribution.uid = android::CameraService::USE_CALLING_UID; |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 241 | clientAttribution.pid = android::CameraService::USE_CALLING_PID; |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 242 | |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 243 | std::vector<hardware::CameraStatus> statuses; |
| 244 | sp<TestCameraServiceListener> serviceListener = new TestCameraServiceListener(); |
| 245 | sCameraService->addListenerTest(serviceListener, &statuses); |
| 246 | sCameraServiceProxy->setOverrideCameraDisabled(true); |
| 247 | |
| 248 | sCameraServiceProxy->setCameraDisabled(true); |
| 249 | for (auto s : statuses) { |
| 250 | sp<TestCameraDeviceCallbacks> callbacks = new TestCameraDeviceCallbacks(); |
| 251 | sp<hardware::camera2::ICameraDeviceUser> device; |
| 252 | binder::Status status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 253 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 254 | 0/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 255 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 256 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &device); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 257 | AutoDisconnectDevice autoDisconnect(device); |
| 258 | ASSERT_TRUE(!status.isOk()) << "connectDevice returned OK status"; |
| 259 | ASSERT_EQ(status.serviceSpecificErrorCode(), hardware::ICameraService::ERROR_DISABLED) |
| 260 | << "connectDevice returned exception code " << status.exceptionCode(); |
| 261 | } |
| 262 | |
| 263 | sCameraServiceProxy->setCameraDisabled(false); |
| 264 | for (auto s : statuses) { |
| 265 | sp<TestCameraDeviceCallbacks> callbacks = new TestCameraDeviceCallbacks(); |
| 266 | sp<hardware::camera2::ICameraDeviceUser> device; |
| 267 | binder::Status status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 268 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 269 | 0/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 270 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 271 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &device); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 272 | AutoDisconnectDevice autoDisconnect(device); |
| 273 | ASSERT_TRUE(status.isOk()); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // Test that consecutive camera connections succeed. |
| 278 | TEST_F(CameraPermissionsTest, TestConsecutiveConnections) { |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 279 | AttributionSourceState clientAttribution; |
| 280 | clientAttribution.deviceId = kDefaultDeviceId; |
| 281 | clientAttribution.uid = android::CameraService::USE_CALLING_UID; |
| 282 | |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 283 | std::vector<hardware::CameraStatus> statuses; |
| 284 | sp<TestCameraServiceListener> serviceListener = new TestCameraServiceListener(); |
| 285 | sCameraService->addListenerTest(serviceListener, &statuses); |
| 286 | sCameraServiceProxy->setOverrideCameraDisabled(false); |
| 287 | |
| 288 | for (auto s : statuses) { |
| 289 | sp<TestCameraDeviceCallbacks> callbacks = new TestCameraDeviceCallbacks(); |
| 290 | sp<hardware::camera2::ICameraDeviceUser> deviceA, deviceB; |
| 291 | binder::Status status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 292 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 293 | 0/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 294 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 295 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &deviceA); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 296 | AutoDisconnectDevice autoDisconnectA(deviceA); |
| 297 | ASSERT_TRUE(status.isOk()) << "Exception code " << status.exceptionCode() << |
| 298 | " service specific error code " << status.serviceSpecificErrorCode(); |
| 299 | status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 300 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 301 | 0/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 302 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 303 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &deviceB); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 304 | AutoDisconnectDevice autoDisconnectB(deviceB); |
| 305 | ASSERT_TRUE(status.isOk()) << "Exception code " << status.exceptionCode() << |
| 306 | " service specific error code " << status.serviceSpecificErrorCode(); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | // Test that consecutive camera connections succeed even when a nonzero oomScoreOffset is provided |
| 311 | // in the second call. |
| 312 | TEST_F(CameraPermissionsTest, TestConflictingOomScoreOffset) { |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 313 | AttributionSourceState clientAttribution; |
| 314 | clientAttribution.deviceId = kDefaultDeviceId; |
| 315 | clientAttribution.uid = android::CameraService::USE_CALLING_UID; |
| 316 | |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 317 | std::vector<hardware::CameraStatus> statuses; |
| 318 | sp<TestCameraServiceListener> serviceListener = new TestCameraServiceListener(); |
| 319 | sCameraService->addListenerTest(serviceListener, &statuses); |
| 320 | sCameraServiceProxy->setOverrideCameraDisabled(false); |
| 321 | |
| 322 | for (auto s : statuses) { |
| 323 | sp<TestCameraDeviceCallbacks> callbacks = new TestCameraDeviceCallbacks(); |
| 324 | sp<hardware::camera2::ICameraDeviceUser> deviceA, deviceB; |
| 325 | binder::Status status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 326 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 327 | 0/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 328 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 329 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &deviceA); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 330 | AutoDisconnectDevice autoDisconnectA(deviceA); |
| 331 | ASSERT_TRUE(status.isOk()) << "Exception code " << status.exceptionCode() << |
| 332 | " service specific error code " << status.serviceSpecificErrorCode(); |
| 333 | status = |
Austin Borger | d1ad6c6 | 2024-07-01 11:28:31 -0700 | [diff] [blame] | 334 | sCameraService->connectDevice(callbacks, s.cameraId, |
Austin Borger | 65e6464 | 2024-06-11 15:58:23 -0700 | [diff] [blame] | 335 | 1/*oomScoreDiff*/, /*targetSdkVersion*/__ANDROID_API_FUTURE__, |
Jayant Chowdhary | 81d81b0 | 2024-02-15 19:13:39 +0000 | [diff] [blame] | 336 | hardware::ICameraService::ROTATION_OVERRIDE_NONE, |
Jyoti Bhayana | 1f9600b | 2024-10-29 20:25:32 -0700 | [diff] [blame^] | 337 | clientAttribution, /*devicePolicy*/0, /*sharedMode*/false, &deviceB); |
Austin Borger | 86a588e | 2022-05-23 12:41:58 -0700 | [diff] [blame] | 338 | AutoDisconnectDevice autoDisconnectB(deviceB); |
| 339 | ASSERT_TRUE(status.isOk()) << "Exception code " << status.exceptionCode() << |
| 340 | " service specific error code " << status.serviceSpecificErrorCode(); |
| 341 | } |
| 342 | } |