合并受阻
感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接。
Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.


/*
- Copyright (c) 2026 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_ABILITY_BASE_WANT_FD_SCOPE_H
#define OHOS_ABILITY_BASE_WANT_FD_SCOPE_H
#include "want.h"
namespace OHOS {
namespace AAFwk {
class WantFdScope final {
public:
explicit WantFdScope(Want &want) : want_(&want) {}
explicit WantFdScope(Want *want) : want_(want) {}
~WantFdScope()
{
if (want_ != nullptr) {
want_->CloseAllFd();
}
}
WantFdScope(const WantFdScope &) = delete;
WantFdScope &operator=(const WantFdScope &) = delete;
WantFdScope(WantFdScope &&other) noexcept : want_(other.want_)
{
other.want_ = nullptr;
}
WantFdScope &operator=(WantFdScope &&) = delete;
void Release() noexcept
{
want_ = nullptr;
}
void Strip()
{
if (want_ != nullptr) {
want_->RemoveAllFd();
}
}
private:
Want *want_;
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_ABILITY_BASE_WANT_FD_SCOPE_H


bool Want::AssignDup(const Want &src)
{
operation_ = src.operation_;
bool ret = parameters_.AssignDup(src.GetParams());
ABILITYBASE_LOGI("Want::AssignDup result:%{public}d", ret);
return ret;
}
bool Want::DupCopy(const Want &src, Want &out)
{
return WantParams::DupCopy(src.GetParams(), out.parameters_);
}


bool WantParams::TryDupAllFd()
{
ABILITYBASE_LOGI("TryDupAllFd called, fd count: %{public}zu", fds_.size());
std::vector<std::pair<std::string, int32_t>> staged;
for (const auto &it : fds_) {
if (it.second < 0) {
continue;
}
int32_t dupFd = dup(it.second);
if (dupFd < 0) {
ABILITYBASE_LOGE("dup fd failed, key: %{public}s oldFd:%{public}d", it.first.c_str(), it.second);
for (const auto &s : staged) {
close(s.second);
}
return false;
}
ABILITYBASE_LOGI("dup fd key:%{public}s oldFd:%{public}d newFd:%{public}d", it.first.c_str(), it.second, dupFd);
staged.emplace_back(it.first, dupFd);
}
for (const auto &s : staged) {
WantParams wp;
wp.SetParam(TYPE_PROPERTY, String::Box(FD));
wp.SetParam(VALUE_PROPERTY, Integer::Box(s.second));
sptrAAFwk::IWantParams pWantParams = AAFwk::WantParamWrapper::Box(wp);
params_[s.first] = pWantParams;
fds_[s.first] = s.second;
}
return true;
}
void WantParams::DupAllFd()
{
(void)TryDupAllFd();
}
bool WantParams::AssignDup(const WantParams &src)
{
if (this == &src) {
return TryDupAllFd();
}
*this = src;
if (!TryDupAllFd()) {
RemoveAllFd();
return false;
}
return true;
}
bool WantParams::DupCopy(const WantParams &src, WantParams &out)
{
if (&out == &src) {
return out.TryDupAllFd();
}
out = src;
if (!out.TryDupAllFd()) {
out.RemoveAllFd();
return false;
}
return true;
}


IssueNo: https://gitcode.com/openharmony/ability_ability_base/issues/1228
Description:
稳定性自检:
安全编码自检:
TDD Result:
XTS Result:
是否已执行L0用例