fix pr issue for bidirection comm base

Signed-off-by: zhubingwei <zhubingwei@huawei.com>
Change-Id: Id362c98dd3802a6bb5de5397502553b2dda407bd
This commit is contained in:
zhubingwei
2024-07-11 13:17:24 +08:00
parent fbc2974564
commit bce23b0288
10 changed files with 40 additions and 29 deletions
@@ -123,6 +123,5 @@ napi_value JsUIServiceHostProxy::OnSendData(napi_env env, NapiCallbackInfo& info
}
return CreateJsUndefined(env);
}
}
}
@@ -77,6 +77,7 @@ napi_value JsUIServiceProxy::SendData(napi_env env, napi_callback_info info)
napi_value JsUIServiceProxy::OnSendData(napi_env env, NapiCallbackInfo& info)
{
if (proxy_ == nullptr || hostProxy_ == nullptr) {
TAG_LOGE(AAFwkTag::UISERVC_EXT, "proxy_ or hostProxy_ is null");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
return CreateJsUndefined(env);
}
@@ -100,6 +101,5 @@ napi_value JsUIServiceProxy::OnSendData(napi_env env, NapiCallbackInfo& info)
}
return CreateJsUndefined(env);
}
}
}
@@ -19,14 +19,13 @@
#include "ability_manager_ipc_interface_code.h"
#include "ipc_types.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace AAFwk {
using namespace AbilityRuntime;
UIServiceHostProxy::UIServiceHostProxy(const sptr<IRemoteObject>& impl)
:IRemoteProxy<IUIServiceHost>(impl)
:IRemoteProxy<IUIServiceHost>(impl)
{
TAG_LOGI(AAFwkTag::UISERVC_EXT, "called");
}
@@ -59,9 +58,7 @@ int32_t UIServiceHostProxy::SendData(OHOS::AAFwk::WantParams &data)
TAG_LOGE(AAFwkTag::UISERVC_EXT, "SendRequest failed, error %{public}d", error);
return static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
}
int32_t ret = reply.ReadInt32();
return ret;
}
return ERR_OK;
}
}
}
@@ -15,7 +15,6 @@
#include "ui_service_host_stub.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace AAFwk {
@@ -52,7 +51,7 @@ int UIServiceHostStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messa
int32_t UIServiceHostStub::OnSendData(MessageParcel& data, MessageParcel& reply)
{
AAFwk::WantParams* wantParams = data.ReadParcelable<AAFwk::WantParams>();
std::unique_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
if (wantParams == nullptr) {
TAG_LOGE(AAFwkTag::UISERVC_EXT, "UIServiceHostStub::OnSendData, read WantParams failed");
return ERR_INVALID_VALUE;
@@ -64,6 +63,5 @@ int32_t UIServiceHostStub::OnSendData(MessageParcel& data, MessageParcel& reply)
}
return NO_ERROR;
}
}
}
@@ -19,7 +19,6 @@
#include "ability_manager_ipc_interface_code.h"
#include "ipc_types.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace AAFwk {
@@ -51,7 +50,7 @@ int32_t UIServiceProxy::SendData(sptr<IRemoteObject> hostProxy, OHOS::AAFwk::Wan
return static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
}
if (!parcelData.WriteRemoteObject(hostProxy)) {
TAG_LOGE(AAFwkTag::UISERVC_EXT, "Write hostProxy failed.");
TAG_LOGE(AAFwkTag::UISERVC_EXT, "Write hostProxy failed.");
return static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
}
if (!parcelData.WriteParcelable(&data)) {
@@ -68,9 +67,7 @@ int32_t UIServiceProxy::SendData(sptr<IRemoteObject> hostProxy, OHOS::AAFwk::Wan
TAG_LOGE(AAFwkTag::UISERVC_EXT, "SendRequest failed, error %{public}d", error);
return static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
}
int32_t ret = reply.ReadInt32();
return ret;
}
return ERR_OK;
}
}
}
@@ -15,7 +15,6 @@
#include "ui_service_stub.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace AAFwk {
@@ -57,7 +56,7 @@ int32_t UIServiceStub::OnSendData(MessageParcel& data, MessageParcel& reply)
TAG_LOGE(AAFwkTag::UISERVC_EXT, "UIServiceStub::OnSendData, read hostProxy failed");
return ERR_INVALID_VALUE;
}
AAFwk::WantParams* wantParams = data.ReadParcelable<AAFwk::WantParams>();
std::unique_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
if (wantParams == nullptr) {
TAG_LOGE(AAFwkTag::UISERVC_EXT, "UIServiceStub::OnSendData, read WantParams failed");
return ERR_INVALID_VALUE;
@@ -69,6 +68,5 @@ int32_t UIServiceStub::OnSendData(MessageParcel& data, MessageParcel& reply)
}
return NO_ERROR;
}
}
}
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024 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_RUNTIME_UISERVICEEXTENSION_CONNECTION_CONSTANTS_H
#define OHOS_ABILITY_RUNTIME_UISERVICEEXTENSION_CONNECTION_CONSTANTS_H
namespace OHOS {
namespace AbilityRuntime {
constexpr const char* UISERVICEHOSTPROXY_KEY = "ohos.ability.params.UIServiceHostProxy";
} // namespace AbilityRuntime
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_UISERVICEEXTENSION_CONNECTION_CONSTANTS_H
@@ -13,14 +13,14 @@
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_PROXY_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_PROXY_H
#include "iremote_broker.h"
#include "iremote_object.h"
#include "iremote_proxy.h"
#include "ui_service_host_interface.h"
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_PROXY_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_PROXY_H
namespace OHOS {
namespace AAFwk {
@@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_STUB_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_STUB_H
#include <map>
@@ -21,9 +23,6 @@
#include "message_parcel.h"
#include "ui_service_host_interface.h"
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_STUB_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_HOST_STUB_H
namespace OHOS {
namespace AAFwk {
@@ -12,14 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_STUB_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_STUB_H
#include <iremote_object.h>
#include <iremote_stub.h>
#include "ui_service_interface.h"
#ifndef OHOS_ABILITY_RUNTIME_UI_SERVICE_STUB_H
#define OHOS_ABILITY_RUNTIME_UI_SERVICE_STUB_H
namespace OHOS {
namespace AAFwk {