diff --git a/bundle.json b/bundle.json index dfcb1b63a2162bcc8776a523bd4084b53896abd4..1450c5d7b226b476a804a9e358292dbe68628b9a 100644 --- a/bundle.json +++ b/bundle.json @@ -56,6 +56,7 @@ "//foundation/distributedhardware/distributedcamera/services/cameraservice/sourceservice:distributed_camera_source", "//foundation/distributedhardware/distributedcamera/services/data_process:distributed_camera_data_process", "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera_sa_profile", + "//foundation/distributedhardware/distributedcamera/sa_profile:dcamera.cfg", "//foundation/distributedhardware/distributedcamera/services/channel:distributed_camera_channel", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/host:distributed_camera_host_config", "//foundation/distributedhardware/distributedcamera/camera_hdf/interfaces/hdi_ipc/config/provider:distributed_camera_provider_config", diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index d89ffa24b66d2ae237aa710fd5cb9733b524cb08..5c60ea744a858ba40ab86c0add3d8b257752ccd4 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -74,7 +74,7 @@ const uint32_t DCAMERA_PRODUCER_FPS_DEFAULT = 30; const uint32_t DCAMERA_MAX_RECV_DATA_LEN = 104857600; const uint32_t DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID = 4803; const uint32_t DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID = 4804; -const std::string DCAMERA_PKG_NAME = "ohos.dhardware"; +const std::string DCAMERA_PKG_NAME = "ohos.dhardware.dcamera"; const std::string SNAP_SHOT_SESSION_FLAG = "dataSnapshot"; const std::string CONTINUE_SESSION_FLAG = "dataContinue"; diff --git a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn index ea379967f915f47b37878d3cb19bb8642894a6a9..33d359b691f199e414c9f699b467cfd7e2ddc4e6 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn @@ -33,6 +33,7 @@ ohos_shared_library("distributed_camera_sink_sdk") { sources = [ "src/dcamera_sink_handler.cpp", "src/dcamera_sink_handler_ipc.cpp", + "src/dcamera_sink_load_callback.cpp", "src/distributed_camera_sink_proxy.cpp", ] diff --git a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h index 52b95b6e03c6ee35496fb1c81d7ae8908a973d86..e9829725fb1aa32568b45b585aaf19c8e97f150c 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_handler.h @@ -16,6 +16,9 @@ #ifndef OHOS_DCAMERA_SINK_HANDLER_H #define OHOS_DCAMERA_SINK_HANDLER_H +#include +#include + #include "idistributed_hardware_sink.h" #include "single_instance.h" @@ -28,10 +31,19 @@ public: int32_t ReleaseSink() override; int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; int32_t UnsubscribeLocalHardware(const std::string& dhId) override; - + void FinishStartSA(const std::string ¶ms); + void FinishStartSAFailed(int32_t systemAbilityId); private: + typedef enum { + DCAMERA_SA_STATE_STOP = 0, + DCAMERA_SA_STATE_START = 1, + } DCameraSAState; DCameraSinkHandler() = default; ~DCameraSinkHandler(); +private: + std::condition_variable producerCon_; + std::mutex producerMutex_; + DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; #ifdef __cplusplus diff --git a/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..003f90d53d7e4207d5e728d5191effa590c82c9d --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_sink/include/dcamera_sink_load_callback.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_DCAMERA_SINk_LOAD_CALLBACK_H +#define OHOS_DCAMERA_SINk_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class DCameraSinkLoadCallback : public SystemAbilityLoadCallbackStub { +public: + explicit DCameraSinkLoadCallback(const std::string& params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; +private: + std::string params_; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp index 4ddea60ad9c114a60943524ae7e497171acd681f..805ec0f8537d4768c9aff0734d6e64d43e3becb9 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_handler.cpp @@ -17,8 +17,12 @@ #include "anonymous_string.h" #include "dcamera_sink_handler_ipc.h" +#include "dcamera_sink_load_callback.h" +#include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { @@ -32,13 +36,50 @@ DCameraSinkHandler::~DCameraSinkHandler() int32_t DCameraSinkHandler::InitSink(const std::string& params) { DHLOGI("DCameraSinkHandler::InitSink"); + sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (sm == nullptr) { + DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); + return DCAMERA_INIT_ERR; + } + sptr loadCallback = new DCameraSinkLoadCallback(params); + int32_t ret = sm->LoadSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, loadCallback); + if (ret != DCAMERA_OK) { + DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); + return DCAMERA_INIT_ERR; + } + uint32_t interval = 1; + std::unique_lock lock(producerMutex_); + producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { + return (this->state_ == DCAMERA_SA_STATE_START); + }); + if (state_ == DCAMERA_SA_STATE_STOP) { + DHLOGE("SinkSA Start failed!"); + return DCAMERA_INIT_ERR; + } + DHLOGI("DCameraSinkHandler InitSink end, result: %d", ret); + return DCAMERA_OK; +} + +void DCameraSinkHandler::FinishStartSA(const std::string& params) +{ DCameraSinkHandlerIpc::GetInstance().Init(); sptr dCameraSinkSrv = DCameraSinkHandlerIpc::GetInstance().GetSinkLocalDHMS(); if (dCameraSinkSrv == nullptr) { DHLOGE("DCameraSinkHandler::InitSink get Service failed"); - return DCAMERA_INIT_ERR; + return; } - return dCameraSinkSrv->InitSink(params); + dCameraSinkSrv->InitSink(params); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_START; + producerCon_.notify_one(); +} + +void DCameraSinkHandler::FinishStartSAFailed(int32_t systemAbilityId) +{ + DHLOGI("SinkSA Start failed, systemAbilityId: %d.", systemAbilityId); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_STOP; + producerCon_.notify_one(); } int32_t DCameraSinkHandler::ReleaseSink() diff --git a/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..139241abc00ce44b3fce58e2cc138710ff1c38ff --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_sink/src/dcamera_sink_load_callback.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "dcamera_sink_load_callback.h" +#include "dcamera_sink_handler.h" +#include "distributed_hardware_log.h" +#include "distributed_camera_constants.h" + +namespace OHOS { +namespace DistributedHardware { +DCameraSinkLoadCallback::DCameraSinkLoadCallback(const std::string& params) : params_(params) {} +void DCameraSinkLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr& remoteObject) +{ + DHLOGI("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; + } + if (remoteObject == nullptr) { + DHLOGE("remoteObject is null."); + return; + } + DCameraSinkHandler::GetInstance().FinishStartSA(params_); +} + +void DCameraSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGI("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID) { + DHLOGE("start aystemabilityId is not sinkSAId!"); + return; + } + DCameraSinkHandler::GetInstance().FinishStartSAFailed(systemAbilityId); +} +} +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index 50cc17a13efdf4e753f4b26c69a974b7283b415f..011442db8f77fb9ab5d47e4a7482b44b7f8772ce 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -36,6 +36,7 @@ ohos_shared_library("distributed_camera_source_sdk") { "src/callback/dcamera_source_callback_stub.cpp", "src/dcamera_source_handler.cpp", "src/dcamera_source_handler_ipc.cpp", + "src/dcamera_source_load_callback.cpp", "src/distributed_camera_source_proxy.cpp", ] diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h index a1f47f6c7f085960836badcfa9412cbde8e190be..0278578ee0c282c014b8afdaaad23fe68336e403 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_handler.h @@ -17,6 +17,7 @@ #define OHOS_DCAMERA_SOURCE_HANDLER_H #include +#include #include "iremote_proxy.h" #include "iremote_broker.h" @@ -39,14 +40,22 @@ public: std::shared_ptr callback) override; int32_t ConfigDistributedHardware(const std::string& devId, const std::string& dhId, const std::string& key, const std::string& value) override; - + void FinishStartSA(const std::string ¶ms); + void FinishStartSAFailed(int32_t systemAbilityId); private: + typedef enum { + DCAMERA_SA_STATE_STOP = 0, + DCAMERA_SA_STATE_START = 1, + } DCameraSAState; DCameraSourceHandler() = default; ~DCameraSourceHandler(); private: std::mutex optLock_; sptr callback_; + std::condition_variable producerCon_; + std::mutex producerMutex_; + DCameraSAState state_ = DCAMERA_SA_STATE_STOP; }; #ifdef __cplusplus diff --git a/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h new file mode 100644 index 0000000000000000000000000000000000000000..458f983a41a67e493dd1f516ea7e2e321b5d2b3e --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_source/include/dcamera_source_load_callback.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef OHOS_DCAMERA_SOURCE_LOAD_CALLBACK_H +#define OHOS_DCAMERA_SOURCE_LOAD_CALLBACK_H + +#include "system_ability_load_callback_stub.h" + +namespace OHOS { +namespace DistributedHardware { +class DCameraSourceLoadCallback : public SystemAbilityLoadCallbackStub { +public: + explicit DCameraSourceLoadCallback(const std::string& params); + void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override; + void OnLoadSystemAbilityFail(int32_t systemAbilityId) override; +private: + std::string params_; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp index ddee107feedeeeddf5d50e20597c89fa6b2e10de..e40358ccc38d6a3142d2fdc1fc0706048717dfde 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_handler.cpp @@ -14,13 +14,17 @@ */ #include "dcamera_source_handler.h" -#include "dcamera_source_callback.h" #include "anonymous_string.h" +#include "dcamera_source_callback.h" #include "dcamera_source_handler_ipc.h" +#include "dcamera_source_load_callback.h" #include "dh_utils_tool.h" +#include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" +#include "if_system_ability_manager.h" +#include "iservice_registry.h" namespace OHOS { namespace DistributedHardware { @@ -34,21 +38,56 @@ DCameraSourceHandler::~DCameraSourceHandler() int32_t DCameraSourceHandler::InitSource(const std::string& params) { DHLOGI("DCameraSourceHandler InitSource Start"); + sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (sm == nullptr) { + DHLOGE("GetSourceLocalDHMS GetSystemAbilityManager failed"); + return DCAMERA_INIT_ERR; + } + sptr loadCallback = new DCameraSourceLoadCallback(params); + int32_t ret = sm->LoadSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID, loadCallback); + if (ret != DCAMERA_OK) { + DHLOGE("systemAbilityId: %d load filed,result code: %d.", DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID, ret); + return DCAMERA_INIT_ERR; + } + uint32_t interval = 1; + std::unique_lock lock(producerMutex_); + producerCon_.wait_for(lock, std::chrono::minutes(interval), [this] { + return (this->state_ == DCAMERA_SA_STATE_START); + }); + if (state_ == DCAMERA_SA_STATE_STOP) { + DHLOGE("SourceSA Start failed!"); + return DCAMERA_INIT_ERR; + } + DHLOGI("DCameraSourceHandler InitSource end, result: %d", ret); + return DCAMERA_OK; +} + +void DCameraSourceHandler::FinishStartSA(const std::string ¶ms) +{ DCameraSourceHandlerIpc::GetInstance().Init(); sptr dCameraSourceSrv = DCameraSourceHandlerIpc::GetInstance().GetSourceLocalDHMS(); if (dCameraSourceSrv == nullptr) { DHLOGE("DCameraSourceHandler InitSource get Service failed"); - return DCAMERA_INIT_ERR; + return; } callback_ = new DCameraSourceCallback(); if (callback_ == nullptr) { DHLOGE("DCameraSourceHandler InitSource init callback failed"); - return DCAMERA_INIT_ERR; + return; } - int32_t ret = dCameraSourceSrv->InitSource(params, callback_); - DHLOGI("DCameraSourceHandler InitSource end, ret: %d", ret); - return ret; + dCameraSourceSrv->InitSource(params, callback_); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_START; + producerCon_.notify_one(); +} + +void DCameraSourceHandler::FinishStartSAFailed(int32_t systemAbilityId) +{ + DHLOGE("SourceSA Start failed, systemAbilityId: %d.", systemAbilityId); + std::unique_lock lock(producerMutex_); + state_ = DCAMERA_SA_STATE_STOP; + producerCon_.notify_one(); } int32_t DCameraSourceHandler::ReleaseSource() diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73a7cf7920410e57488f725720cf3e08074cf60c --- /dev/null +++ b/interfaces/inner_kits/native_cpp/camera_source/src/dcamera_source_load_callback.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "dcamera_source_load_callback.h" +#include "dcamera_source_handler.h" +#include "distributed_hardware_log.h" +#include "distributed_camera_constants.h" + +namespace OHOS { +namespace DistributedHardware { +DCameraSourceLoadCallback::DCameraSourceLoadCallback(const std::string& params) : params_(params) {} +void DCameraSourceLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, + const sptr& remoteObject) +{ + DHLOGI("OnLoadSystemAbilitySuccess systemAbilityId: %d, IRmoteObject result: %s", + systemAbilityId, (remoteObject != nullptr) ? "true" : "false"); + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; + } + if (remoteObject == nullptr) { + DHLOGE("remoteObject is null."); + return; + } + DCameraSourceHandler::GetInstance().FinishStartSA(params_); +} + +void DCameraSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) +{ + DHLOGI("OnLoadSystemAbilityFail systemAbilityId: %d.", systemAbilityId); + if (systemAbilityId != DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID) { + DHLOGE("start systemabilityId is not sourceSAId!"); + return; + } + DCameraSourceHandler::GetInstance().FinishStartSAFailed(systemAbilityId); +} +} +} \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp index 113bdbda2436aaed451413b43a4dd53b88c11e41..33af72b07c2b1834b259c952c188396eb9834294 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp @@ -34,7 +34,7 @@ int32_t DistributedCameraSourceProxy::InitSource(const std::string& params, } MessageParcel data; MessageParcel reply; - MessageOption option; + MessageOption option = { MessageOption::TF_ASYNC }; if (!data.WriteInterfaceToken(DistributedCameraSourceProxy::GetDescriptor())) { DHLOGE("DistributedCameraSourceProxy InitSource write token failed"); return DCAMERA_BAD_VALUE; diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index d5e5bfaa79df8b30d30d9469d155311bc7fb6f81..1908bec35d6a9630464acb32215297fc54941e64 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dcamera 4803 libdistributed_camera_source.z.so - true + false true 1 diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index f0e705748d635b5c4a7b93e0fa6ed41666f746d1..222771348b3cc7c8a11c6d7702f375390fe2e341 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -14,13 +14,13 @@ * limitations under the License. --> - dhardware + dcamera 4804 libdistributed_camera_sink.z.so - true + false true 1 diff --git a/sa_profile/BUILD.gn b/sa_profile/BUILD.gn index 8d10ac4f7b314aec5285454fb47736feae2eb307..d78e0b2bf47701404ec492fd74381cb2dda640e0 100644 --- a/sa_profile/BUILD.gn +++ b/sa_profile/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/ohos.gni") import("//build/ohos/sa_profile/sa_profile.gni") ohos_sa_profile("dcamera_sa_profile") { @@ -21,3 +22,9 @@ ohos_sa_profile("dcamera_sa_profile") { part_name = "distributed_camera" } +ohos_prebuilt_etc("dcamera.cfg") { + relative_install_dir = "init" + source = "dcamera.cfg" + part_name = "distributed_camera" + subsystem_name = "distributedhardware" +} diff --git a/sa_profile/dcamera.cfg b/sa_profile/dcamera.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2f92f47f80d5aaef4fea57bd1fb65346fdb807ef --- /dev/null +++ b/sa_profile/dcamera.cfg @@ -0,0 +1,9 @@ +{ + "services" : [{ + "name" : "dcamera", + "path" : ["/system/bin/sa_main","/system/profile/dcamera.xml"], + "uid" : "system", + "gid" : ["system"], + "ondemand" : true + }] +} \ No newline at end of file diff --git a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp index 888708d87df08381cd3d3325d610c84e85ac4e06..a968898c91be6ab10c92be2c393b8f8943212007 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -116,7 +116,8 @@ int32_t DistributedCameraSinkService::ReleaseSink() } } camerasMap_.clear(); - DHLOGI("DistributedCameraSinkService::ReleaseSink success"); + DHLOGI("exit sink sa process."); + exit(0); return DCAMERA_OK; } diff --git a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp index e0ea205c992f1972659f841580819ca93b24666c..3da2ed457f7bb489ff758a3c352b600d4af2de32 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_service.cpp @@ -23,6 +23,7 @@ #include "system_ability_definition.h" #include "anonymous_string.h" +#include "dcamera_service_state_listener.h" #include "dcamera_source_service_ipc.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" @@ -101,6 +102,8 @@ int32_t DistributedCameraSourceService::ReleaseSource() return ret; } listener_ = nullptr; + DHLOGI("exit source sa process."); + exit(0); return DCAMERA_OK; } diff --git a/services/channel/include/dcamera_softbus_adapter.h b/services/channel/include/dcamera_softbus_adapter.h index c104f563ff10e296dab7b22060169326682aca36..999838f2c9c2ad53ed4c1f511ffba4c30dc7be3a 100644 --- a/services/channel/include/dcamera_softbus_adapter.h +++ b/services/channel/include/dcamera_softbus_adapter.h @@ -73,7 +73,7 @@ private: private: std::mutex optLock_; - const string PKG_NAME = "ohos.dhardware"; + const string PKG_NAME = "ohos.dhardware.dcamera"; static const uint32_t DCAMERA_SESSION_NAME_MAX_LEN = 128; map sessListeners_; std::map sessionTotal_;