Loading camera/aidl/android/hardware/ICameraServiceProxy.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,9 @@ interface ICameraServiceProxy * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_270}). */ int getRotateAndCropOverride(String packageName, int lensFacing, int userId); /** * Checks if the camera has been disabled via device policy. */ boolean isCameraDisabled(); } services/camera/libcameraservice/CameraService.cpp +11 −15 Original line number Diff line number Diff line Loading @@ -1688,6 +1688,13 @@ Status CameraService::connectDevice( return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string()); } if (CameraServiceProxyWrapper::isCameraDisabled()) { String8 msg = String8::format("Camera disabled by device policy"); ALOGE("%s: %s", __FUNCTION__, msg.string()); return STATUS_ERROR(ERROR_DISABLED, msg.string()); } // enforce system camera permissions if (oomScoreOffset > 0 && !hasPermissionsForSystemCamera(callingPid, CameraThreadState::getCallingUid())) { Loading Loading @@ -3717,21 +3724,10 @@ void CameraService::UidPolicy::onUidIdle(uid_t uid, bool /* disabled */) { void CameraService::UidPolicy::onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq __unused, int32_t capability __unused) { bool procStateChange = false; { Mutex::Autolock _l(mUidLock); if (mMonitoredUids.find(uid) != mMonitoredUids.end() && mMonitoredUids[uid].procState != procState) { mMonitoredUids[uid].procState = procState; procStateChange = true; } } if (procStateChange) { sp<CameraService> service = mService.promote(); if (service != nullptr) { service->notifyMonitoredUids(); } } } Loading services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -260,4 +260,16 @@ void CameraServiceProxyWrapper::logClose(const String8& id, int32_t latencyMs) { sessionStats->onClose(latencyMs); } bool CameraServiceProxyWrapper::isCameraDisabled() { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return true; bool ret = false; auto status = proxyBinder->isCameraDisabled(&ret); if (!status.isOk()) { ALOGE("%s: Failed during camera disabled query: %s", __FUNCTION__, status.exceptionMessage().c_str()); } return ret; } }; // namespace android services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ public: // Return the current top activity rotate and crop override. static int getRotateAndCropOverride(String16 packageName, int lensFacing, int userId); // Detect if the camera is disabled by device policy. static bool isCameraDisabled(); }; } // android Loading services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,10 @@ bool isStreamUseCaseSupported(int64_t streamUseCase, streamUseCase == ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT) { return true; } // Allow vendor stream use case unconditionally. if (streamUseCase >= ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VENDOR_START) { return true; } for (size_t i = 0; i < availableStreamUseCases.count; i++) { if (availableStreamUseCases.data.i64[i] == streamUseCase) { Loading Loading
camera/aidl/android/hardware/ICameraServiceProxy.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -44,4 +44,9 @@ interface ICameraServiceProxy * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_270}). */ int getRotateAndCropOverride(String packageName, int lensFacing, int userId); /** * Checks if the camera has been disabled via device policy. */ boolean isCameraDisabled(); }
services/camera/libcameraservice/CameraService.cpp +11 −15 Original line number Diff line number Diff line Loading @@ -1688,6 +1688,13 @@ Status CameraService::connectDevice( return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string()); } if (CameraServiceProxyWrapper::isCameraDisabled()) { String8 msg = String8::format("Camera disabled by device policy"); ALOGE("%s: %s", __FUNCTION__, msg.string()); return STATUS_ERROR(ERROR_DISABLED, msg.string()); } // enforce system camera permissions if (oomScoreOffset > 0 && !hasPermissionsForSystemCamera(callingPid, CameraThreadState::getCallingUid())) { Loading Loading @@ -3717,21 +3724,10 @@ void CameraService::UidPolicy::onUidIdle(uid_t uid, bool /* disabled */) { void CameraService::UidPolicy::onUidStateChanged(uid_t uid, int32_t procState, int64_t procStateSeq __unused, int32_t capability __unused) { bool procStateChange = false; { Mutex::Autolock _l(mUidLock); if (mMonitoredUids.find(uid) != mMonitoredUids.end() && mMonitoredUids[uid].procState != procState) { mMonitoredUids[uid].procState = procState; procStateChange = true; } } if (procStateChange) { sp<CameraService> service = mService.promote(); if (service != nullptr) { service->notifyMonitoredUids(); } } } Loading
services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -260,4 +260,16 @@ void CameraServiceProxyWrapper::logClose(const String8& id, int32_t latencyMs) { sessionStats->onClose(latencyMs); } bool CameraServiceProxyWrapper::isCameraDisabled() { sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy(); if (proxyBinder == nullptr) return true; bool ret = false; auto status = proxyBinder->isCameraDisabled(&ret); if (!status.isOk()) { ALOGE("%s: Failed during camera disabled query: %s", __FUNCTION__, status.exceptionMessage().c_str()); } return ret; } }; // namespace android
services/camera/libcameraservice/utils/CameraServiceProxyWrapper.h +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ public: // Return the current top activity rotate and crop override. static int getRotateAndCropOverride(String16 packageName, int lensFacing, int userId); // Detect if the camera is disabled by device policy. static bool isCameraDisabled(); }; } // android Loading
services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -322,6 +322,10 @@ bool isStreamUseCaseSupported(int64_t streamUseCase, streamUseCase == ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT) { return true; } // Allow vendor stream use case unconditionally. if (streamUseCase >= ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_VENDOR_START) { return true; } for (size_t i = 0; i < availableStreamUseCases.count; i++) { if (availableStreamUseCases.data.i64[i] == streamUseCase) { Loading