mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-19 14:43:36 -04:00
!2246 support update SA dialog
Merge pull request !2246 from zhanghaibo/updateDialog
This commit is contained in:
@@ -480,6 +480,20 @@ void AceContainer::OnNewRequest(int32_t instanceId, const std::string& data)
|
||||
}
|
||||
}
|
||||
|
||||
void AceContainer::OnDialogUpdated(int32_t instanceId, const std::string& data)
|
||||
{
|
||||
auto container = AceEngine::Get().GetContainer(instanceId);
|
||||
if (!container) {
|
||||
return;
|
||||
}
|
||||
|
||||
ContainerScope scope(instanceId);
|
||||
auto front = container->GetFrontend();
|
||||
if (front) {
|
||||
front->OnDialogUpdated(data);
|
||||
}
|
||||
}
|
||||
|
||||
void AceContainer::InitializeCallback()
|
||||
{
|
||||
ACE_FUNCTION_TRACE();
|
||||
|
||||
@@ -233,6 +233,7 @@ public:
|
||||
static void OnRemoteTerminated(int32_t instanceId);
|
||||
static void OnConfigurationUpdated(int32_t instanceId, const std::string& configuration);
|
||||
static void OnNewRequest(int32_t instanceId, const std::string& data);
|
||||
static void OnDialogUpdated(int32_t instanceId, const std::string& data);
|
||||
static void AddAssetPath(int32_t instanceId, const std::string& packagePath, const std::vector<std::string>& paths);
|
||||
static void AddLibPath(int32_t instanceId, const std::string& libPath);
|
||||
static void SetView(AceView* view, double density, int32_t width, int32_t height, int32_t windowId,
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
|
||||
int CancelDialog(int id) override;
|
||||
|
||||
int UpdateDialog(int id, const std::string& data) override;
|
||||
|
||||
/**
|
||||
* GetEventHandler, get the ui_service manager service's handler.
|
||||
*
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
virtual int CancelDialog(int id);
|
||||
|
||||
virtual int UpdateDialog(int id, const std::string& data);
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel& data);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
using RequestFuncType = int (UIServiceMgrStub ::*)(MessageParcel& data, MessageParcel& reply);
|
||||
int ShowDialogInner(MessageParcel& data, MessageParcel& reply);
|
||||
int CancelDialogInner(MessageParcel& data, MessageParcel& reply);
|
||||
int UpdateDialogInner(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
};
|
||||
} // namespace Ace
|
||||
|
||||
@@ -382,6 +382,24 @@ int UIMgrService::CancelDialog(int id)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int UIMgrService::UpdateDialog(int id, const std::string& data)
|
||||
{
|
||||
auto updateDialogCallback = [id, data]() {
|
||||
HILOG_INFO("Update dialog id: %{public}d", id);
|
||||
auto container = Platform::AceContainer::GetContainer(id);
|
||||
if (!container) {
|
||||
HILOG_INFO("Container(%{public}d) not found.", id);
|
||||
return;
|
||||
}
|
||||
Platform::AceContainer::OnDialogUpdated(id, data);
|
||||
};
|
||||
if (!handler_->PostTask(updateDialogCallback)) {
|
||||
return UI_SERVICE_POST_TASK_FAILED;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void UIMgrService::OnStart()
|
||||
{
|
||||
if (state_ == UIServiceRunningState::STATE_RUNNING) {
|
||||
|
||||
@@ -175,6 +175,29 @@ ErrCode UIServiceMgrClient::CancelDialog(int32_t id)
|
||||
return doms->CancelDialog(id);
|
||||
}
|
||||
|
||||
ErrCode UIServiceMgrClient::UpdateDialog(int32_t id, const std::string& data)
|
||||
{
|
||||
if (id < 0) {
|
||||
HILOG_INFO("invalid parameter");
|
||||
return UI_SERVICE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (remoteObject_ == nullptr) {
|
||||
ErrCode err = Connect();
|
||||
if (err != ERR_OK) {
|
||||
HILOG_ERROR("%{private}s:fail to connect UIMgrService", __func__);
|
||||
return UI_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
sptr<IUIServiceMgr> doms = iface_cast<IUIServiceMgr>(remoteObject_);
|
||||
if (doms == nullptr) {
|
||||
HILOG_ERROR("doms is nullptr");
|
||||
return UI_SERVICE_GET_PROXY_FAILED;
|
||||
}
|
||||
return doms->UpdateDialog(id, data);
|
||||
}
|
||||
|
||||
ErrCode UIServiceMgrClient::ShowAppPickerDialog(
|
||||
const AAFwk::Want& want, const std::vector<AppExecFwk::AbilityInfo>& abilityInfos, int32_t userId)
|
||||
{
|
||||
|
||||
@@ -268,5 +268,33 @@ int UIServiceMgrProxy::CancelDialog(int id)
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int UIServiceMgrProxy::UpdateDialog(int id, const std::string& data)
|
||||
{
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(dataParcel)) {
|
||||
return UI_SERVICE_PROXY_INNER_ERR;
|
||||
}
|
||||
|
||||
if (!dataParcel.WriteInt32(id)) {
|
||||
HILOG_ERROR("fail to WriteString id");
|
||||
return INVALID_DATA;
|
||||
}
|
||||
|
||||
if (!dataParcel.WriteString(data)) {
|
||||
HILOG_ERROR("fail to WriteString data");
|
||||
return INVALID_DATA;
|
||||
}
|
||||
|
||||
int error = Remote()->SendRequest(IUIServiceMgr::UPDATE_DIALOG, dataParcel, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Request fail, error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -32,6 +32,7 @@ UIServiceMgrStub::UIServiceMgrStub()
|
||||
requestFuncMap_[RETURN_REQUEST] = &UIServiceMgrStub::ReturnRequestInner;
|
||||
requestFuncMap_[SHOW_DIALOG] = &UIServiceMgrStub::ShowDialogInner;
|
||||
requestFuncMap_[CANCEL_DIALOG] = &UIServiceMgrStub::CancelDialogInner;
|
||||
requestFuncMap_[UPDATE_DIALOG] = &UIServiceMgrStub::UpdateDialogInner;
|
||||
}
|
||||
|
||||
UIServiceMgrStub::~UIServiceMgrStub()
|
||||
@@ -167,5 +168,14 @@ int UIServiceMgrStub::CancelDialogInner(MessageParcel &data, MessageParcel &repl
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int UIServiceMgrStub::UpdateDialogInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t id = data.ReadInt32();
|
||||
std::string updateData = data.ReadString();
|
||||
int32_t result = UpdateDialog(id, updateData);
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
}
|
||||
void OnRemoteTerminated() override {}
|
||||
void OnNewRequest(const std::string& data) override {}
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
void OnNewWant(const std::string& data) override {}
|
||||
void CallRouterBack() override {}
|
||||
void OnSurfaceChanged(int32_t width, int32_t height) override;
|
||||
|
||||
@@ -113,6 +113,7 @@ public:
|
||||
bool OnRestoreData(const std::string& data) override;
|
||||
void OnRemoteTerminated() override;
|
||||
void OnNewRequest(const std::string& data) override;
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
void OnMemoryLevel(const int32_t level) override;
|
||||
void CallRouterBack() override;
|
||||
void OnSurfaceChanged(int32_t width, int32_t height) override;
|
||||
|
||||
@@ -442,6 +442,11 @@ void FrontendDelegateImpl::OnNewRequest(const std::string& data)
|
||||
FireSyncEvent("_root", std::string("\"onNewRequest\","), data);
|
||||
}
|
||||
|
||||
void FrontendDelegateImpl::OnDialogUpdated(const std::string& data)
|
||||
{
|
||||
FireSyncEvent("_root", std::string("\"onDialogUpdated\","), data);
|
||||
}
|
||||
|
||||
void FrontendDelegateImpl::CallPopPage()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
@@ -234,6 +234,7 @@ public:
|
||||
void OnSaveData(std::string& data);
|
||||
bool OnRestoreData(const std::string& data);
|
||||
void OnNewRequest(const std::string& data);
|
||||
void OnDialogUpdated(const std::string& data);
|
||||
void OnMemoryLevel(const int32_t level);
|
||||
void OnNewWant(const std::string& data);
|
||||
void CallPopPage();
|
||||
|
||||
@@ -701,6 +701,13 @@ void JsFrontend::OnNewRequest(const std::string& data)
|
||||
}
|
||||
}
|
||||
|
||||
void JsFrontend::OnDialogUpdated(const std::string& data)
|
||||
{
|
||||
if (delegate_) {
|
||||
delegate_->OnDialogUpdated(data);
|
||||
}
|
||||
}
|
||||
|
||||
void JsFrontend::CallRouterBack()
|
||||
{
|
||||
if (delegate_) {
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
|
||||
void OnMemoryLevel(const int32_t level) override {}
|
||||
void OnNewRequest(const std::string& data) override;
|
||||
void OnDialogUpdated(const std::string& data) override;
|
||||
void OnNewWant(const std::string& data) override {}
|
||||
void CallRouterBack() override;
|
||||
void SetColorMode(ColorMode colorMode) override;
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
bool OnRestoreData(const std::string& data) override;
|
||||
void OnRemoteTerminated() override;
|
||||
void OnNewRequest(const std::string& data) override;
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
void OnMemoryLevel(const int32_t level) override;
|
||||
void SetColorMode(ColorMode colorMode) override;
|
||||
void CallRouterBack() override;
|
||||
|
||||
@@ -131,6 +131,7 @@ public:
|
||||
void OnRestoreAbilityState (const std::string& data) override {}
|
||||
void OnRemoteTerminated() override {}
|
||||
void OnNewRequest(const std::string& data) override {}
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
void OnNewWant(const std::string& data) override {}
|
||||
void CallRouterBack() override {}
|
||||
void OnSurfaceChanged(int32_t width, int32_t height) override {}
|
||||
|
||||
@@ -166,6 +166,8 @@ public:
|
||||
|
||||
virtual void OnNewWant(const std::string& data) = 0;
|
||||
|
||||
virtual void OnDialogUpdated(const std::string& data) = 0;
|
||||
|
||||
// call router back
|
||||
virtual void CallRouterBack() = 0;
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
|
||||
void OnNewRequest(const std::string& data) override;
|
||||
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
|
||||
void OnNewWant(const std::string& data) override {}
|
||||
|
||||
void CallRouterBack() override;
|
||||
|
||||
@@ -192,6 +192,7 @@ public:
|
||||
}
|
||||
void OnRemoteTerminated() override {}
|
||||
void OnNewRequest(const std::string& data) override {}
|
||||
void OnDialogUpdated(const std::string& data) override {}
|
||||
void OnNewWant(const std::string& data) override {}
|
||||
void CallRouterBack() override {}
|
||||
void OnSurfaceChanged(int32_t width, int32_t height) override {}
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
|
||||
ErrCode CancelDialog(int32_t id);
|
||||
|
||||
ErrCode UpdateDialog(int32_t id, const std::string& data);
|
||||
|
||||
ErrCode ShowAppPickerDialog(
|
||||
const AAFwk::Want& want, const std::vector<AppExecFwk::AbilityInfo>& abilityInfos, int32_t userId);
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
virtual int CancelDialog(int id) = 0;
|
||||
|
||||
virtual int UpdateDialog(int id, const std::string& data) = 0;
|
||||
|
||||
enum {
|
||||
// ipc id 1-1000 for kit
|
||||
// ipc id for RegisterCallBack (1)
|
||||
@@ -76,6 +78,7 @@ public:
|
||||
RETURN_REQUEST,
|
||||
SHOW_DIALOG,
|
||||
CANCEL_DIALOG,
|
||||
UPDATE_DIALOG,
|
||||
};
|
||||
};
|
||||
} // namespace Ace
|
||||
|
||||
Reference in New Issue
Block a user