mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
!3428 快速修复代码优化_异步方式返回LoadPatch的返回值
Merge pull request !3428 from 张亚菲/zyf
This commit is contained in:
@@ -1932,28 +1932,32 @@ void MainThread::CheckMainThreadIsAlive()
|
||||
}
|
||||
#endif // ABILITY_LIBRARY_LOADER
|
||||
|
||||
int32_t MainThread::ScheduleNotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t MainThread::ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("ScheduleNotifyLoadRepairPatch function called.");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak, bundleName]() {
|
||||
auto task = [weak, bundleName, callback]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr || appThread->application_ == nullptr) {
|
||||
HILOG_ERROR("ScheduleNotifyLoadRepairPatch, app thread or application is nullptr.");
|
||||
if (appThread == nullptr || appThread->application_ == nullptr || callback == nullptr) {
|
||||
HILOG_ERROR("ScheduleNotifyLoadRepairPatch, parameter is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
std::vector<std::pair<std::string, std::string>> hqfFilePair;
|
||||
if (appThread->GetHqfFileAndHapPath(bundleName, hqfFilePair)) {
|
||||
for (auto it = hqfFilePair.begin(); it != hqfFilePair.end(); it++) {
|
||||
HILOG_INFO("ScheduleNotifyLoadRepairPatch, LoadPatch, hqfFile: %{private}s, hapPath: %{private}s.",
|
||||
it->first.c_str(), it->second.c_str());
|
||||
appThread->application_->NotifyLoadRepairPatch(it->first, it->second);
|
||||
ret = appThread->application_->NotifyLoadRepairPatch(it->first, it->second);
|
||||
}
|
||||
} else {
|
||||
HILOG_DEBUG("ScheduleNotifyLoadRepairPatch, There's no hqfFile need to load.");
|
||||
}
|
||||
|
||||
callback->OnLoadPatchDone(ret ? NO_ERROR : ERR_INVALID_OPERATION);
|
||||
};
|
||||
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task)) {
|
||||
HILOG_ERROR("ScheduleNotifyLoadRepairPatch, Post task failed.");
|
||||
@@ -1963,18 +1967,19 @@ int32_t MainThread::ScheduleNotifyLoadRepairPatch(const std::string &bundleName)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t MainThread::ScheduleNotifyHotReloadPage()
|
||||
int32_t MainThread::ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak]() {
|
||||
auto task = [weak, callback]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr || appThread->application_ == nullptr) {
|
||||
HILOG_ERROR("app thread or application is nullptr.");
|
||||
if (appThread == nullptr || appThread->application_ == nullptr || callback == nullptr) {
|
||||
HILOG_ERROR("parameter is nullptr.");
|
||||
return;
|
||||
}
|
||||
appThread->application_->NotifyHotReloadPage();
|
||||
auto ret = appThread->application_->NotifyHotReloadPage();
|
||||
callback->OnReloadPageDone(ret ? NO_ERROR : ERR_INVALID_OPERATION);
|
||||
};
|
||||
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task)) {
|
||||
HILOG_ERROR("Post task failed.");
|
||||
@@ -2032,27 +2037,31 @@ bool MainThread::GetHqfFileAndHapPath(const std::string &bundleName,
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t MainThread::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t MainThread::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("ScheduleNotifyUnLoadRepairPatch function called.");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak, bundleName]() {
|
||||
auto task = [weak, bundleName, callback]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr || appThread->application_ == nullptr) {
|
||||
HILOG_ERROR("ScheduleNotifyUnLoadRepairPatch, app thread or application is nullptr.");
|
||||
if (appThread == nullptr || appThread->application_ == nullptr || callback == nullptr) {
|
||||
HILOG_ERROR("ScheduleNotifyUnLoadRepairPatch, parameter is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
std::vector<std::pair<std::string, std::string>> hqfFilePair;
|
||||
if (appThread->GetHqfFileAndHapPath(bundleName, hqfFilePair)) {
|
||||
for (auto it = hqfFilePair.begin(); it != hqfFilePair.end(); it++) {
|
||||
HILOG_INFO("ScheduleNotifyUnLoadRepairPatch, UnloadPatch, hqfFile: %{private}s.", it->first.c_str());
|
||||
appThread->application_->NotifyUnLoadRepairPatch(it->first);
|
||||
ret = appThread->application_->NotifyUnLoadRepairPatch(it->first);
|
||||
}
|
||||
} else {
|
||||
HILOG_DEBUG("ScheduleNotifyUnLoadRepairPatch, There's no hqfFile need to unload.");
|
||||
}
|
||||
|
||||
callback->OnUnloadPatchDone(ret ? NO_ERROR : ERR_INVALID_OPERATION);
|
||||
};
|
||||
if (mainHandler_ == nullptr || !mainHandler_->PostTask(task)) {
|
||||
HILOG_ERROR("ScheduleNotifyUnLoadRepairPatch, Post task failed.");
|
||||
|
||||
@@ -662,34 +662,34 @@ void OHOSApplication::SetExtensionTypeMap(std::map<int32_t, std::string> map)
|
||||
extensionTypeMap_ = map;
|
||||
}
|
||||
|
||||
void OHOSApplication::NotifyLoadRepairPatch(const std::string &hqfFile, const std::string &hapPath)
|
||||
bool OHOSApplication::NotifyLoadRepairPatch(const std::string &hqfFile, const std::string &hapPath)
|
||||
{
|
||||
if (runtime_ == nullptr) {
|
||||
HILOG_DEBUG("runtime is nullptr.");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
runtime_->LoadRepairPatch(hqfFile, hapPath);
|
||||
return runtime_->LoadRepairPatch(hqfFile, hapPath);
|
||||
}
|
||||
|
||||
void OHOSApplication::NotifyHotReloadPage()
|
||||
bool OHOSApplication::NotifyHotReloadPage()
|
||||
{
|
||||
if (runtime_ == nullptr) {
|
||||
HILOG_DEBUG("runtime is nullptr.");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
runtime_->NotifyHotReloadPage();
|
||||
return runtime_->NotifyHotReloadPage();
|
||||
}
|
||||
|
||||
void OHOSApplication::NotifyUnLoadRepairPatch(const std::string &hqfFile)
|
||||
bool OHOSApplication::NotifyUnLoadRepairPatch(const std::string &hqfFile)
|
||||
{
|
||||
if (runtime_ == nullptr) {
|
||||
HILOG_DEBUG("runtime is nullptr.");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
runtime_->UnLoadRepairPatch(hqfFile);
|
||||
return runtime_->UnLoadRepairPatch(hqfFile);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
#include "ability_constants.h"
|
||||
#include "connect_server_manager.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "event_handler.h"
|
||||
#include "file_path_utils.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "hdc_register.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hot_reloader.h"
|
||||
@@ -170,25 +170,25 @@ public:
|
||||
static_cast<ArkNativeEngine*>(nativeEngine_.get()), exportObj);
|
||||
}
|
||||
|
||||
void LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath) override
|
||||
bool LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath) override
|
||||
{
|
||||
HILOG_DEBUG("LoadRepairPatch function called.");
|
||||
if (vm_ == nullptr) {
|
||||
HILOG_ERROR("LoadRepairPatch, vm is nullptr.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
AbilityRuntime::RuntimeExtractor extractor(hqfFile);
|
||||
if (!extractor.Init()) {
|
||||
HILOG_ERROR("LoadRepairPatch, Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (fileNames.empty()) {
|
||||
HILOG_WARN("LoadRepairPatch, There's no abc file in hqf %{private}s.", hqfFile.c_str());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &fileName : fileNames) {
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
std::ostringstream outStream;
|
||||
if (!extractor.ExtractByName(fileName, outStream)) {
|
||||
HILOG_ERROR("LoadRepairPatch, Extract %{public}s failed.", patchFile.c_str());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto &outStr = outStream.str();
|
||||
@@ -208,31 +208,33 @@ public:
|
||||
bool ret = panda::JSNApi::LoadPatch(vm_, patchFile, buffer.data(), buffer.size(), baseFile);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("LoadRepairPatch, LoadPatch failed.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("LoadRepairPatch, Load patch %{private}s succeed.", patchFile.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnLoadRepairPatch(const std::string& hqfFile) override
|
||||
bool UnLoadRepairPatch(const std::string& hqfFile) override
|
||||
{
|
||||
HILOG_DEBUG("UnLoadRepairPatch function called.");
|
||||
if (vm_ == nullptr) {
|
||||
HILOG_ERROR("UnLoadRepairPatch vm is nullptr.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
AbilityRuntime::RuntimeExtractor extractor(hqfFile);
|
||||
if (!extractor.Init()) {
|
||||
HILOG_ERROR("UnLoadRepairPatch, Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (fileNames.empty()) {
|
||||
HILOG_WARN("UnLoadRepairPatch, There's no abc file in hqf %{private}s.", hqfFile.c_str());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &fileName : fileNames) {
|
||||
@@ -241,16 +243,19 @@ public:
|
||||
bool ret = panda::JSNApi::UnloadPatch(vm_, patchFile);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("UnLoadRepairPatch, UnLoadPatch failed.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("UnLoadRepairPatch, UnLoad patch %{private}s succeed.", patchFile.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotifyHotReloadPage() override
|
||||
bool NotifyHotReloadPage() override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
Ace::HotReloader::HotReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
/**
|
||||
* @brief Get specified type names in a zip file.
|
||||
* @param fileNames Indicates the obtained file names in zip.
|
||||
* @param suffix Indicates the suffix of file.
|
||||
*/
|
||||
void GetSpecifiedTypeFiles(std::vector<std::string> &fileNames, const std::string &suffix);
|
||||
/**
|
||||
|
||||
@@ -201,7 +201,6 @@ void RuntimeExtractor::GetSpecifiedTypeFiles(std::vector<std::string> &fileNames
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool RuntimeExtractor::IsStageBasedModel(std::string abilityName)
|
||||
|
||||
@@ -73,6 +73,8 @@ ohos_shared_library("app_manager") {
|
||||
"src/appmgr/process_data.cpp",
|
||||
"src/appmgr/process_info.cpp",
|
||||
"src/appmgr/profile.cpp",
|
||||
"src/appmgr/quick_fix_callback_proxy.cpp",
|
||||
"src/appmgr/quick_fix_callback_stub.cpp",
|
||||
"src/appmgr/render_scheduler_host.cpp",
|
||||
"src/appmgr/render_scheduler_proxy.cpp",
|
||||
"src/appmgr/running_process_info.cpp",
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "system_memory_attr.h"
|
||||
#include "iapplication_state_observer.h"
|
||||
#include "iconfiguration_observer.h"
|
||||
#include "iquick_fix_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@@ -262,25 +263,28 @@ public:
|
||||
* @brief Notify application load patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyLoadRepairPatch(const std::string &bundleName) = 0;
|
||||
virtual int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Notify application reload page.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when HotReload finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyHotReloadPage(const std::string &bundleName) = 0;
|
||||
virtual int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Notify application unload patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when UnloadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyUnLoadRepairPatch(const std::string &bundleName) = 0;
|
||||
virtual int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
/**
|
||||
|
||||
@@ -246,11 +246,11 @@ public:
|
||||
|
||||
bool GetAppRunningStateByBundleName(const std::string &bundleName) override;
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName) override;
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
int32_t SetContinuousTaskProcess(int32_t pid, bool isContinuousTask) override;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "app_launch_data.h"
|
||||
#include "configuration.h"
|
||||
#include "hap_module_info.h"
|
||||
#include "iquick_fix_callback.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -143,24 +144,29 @@ public:
|
||||
* @brief Notify application load patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName) = 0;
|
||||
virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Notify application reload page.
|
||||
*
|
||||
* @param callback called when HotReload finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyHotReloadPage() = 0;
|
||||
virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Notify application unload patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when UnloadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName) = 0;
|
||||
virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
enum class Message {
|
||||
SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
|
||||
|
||||
@@ -142,11 +142,13 @@ public:
|
||||
|
||||
virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override;
|
||||
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t ScheduleNotifyHotReloadPage() override;
|
||||
int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class IQuickFixCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.QuickFixCallback");
|
||||
|
||||
virtual void OnLoadPatchDone(int32_t resultCode) = 0;
|
||||
virtual void OnUnloadPatchDone(int32_t resultCode) = 0;
|
||||
virtual void OnReloadPageDone(int32_t resultCode) = 0;
|
||||
|
||||
enum QuickFixCallbackCmd {
|
||||
ON_NOTIFY_LOAD_PATCH = 0, // ipc id for OnLoadPatchDone
|
||||
ON_NOTIFY_UNLOAD_PATCH = 1, // ipc id for OnUnloadPatchDone
|
||||
ON_NOTIFY_RELOAD_PAGE = 2, // ipc id for OnReloadPageDone
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_IQUICK_FIX_CALLBACK_H
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_PROXY_H
|
||||
#define OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_PROXY_H
|
||||
|
||||
#include "iquick_fix_callback.h"
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class QuickFixCallbackProxy : public IRemoteProxy<IQuickFixCallback> {
|
||||
public:
|
||||
explicit QuickFixCallbackProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IQuickFixCallback>(impl) {};
|
||||
virtual ~QuickFixCallbackProxy() = default;
|
||||
|
||||
void OnLoadPatchDone(int32_t resultCode) override;
|
||||
void OnUnloadPatchDone(int32_t resultCode) override;
|
||||
void OnReloadPageDone(int32_t resultCode) override;
|
||||
|
||||
private:
|
||||
bool SendRequestWithCmd(uint32_t code, MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
static inline BrokerDelegator<QuickFixCallbackProxy> delegator_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_PROXY_H
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_STUB_H
|
||||
#define OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_STUB_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "iquick_fix_callback.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "message_parcel.h"
|
||||
#include "nocopyable.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class QuickFixCallbackStub : public IRemoteStub<IQuickFixCallback> {
|
||||
public:
|
||||
QuickFixCallbackStub();
|
||||
virtual ~QuickFixCallbackStub();
|
||||
|
||||
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
private:
|
||||
int32_t HandleOnLoadPatchDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnUnloadPatchDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleOnReloadPageDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using RequestFuncType = int32_t (QuickFixCallbackStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(QuickFixCallbackStub);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_QUICK_FIX_CALLBACK_STUB_H
|
||||
@@ -859,7 +859,7 @@ bool AppMgrProxy::GetAppRunningStateByBundleName(const std::string &bundleName)
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrProxy::NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("NotifyLoadRepairPatch, function called.");
|
||||
@@ -874,6 +874,11 @@ int32_t AppMgrProxy::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("NotifyLoadRepairPatch, Remote is nullptr.");
|
||||
@@ -892,7 +897,7 @@ int32_t AppMgrProxy::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::NotifyHotReloadPage(const std::string &bundleName)
|
||||
int32_t AppMgrProxy::NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -907,6 +912,11 @@ int32_t AppMgrProxy::NotifyHotReloadPage(const std::string &bundleName)
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr.");
|
||||
@@ -965,7 +975,7 @@ int32_t AppMgrProxy::SetContinuousTaskProcess(int32_t pid, bool isContinuousTask
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t AppMgrProxy::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrProxy::NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -980,6 +990,11 @@ int32_t AppMgrProxy::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Notify unload patch, Remote is nullptr.");
|
||||
|
||||
@@ -520,7 +520,8 @@ int32_t AppMgrStub::HandleNotifyLoadRepairPatch(MessageParcel &data, MessageParc
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
std::string bundleName = data.ReadString();
|
||||
auto ret = NotifyLoadRepairPatch(bundleName);
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
auto ret = NotifyLoadRepairPatch(bundleName, callback);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
@@ -532,7 +533,8 @@ int32_t AppMgrStub::HandleNotifyHotReloadPage(MessageParcel &data, MessageParcel
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
std::string bundleName = data.ReadString();
|
||||
auto ret = NotifyHotReloadPage(bundleName);
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
auto ret = NotifyHotReloadPage(bundleName, callback);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
@@ -559,7 +561,8 @@ int32_t AppMgrStub::HandleNotifyUnLoadRepairPatch(MessageParcel &data, MessagePa
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
std::string bundleName = data.ReadString();
|
||||
auto ret = NotifyUnLoadRepairPatch(bundleName);
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
auto ret = NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -236,14 +236,16 @@ int32_t AppSchedulerHost::HandleNotifyLoadRepairPatch(MessageParcel &data, Messa
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::string bundleName = data.ReadString();
|
||||
ScheduleNotifyLoadRepairPatch(bundleName);
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
ScheduleNotifyLoadRepairPatch(bundleName, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppSchedulerHost::HandleNotifyHotReloadPage(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
ScheduleNotifyHotReloadPage();
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
ScheduleNotifyHotReloadPage(callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -251,7 +253,8 @@ int32_t AppSchedulerHost::HandleNotifyUnLoadRepairPatch(MessageParcel &data, Mes
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::string bundleName = data.ReadString();
|
||||
ScheduleNotifyUnLoadRepairPatch(bundleName);
|
||||
auto callback = iface_cast<IQuickFixCallback>(data.ReadRemoteObject());
|
||||
ScheduleNotifyUnLoadRepairPatch(bundleName, callback);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -380,7 +380,8 @@ void AppSchedulerProxy::ScheduleAcceptWant(const AAFwk::Want &want, const std::s
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
MessageParcel data;
|
||||
@@ -394,6 +395,11 @@ int32_t AppSchedulerProxy::ScheduleNotifyLoadRepairPatch(const std::string &bund
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("ScheduleNotifyLoadRepairPatch, Remote is nullptr");
|
||||
@@ -412,7 +418,7 @@ int32_t AppSchedulerProxy::ScheduleNotifyLoadRepairPatch(const std::string &bund
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyHotReloadPage()
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
MessageParcel data;
|
||||
@@ -421,6 +427,11 @@ int32_t AppSchedulerProxy::ScheduleNotifyHotReloadPage()
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr");
|
||||
@@ -439,7 +450,8 @@ int32_t AppSchedulerProxy::ScheduleNotifyHotReloadPage()
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppSchedulerProxy::ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
MessageParcel data;
|
||||
@@ -453,6 +465,11 @@ int32_t AppSchedulerProxy::ScheduleNotifyUnLoadRepairPatch(const std::string &bu
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) {
|
||||
HILOG_ERROR("Write callback failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Schedule notify unload patch, Remote is nullptr");
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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 "quick_fix_callback_proxy.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "message_parcel.h"
|
||||
#include "parcel_macro_base.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
void QuickFixCallbackProxy::OnLoadPatchDone(int32_t resultCode)
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor());
|
||||
WRITE_PARCEL_AND_RETURN(Int32, data, resultCode);
|
||||
if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
return;
|
||||
}
|
||||
|
||||
void QuickFixCallbackProxy::OnUnloadPatchDone(int32_t resultCode)
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor());
|
||||
WRITE_PARCEL_AND_RETURN(Int32, data, resultCode);
|
||||
if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH, data, reply)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
return;
|
||||
}
|
||||
|
||||
void QuickFixCallbackProxy::OnReloadPageDone(int32_t resultCode)
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
WRITE_PARCEL_AND_RETURN(InterfaceToken, data, QuickFixCallbackProxy::GetDescriptor());
|
||||
WRITE_PARCEL_AND_RETURN(Int32, data, resultCode);
|
||||
if (!SendRequestWithCmd(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE, data, reply)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool QuickFixCallbackProxy::SendRequestWithCmd(uint32_t code, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
auto ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Send request failed with error %{public}d.", ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 "quick_fix_callback_stub.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
QuickFixCallbackStub::QuickFixCallbackStub()
|
||||
{
|
||||
requestFuncMap_[ON_NOTIFY_LOAD_PATCH] = &QuickFixCallbackStub::HandleOnLoadPatchDoneInner;
|
||||
requestFuncMap_[ON_NOTIFY_UNLOAD_PATCH] = &QuickFixCallbackStub::HandleOnUnloadPatchDoneInner;
|
||||
requestFuncMap_[ON_NOTIFY_RELOAD_PAGE] = &QuickFixCallbackStub::HandleOnReloadPageDoneInner;
|
||||
}
|
||||
|
||||
QuickFixCallbackStub::~QuickFixCallbackStub()
|
||||
{
|
||||
requestFuncMap_.clear();
|
||||
}
|
||||
|
||||
int QuickFixCallbackStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
if (data.ReadInterfaceToken() != IQuickFixCallback::GetDescriptor()) {
|
||||
HILOG_ERROR("local descriptor is not equal to remote.");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
auto itFunc = requestFuncMap_.find(code);
|
||||
if (itFunc != requestFuncMap_.end()) {
|
||||
auto requestFunc = itFunc->second;
|
||||
if (requestFunc != nullptr) {
|
||||
return (this->*requestFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_WARN("default case, need check value of code.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int32_t QuickFixCallbackStub::HandleOnLoadPatchDoneInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
OnLoadPatchDone(resultCode);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t QuickFixCallbackStub::HandleOnUnloadPatchDoneInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
OnUnloadPatchDone(resultCode);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t QuickFixCallbackStub::HandleOnReloadPageDoneInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
OnReloadPageDone(resultCode);
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
@@ -38,8 +38,6 @@ ohos_shared_library("quickfix_manager") {
|
||||
|
||||
defines = [ "AMS_LOG_TAG = \"QuickFixService\"" ]
|
||||
|
||||
deps = [ "${ability_runtime_services_path}/common:perm_verification" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_INTERFACE_H
|
||||
#define OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_INTERFACE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "quick_fix_info.h"
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
#include "quick_fix_manager_proxy.h"
|
||||
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "message_parcel.h"
|
||||
#include "permission_verification.h"
|
||||
#include "quick_fix_error_utils.h"
|
||||
#include "quick_fix_util.h"
|
||||
|
||||
@@ -29,10 +29,6 @@ int32_t QuickFixManagerProxy::ApplyQuickFix(const std::vector<std::string> &quic
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyInstallBundlePermission()) {
|
||||
return QUICK_FIX_VERIFY_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
auto bundleQuickFixMgr = QuickFixUtil::GetBundleQuickFixMgrProxy();
|
||||
if (bundleQuickFixMgr == nullptr) {
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
@@ -40,9 +36,11 @@ int32_t QuickFixManagerProxy::ApplyQuickFix(const std::vector<std::string> &quic
|
||||
|
||||
HILOG_DEBUG("hqf file number need to apply: %{public}zu.", quickFixFiles.size());
|
||||
std::vector<std::string> destFiles;
|
||||
if (bundleQuickFixMgr->CopyFiles(quickFixFiles, destFiles) != 0) {
|
||||
auto copyRet = bundleQuickFixMgr->CopyFiles(quickFixFiles, destFiles);
|
||||
if (copyRet != 0) {
|
||||
HILOG_ERROR("Copy files failed.");
|
||||
return QUICK_FIX_COPY_FILES_FAILED;
|
||||
return (copyRet == ERR_BUNDLEMANAGER_QUICK_FIX_PERMISSION_DENIED) ? QUICK_FIX_VERIFY_PERMISSION_FAILED :
|
||||
QUICK_FIX_COPY_FILES_FAILED;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
@@ -80,10 +78,6 @@ int32_t QuickFixManagerProxy::GetApplyedQuickFixInfo(const std::string &bundleNa
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyGetBundleInfoPrivilegedPermission()) {
|
||||
return QUICK_FIX_VERIFY_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(AAFwk::IQuickFixManager::GetDescriptor())) {
|
||||
HILOG_ERROR("GetApplyedQuickFixInfo, Write interface token failed.");
|
||||
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
virtual void NotifyApplicationState(bool isBackground) = 0;
|
||||
virtual void PreloadSystemModule(const std::string& moduleName) = 0;
|
||||
virtual void FinishPreload() = 0;
|
||||
virtual void LoadRepairPatch(const std::string& patchFile, const std::string& baseFile) = 0;
|
||||
virtual void NotifyHotReloadPage() = 0;
|
||||
virtual void UnLoadRepairPatch(const std::string& patchFile) = 0;
|
||||
virtual bool LoadRepairPatch(const std::string& patchFile, const std::string& baseFile) = 0;
|
||||
virtual bool NotifyHotReloadPage() = 0;
|
||||
virtual bool UnLoadRepairPatch(const std::string& patchFile) = 0;
|
||||
|
||||
Runtime(const Runtime&) = delete;
|
||||
Runtime(Runtime&&) = delete;
|
||||
|
||||
@@ -225,11 +225,13 @@ public:
|
||||
*/
|
||||
void CheckMainThreadIsAlive();
|
||||
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t ScheduleNotifyHotReloadPage() override;
|
||||
int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -280,11 +280,11 @@ public:
|
||||
*/
|
||||
void SetExtensionTypeMap(std::map<int32_t, std::string> map);
|
||||
|
||||
void NotifyLoadRepairPatch(const std::string &hqfFile, const std::string &hapPath);
|
||||
bool NotifyLoadRepairPatch(const std::string &hqfFile, const std::string &hapPath);
|
||||
|
||||
void NotifyHotReloadPage();
|
||||
bool NotifyHotReloadPage();
|
||||
|
||||
void NotifyUnLoadRepairPatch(const std::string &hqfFile);
|
||||
bool NotifyUnLoadRepairPatch(const std::string &hqfFile);
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<AbilityLifecycleCallbacks>> abilityLifecycleCallbacks_;
|
||||
|
||||
@@ -151,11 +151,11 @@ public:
|
||||
*/
|
||||
int32_t UpdateConfiguration(const Configuration &config);
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyHotReloadPage();
|
||||
int32_t NotifyHotReloadPage(const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
private:
|
||||
sptr<IAppScheduler> appThread_ = nullptr;
|
||||
|
||||
@@ -242,11 +242,11 @@ public:
|
||||
|
||||
bool GetAppRunningStateByBundleName(const std::string &bundleName) override;
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName) override;
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName) override;
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
int32_t SetContinuousTaskProcess(int32_t pid, bool isContinuousTask) override;
|
||||
|
||||
@@ -551,11 +551,11 @@ public:
|
||||
|
||||
bool GetAppRunningStateByBundleName(const std::string &bundleName);
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName);
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
void HandleFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo);
|
||||
void HandleUnfocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo);
|
||||
|
||||
@@ -162,9 +162,9 @@ public:
|
||||
std::shared_ptr<RenderRecord> OnRemoteRenderDied(const wptr<IRemoteObject> &remote);
|
||||
bool ProcessExitByPid(pid_t pid);
|
||||
bool GetAppRunningStateByBundleName(const std::string &bundleName);
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName);
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
bool IsApplicationFirstForeground(const AppRunningRecord &foregroundingRecord);
|
||||
bool IsApplicationBackground(const std::string &bundleName);
|
||||
bool IsApplicationFirstFocused(const AppRunningRecord &foregroundingRecord);
|
||||
|
||||
@@ -523,11 +523,11 @@ public:
|
||||
void PostTask(std::string msg, int64_t timeOut, const Closure &task);
|
||||
void RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const;
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyHotReloadPage();
|
||||
int32_t NotifyHotReloadPage(const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName);
|
||||
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
|
||||
|
||||
bool IsContinuousTask();
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ int32_t AppLifeCycleDeal::UpdateConfiguration(const Configuration &config)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppLifeCycleDeal::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppLifeCycleDeal::NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("call %{public}s", __func__);
|
||||
@@ -171,10 +171,10 @@ int32_t AppLifeCycleDeal::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
HILOG_ERROR("appThread_ is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appThread_->ScheduleNotifyLoadRepairPatch(bundleName);
|
||||
return appThread_->ScheduleNotifyLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
|
||||
int32_t AppLifeCycleDeal::NotifyHotReloadPage()
|
||||
int32_t AppLifeCycleDeal::NotifyHotReloadPage(const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("call %{public}s", __func__);
|
||||
@@ -182,10 +182,11 @@ int32_t AppLifeCycleDeal::NotifyHotReloadPage()
|
||||
HILOG_ERROR("appThread_ is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appThread_->ScheduleNotifyHotReloadPage();
|
||||
return appThread_->ScheduleNotifyHotReloadPage(callback);
|
||||
}
|
||||
|
||||
int32_t AppLifeCycleDeal::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppLifeCycleDeal::NotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -193,7 +194,7 @@ int32_t AppLifeCycleDeal::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
HILOG_ERROR("appThread_ is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appThread_->ScheduleNotifyUnLoadRepairPatch(bundleName);
|
||||
return appThread_->ScheduleNotifyUnLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -548,24 +548,24 @@ bool AppMgrService::GetAppRunningStateByBundleName(const std::string &bundleName
|
||||
return appMgrServiceInner_->GetAppRunningStateByBundleName(bundleName);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrService::NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
HILOG_ERROR("AppMgrService is not ready.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appMgrServiceInner_->NotifyLoadRepairPatch(bundleName);
|
||||
return appMgrServiceInner_->NotifyLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::NotifyHotReloadPage(const std::string &bundleName)
|
||||
int32_t AppMgrService::NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
HILOG_ERROR("AppMgrService is not ready.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appMgrServiceInner_->NotifyHotReloadPage(bundleName);
|
||||
return appMgrServiceInner_->NotifyHotReloadPage(bundleName, callback);
|
||||
}
|
||||
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
@@ -580,14 +580,14 @@ int32_t AppMgrService::SetContinuousTaskProcess(int32_t pid, bool isContinuousTa
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t AppMgrService::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrService::NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
HILOG_ERROR("AppMgrService is not ready.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appMgrServiceInner_->NotifyUnLoadRepairPatch(bundleName);
|
||||
return appMgrServiceInner_->NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -2799,7 +2799,8 @@ bool AppMgrServiceInner::GetAppRunningStateByBundleName(const std::string &bundl
|
||||
return appRunningManager_->GetAppRunningStateByBundleName(bundleName);
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrServiceInner::NotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -2808,10 +2809,10 @@ int32_t AppMgrServiceInner::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appRunningManager_->NotifyLoadRepairPatch(bundleName);
|
||||
return appRunningManager_->NotifyLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::NotifyHotReloadPage(const std::string &bundleName)
|
||||
int32_t AppMgrServiceInner::NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -2820,7 +2821,7 @@ int32_t AppMgrServiceInner::NotifyHotReloadPage(const std::string &bundleName)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appRunningManager_->NotifyHotReloadPage(bundleName);
|
||||
return appRunningManager_->NotifyHotReloadPage(bundleName, callback);
|
||||
}
|
||||
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
@@ -2849,7 +2850,8 @@ int32_t AppMgrServiceInner::SetContinuousTaskProcess(int32_t pid, bool isContinu
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t AppMgrServiceInner::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppMgrServiceInner::NotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -2858,7 +2860,7 @@ int32_t AppMgrServiceInner::NotifyUnLoadRepairPatch(const std::string &bundleNam
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appRunningManager_->NotifyUnLoadRepairPatch(bundleName);
|
||||
return appRunningManager_->NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -599,7 +599,7 @@ bool AppRunningManager::GetAppRunningStateByBundleName(const std::string &bundle
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppRunningManager::NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -610,7 +610,7 @@ int32_t AppRunningManager::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
const auto &appRecord = item.second;
|
||||
if (appRecord && appRecord->GetBundleName() == bundleName) {
|
||||
HILOG_DEBUG("Notify application [%{public}s] load patch.", appRecord->GetProcessName().c_str());
|
||||
result = appRecord->NotifyLoadRepairPatch(bundleName);
|
||||
result = appRecord->NotifyLoadRepairPatch(bundleName, callback);
|
||||
if (result == ERR_OK) {
|
||||
loadSucceed = true;
|
||||
}
|
||||
@@ -619,7 +619,7 @@ int32_t AppRunningManager::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
return loadSucceed == true ? ERR_OK : result;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::NotifyHotReloadPage(const std::string &bundleName)
|
||||
int32_t AppRunningManager::NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -629,13 +629,14 @@ int32_t AppRunningManager::NotifyHotReloadPage(const std::string &bundleName)
|
||||
const auto &appRecord = item.second;
|
||||
if (appRecord && appRecord->GetBundleName() == bundleName) {
|
||||
HILOG_DEBUG("Notify application [%{public}s] reload page.", appRecord->GetProcessName().c_str());
|
||||
result = appRecord->NotifyHotReloadPage();
|
||||
result = appRecord->NotifyHotReloadPage(callback);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppRunningManager::NotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -646,7 +647,7 @@ int32_t AppRunningManager::NotifyUnLoadRepairPatch(const std::string &bundleName
|
||||
const auto &appRecord = item.second;
|
||||
if (appRecord && appRecord->GetBundleName() == bundleName) {
|
||||
HILOG_DEBUG("Notify application [%{public}s] unload patch.", appRecord->GetProcessName().c_str());
|
||||
result = appRecord->NotifyUnLoadRepairPatch(bundleName);
|
||||
result = appRecord->NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
if (result == ERR_OK) {
|
||||
unLoadSucceed = true;
|
||||
}
|
||||
|
||||
@@ -1266,7 +1266,7 @@ void AppRunningRecord::RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObjec
|
||||
(void)moduleRecord->RemoveTerminateAbilityTimeoutTask(token);
|
||||
}
|
||||
|
||||
int32_t AppRunningRecord::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppRunningRecord::NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -1274,10 +1274,10 @@ int32_t AppRunningRecord::NotifyLoadRepairPatch(const std::string &bundleName)
|
||||
HILOG_ERROR("appLifeCycleDeal_ is null");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appLifeCycleDeal_->NotifyLoadRepairPatch(bundleName);
|
||||
return appLifeCycleDeal_->NotifyLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
|
||||
int32_t AppRunningRecord::NotifyHotReloadPage()
|
||||
int32_t AppRunningRecord::NotifyHotReloadPage(const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -1285,10 +1285,11 @@ int32_t AppRunningRecord::NotifyHotReloadPage()
|
||||
HILOG_ERROR("appLifeCycleDeal_ is null");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appLifeCycleDeal_->NotifyHotReloadPage();
|
||||
return appLifeCycleDeal_->NotifyHotReloadPage(callback);
|
||||
}
|
||||
|
||||
int32_t AppRunningRecord::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
int32_t AppRunningRecord::NotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
@@ -1296,7 +1297,7 @@ int32_t AppRunningRecord::NotifyUnLoadRepairPatch(const std::string &bundleName)
|
||||
HILOG_ERROR("appLifeCycleDeal_ is null");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return appLifeCycleDeal_->NotifyUnLoadRepairPatch(bundleName);
|
||||
return appLifeCycleDeal_->NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
}
|
||||
|
||||
bool AppRunningRecord::IsContinuousTask()
|
||||
|
||||
@@ -42,6 +42,8 @@ ohos_shared_library("quickfixms") {
|
||||
|
||||
defines = [ "AMS_LOG_TAG = \"QuickFixService\"" ]
|
||||
|
||||
deps = [ "${ability_runtime_services_path}/common:perm_verification" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
|
||||
@@ -45,12 +45,16 @@ public:
|
||||
void NotifyApplyStatus(int32_t applyResult);
|
||||
void RemoveSelf();
|
||||
|
||||
private:
|
||||
void PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles);
|
||||
void PostSwitchQuickFixTask();
|
||||
void PostDeleteQuickFixTask();
|
||||
|
||||
private:
|
||||
void PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles);
|
||||
void PostTimeOutTask();
|
||||
void NotifyLoadRepairPatch();
|
||||
void NotifyUnloadRepairPatch();
|
||||
void NotifyHotReloadPage();
|
||||
void RegAppStateObserver();
|
||||
|
||||
sptr<AppExecFwk::IQuickFixManager> bundleQfMgr_ = nullptr;
|
||||
sptr<AppExecFwk::IAppMgr> appMgr_ = nullptr;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "common_event_support.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "quick_fix_callback_stub.h"
|
||||
#include "quick_fix_error_utils.h"
|
||||
#include "quick_fix_manager_service.h"
|
||||
#include "quick_fix/quick_fix_status_callback_host.h"
|
||||
@@ -172,6 +173,58 @@ private:
|
||||
std::shared_ptr<QuickFixManagerApplyTask> applyTask_;
|
||||
};
|
||||
|
||||
class QuickFixNotifyCallback : public AppExecFwk::QuickFixCallbackStub {
|
||||
public:
|
||||
explicit QuickFixNotifyCallback(std::shared_ptr<QuickFixManagerApplyTask> applyTask)
|
||||
: applyTask_(applyTask)
|
||||
{}
|
||||
|
||||
virtual ~QuickFixNotifyCallback() = default;
|
||||
|
||||
void OnLoadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
if (resultCode != 0) {
|
||||
HILOG_ERROR("Notify app load patch failed with %{public}d.", resultCode);
|
||||
applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_LOAD_PATCH_FAILED);
|
||||
applyTask_->RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
applyTask_->PostDeleteQuickFixTask();
|
||||
}
|
||||
|
||||
void OnUnloadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
if (resultCode != 0) {
|
||||
HILOG_ERROR("Notify app load patch failed with %{public}d.", resultCode);
|
||||
applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_UNLOAD_PATCH_FAILED);
|
||||
applyTask_->RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
applyTask_->PostSwitchQuickFixTask();
|
||||
}
|
||||
|
||||
void OnReloadPageDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
if (resultCode != 0) {
|
||||
HILOG_ERROR("Notify app load patch failed with %{public}d.", resultCode);
|
||||
applyTask_->NotifyApplyStatus(QUICK_FIX_NOTIFY_RELOAD_PAGE_FAILED);
|
||||
applyTask_->RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
applyTask_->NotifyApplyStatus(QUICK_FIX_OK);
|
||||
applyTask_->RemoveSelf();
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<QuickFixManagerApplyTask> applyTask_;
|
||||
};
|
||||
|
||||
void QuickFixManagerApplyTask::Run(const std::vector<std::string> &quickFixFiles)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@@ -184,27 +237,9 @@ void QuickFixManagerApplyTask::HandlePatchDeployed()
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
isRunning_ = GetRunningState();
|
||||
if (isRunning_ && isSoContained_) {
|
||||
HILOG_INFO("Start to register application state observer.");
|
||||
std::vector<std::string> bundleNameList;
|
||||
bundleNameList.push_back(bundleName_);
|
||||
sptr<AppExecFwk::IApplicationStateObserver> callback = new QuickFixMgrAppStateObserver(shared_from_this());
|
||||
auto ret = appMgr_->RegisterApplicationStateObserver(callback, bundleNameList);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Register application state observer failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_REGISTER_OBSERVER_FAILED);
|
||||
RemoveSelf();
|
||||
}
|
||||
HILOG_DEBUG("Register application state observer succeed.");
|
||||
return;
|
||||
return RegAppStateObserver();
|
||||
} else if (isRunning_ && !isSoContained_) {
|
||||
ApplicationQuickFixInfo quickFixInfo;
|
||||
auto service = quickFixMgrService_.promote();
|
||||
@@ -219,13 +254,7 @@ void QuickFixManagerApplyTask::HandlePatchDeployed()
|
||||
if (ret == QUICK_FIX_OK && !quickFixInfo.appqfInfo.hqfInfos.empty()) {
|
||||
// if there exist old version hqfInfo, need to unload.
|
||||
HILOG_DEBUG("Need unload patch firstly.");
|
||||
ret = appMgr_->NotifyUnLoadRepairPatch(bundleName_);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app unload patch failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_UNLOAD_PATCH_FAILED);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
return NotifyUnloadRepairPatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,20 +267,7 @@ void QuickFixManagerApplyTask::HandlePatchSwitched()
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (isRunning_ && !isSoContained_) {
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
auto ret = appMgr_->NotifyLoadRepairPatch(bundleName_);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app load patch failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_LOAD_PATCH_FAILED);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
return NotifyLoadRepairPatch();
|
||||
}
|
||||
|
||||
PostDeleteQuickFixTask();
|
||||
@@ -263,20 +279,7 @@ void QuickFixManagerApplyTask::HandlePatchDeleted()
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (isRunning_ && !isSoContained_ && type_ == AppExecFwk::QuickFixType::HOT_RELOAD) {
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
auto ret = appMgr_->NotifyHotReloadPage(bundleName_);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app reload page failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_RELOAD_PAGE_FAILED);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
return NotifyHotReloadPage();
|
||||
}
|
||||
|
||||
NotifyApplyStatus(QUICK_FIX_OK);
|
||||
@@ -472,6 +475,82 @@ void QuickFixManagerApplyTask::NotifyApplyStatus(int32_t applyResult)
|
||||
EventFwk::CommonEventManager::PublishCommonEvent(commonData);
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::NotifyLoadRepairPatch()
|
||||
{
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<AppExecFwk::IQuickFixCallback> callback = new QuickFixNotifyCallback(shared_from_this());
|
||||
auto ret = appMgr_->NotifyLoadRepairPatch(bundleName_, callback);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app load patch failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_LOAD_PATCH_FAILED);
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::NotifyUnloadRepairPatch()
|
||||
{
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<AppExecFwk::IQuickFixCallback> callback = new QuickFixNotifyCallback(shared_from_this());
|
||||
auto ret = appMgr_->NotifyUnLoadRepairPatch(bundleName_, callback);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app unload patch failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_UNLOAD_PATCH_FAILED);
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::NotifyHotReloadPage()
|
||||
{
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
sptr<AppExecFwk::IQuickFixCallback> callback = new QuickFixNotifyCallback(shared_from_this());
|
||||
auto ret = appMgr_->NotifyHotReloadPage(bundleName_, callback);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Notify app reload page failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_NOTIFY_RELOAD_PAGE_FAILED);
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::RegAppStateObserver()
|
||||
{
|
||||
HILOG_DEBUG("Start to register application state observer.");
|
||||
if (appMgr_ == nullptr) {
|
||||
HILOG_ERROR("Appmgr is nullptr.");
|
||||
NotifyApplyStatus(QUICK_FIX_APPMGR_INVALID);
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> bundleNameList;
|
||||
bundleNameList.push_back(bundleName_);
|
||||
sptr<AppExecFwk::IApplicationStateObserver> callback = new QuickFixMgrAppStateObserver(shared_from_this());
|
||||
auto ret = appMgr_->RegisterApplicationStateObserver(callback, bundleNameList);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Register application state observer failed.");
|
||||
NotifyApplyStatus(QUICK_FIX_REGISTER_OBSERVER_FAILED);
|
||||
RemoveSelf();
|
||||
}
|
||||
HILOG_DEBUG("Register application state observer succeed.");
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::RemoveSelf()
|
||||
{
|
||||
auto service = quickFixMgrService_.promote();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "permission_verification.h"
|
||||
#include "quick_fix_error_utils.h"
|
||||
#include "quick_fix_util.h"
|
||||
|
||||
@@ -58,6 +59,10 @@ int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &qu
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyInstallBundlePermission()) {
|
||||
return QUICK_FIX_VERIFY_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
auto bundleQfMgr = QuickFixUtil::GetBundleQuickFixMgrProxy();
|
||||
if (bundleQfMgr == nullptr) {
|
||||
HILOG_ERROR("Bundle quick fix manager is nullptr.");
|
||||
@@ -84,6 +89,10 @@ int32_t QuickFixManagerService::GetApplyedQuickFixInfo(const std::string &bundle
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyGetBundleInfoPrivilegedPermission()) {
|
||||
return QUICK_FIX_VERIFY_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
auto bundleMgr = QuickFixUtil::GetBundleManagerProxy();
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager.");
|
||||
|
||||
@@ -59,9 +59,11 @@ public:
|
||||
MOCK_METHOD1(RegisterConfigurationObserver, int32_t(const sptr<IConfigurationObserver> &observer));
|
||||
MOCK_METHOD1(UnregisterConfigurationObserver, int32_t(const sptr<IConfigurationObserver> &observer));
|
||||
MOCK_METHOD1(GetAppRunningStateByBundleName, bool(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyHotReloadPage, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyUnLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD2(NotifyLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(NotifyHotReloadPage, int32_t(const std::string &bundleName, const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(NotifyUnLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
|
||||
void AttachApplication(const sptr<IRemoteObject> &app)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,18 @@ public:
|
||||
}
|
||||
void StartDebugMode(bool needBreakPoint) {}
|
||||
void FinishPreload() {}
|
||||
void LoadRepairPatch(const std::string& patchFile, const std::string& baseFile) {}
|
||||
void NotifyHotReloadPage() {}
|
||||
void UnLoadRepairPatch(const std::string& patchFile) {}
|
||||
bool LoadRepairPatch(const std::string& patchFile, const std::string& baseFile)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool NotifyHotReloadPage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool UnLoadRepairPatch(const std::string& patchFile)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool RunScript(const std::string& path, const std::string& hapPath)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -66,9 +66,11 @@ public:
|
||||
MOCK_METHOD0(BlockAppService, int());
|
||||
#endif
|
||||
MOCK_METHOD1(GetAppRunningStateByBundleName, bool(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyHotReloadPage, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD1(NotifyUnLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD2(NotifyLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(NotifyHotReloadPage, int32_t(const std::string &bundleName, const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(NotifyUnLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
|
||||
virtual int StartUserTestProcess(
|
||||
const AAFwk::Want &want, const sptr<IRemoteObject> &observer, const BundleInfo &bundleInfo, int32_t userId)
|
||||
|
||||
@@ -43,9 +43,11 @@ public:
|
||||
MOCK_METHOD1(ScheduleAbilityStage, void(const HapModuleInfo &));
|
||||
MOCK_METHOD1(ScheduleMemoryLevel, void(int32_t level));
|
||||
MOCK_METHOD2(ScheduleAcceptWant, void(const AAFwk::Want &want, const std::string &moduleName));
|
||||
MOCK_METHOD1(ScheduleNotifyLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD0(ScheduleNotifyHotReloadPage, int32_t());
|
||||
MOCK_METHOD1(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD2(ScheduleNotifyLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD1(ScheduleNotifyHotReloadPage, int32_t(const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -38,9 +38,11 @@ public:
|
||||
MOCK_METHOD0(ScheduleProcessSecurityExit, void());
|
||||
MOCK_METHOD1(ScheduleAbilityStage, void(const HapModuleInfo &));
|
||||
MOCK_METHOD2(ScheduleAcceptWant, void(const AAFwk::Want &want, const std::string &moduleName));
|
||||
MOCK_METHOD1(ScheduleNotifyLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD0(ScheduleNotifyHotReloadPage, int32_t());
|
||||
MOCK_METHOD1(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string &bundleName));
|
||||
MOCK_METHOD2(ScheduleNotifyLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD1(ScheduleNotifyHotReloadPage, int32_t(const sptr<IQuickFixCallback> &callback));
|
||||
MOCK_METHOD2(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback));
|
||||
|
||||
void Post()
|
||||
{
|
||||
|
||||
+5
-3
@@ -134,17 +134,19 @@ public:
|
||||
void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override
|
||||
{}
|
||||
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName) override
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ScheduleNotifyHotReloadPage() override
|
||||
int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName) override
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,15 +71,17 @@ public:
|
||||
{}
|
||||
void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override
|
||||
{}
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName) override
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int32_t ScheduleNotifyHotReloadPage() override
|
||||
int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName) override
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "mock_app_mgr_service.h"
|
||||
#include "app_mgr_proxy.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "quick_fix_callback_stub.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
@@ -28,6 +29,27 @@ namespace {
|
||||
const int32_t USER_ID = 100;
|
||||
} // namespace
|
||||
|
||||
class QuickFixCallbackImpl : public AppExecFwk::QuickFixCallbackStub {
|
||||
public:
|
||||
QuickFixCallbackImpl() = default;
|
||||
virtual ~QuickFixCallbackImpl() = default;
|
||||
|
||||
void OnLoadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
|
||||
void OnUnloadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
|
||||
void OnReloadPageDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
};
|
||||
|
||||
class AppMgrProxyTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -116,7 +138,8 @@ HWTEST_F(AppMgrProxyTest, NotifyLoadRepairPatch_0100, TestSize.Level0)
|
||||
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
|
||||
|
||||
std::string bundleName = "testBundleName";
|
||||
appMgrProxy_->NotifyLoadRepairPatch(bundleName);
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
appMgrProxy_->NotifyLoadRepairPatch(bundleName, callback);
|
||||
|
||||
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::NOTIFY_LOAD_REPAIR_PATCH));
|
||||
|
||||
@@ -138,7 +161,8 @@ HWTEST_F(AppMgrProxyTest, NotifyHotReloadPage_0100, TestSize.Level0)
|
||||
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
|
||||
|
||||
std::string bundleName = "testBundleName";
|
||||
appMgrProxy_->NotifyHotReloadPage(bundleName);
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
appMgrProxy_->NotifyHotReloadPage(bundleName, callback);
|
||||
|
||||
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::NOTIFY_HOT_RELOAD_PAGE));
|
||||
|
||||
@@ -160,7 +184,8 @@ HWTEST_F(AppMgrProxyTest, NotifyUnLoadRepairPatch_0100, TestSize.Level0)
|
||||
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
|
||||
|
||||
std::string bundleName = "testBundleName";
|
||||
appMgrProxy_->NotifyUnLoadRepairPatch(bundleName);
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
appMgrProxy_->NotifyUnLoadRepairPatch(bundleName, callback);
|
||||
|
||||
EXPECT_EQ(mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::NOTIFY_UNLOAD_REPAIR_PATCH));
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ HWTEST_F(AppMgrStubTest, HandleNotifyLoadRepairPatch_0100, TestSize.Level0)
|
||||
std::string bundleName = "testBundleName";
|
||||
data.WriteString(bundleName);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyLoadRepairPatch(_)).Times(1);
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyLoadRepairPatch(_, _)).Times(1);
|
||||
|
||||
auto result = mockAppMgrService_->OnRemoteRequest(
|
||||
static_cast<uint32_t>(IAppMgr::Message::NOTIFY_LOAD_REPAIR_PATCH), data, reply, option);
|
||||
@@ -161,7 +161,7 @@ HWTEST_F(AppMgrStubTest, HandleNotifyHotReloadPage_0100, TestSize.Level0)
|
||||
std::string bundleName = "testBundleName";
|
||||
data.WriteString(bundleName);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyHotReloadPage(_)).Times(1);
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyHotReloadPage(_, _)).Times(1);
|
||||
|
||||
auto result = mockAppMgrService_->OnRemoteRequest(
|
||||
static_cast<uint32_t>(IAppMgr::Message::NOTIFY_HOT_RELOAD_PAGE), data, reply, option);
|
||||
@@ -188,7 +188,7 @@ HWTEST_F(AppMgrStubTest, HandleNotifyUnLoadRepairPatch_0100, TestSize.Level0)
|
||||
std::string bundleName = "testBundleName";
|
||||
data.WriteString(bundleName);
|
||||
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyUnLoadRepairPatch(_)).Times(1);
|
||||
EXPECT_CALL(*mockAppMgrService_, NotifyUnLoadRepairPatch(_, _)).Times(1);
|
||||
|
||||
auto result = mockAppMgrService_->OnRemoteRequest(
|
||||
static_cast<uint32_t>(IAppMgr::Message::NOTIFY_UNLOAD_REPAIR_PATCH), data, reply, option);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "main_thread.h"
|
||||
#undef private
|
||||
#include "mock_bundle_manager.h"
|
||||
#include "quick_fix_callback_stub.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "sys_mgr_client.h"
|
||||
|
||||
@@ -31,6 +32,27 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class QuickFixCallbackImpl : public AppExecFwk::QuickFixCallbackStub {
|
||||
public:
|
||||
QuickFixCallbackImpl() = default;
|
||||
virtual ~QuickFixCallbackImpl() = default;
|
||||
|
||||
void OnLoadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
|
||||
void OnUnloadPatchDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
|
||||
void OnReloadPageDone(int32_t resultCode) override
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
}
|
||||
};
|
||||
|
||||
class MainThreadTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -81,7 +103,8 @@ HWTEST_F(MainThreadTest, ScheduleNotifyLoadRepairPatch_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
std::string bundleName;
|
||||
auto ret = mainThread_->ScheduleNotifyLoadRepairPatch(bundleName);
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
auto ret = mainThread_->ScheduleNotifyLoadRepairPatch(bundleName, callback);
|
||||
EXPECT_EQ(ret, NO_ERROR);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
@@ -95,7 +118,8 @@ HWTEST_F(MainThreadTest, ScheduleNotifyLoadRepairPatch_0100, TestSize.Level1)
|
||||
HWTEST_F(MainThreadTest, ScheduleNotifyHotReloadPage_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
auto ret = mainThread_->ScheduleNotifyHotReloadPage();
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
auto ret = mainThread_->ScheduleNotifyHotReloadPage(callback);
|
||||
EXPECT_EQ(ret, NO_ERROR);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
@@ -131,7 +155,8 @@ HWTEST_F(MainThreadTest, ScheduleNotifyUnLoadRepairPatch_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
std::string bundleName;
|
||||
auto ret = mainThread_->ScheduleNotifyUnLoadRepairPatch(bundleName);
|
||||
sptr<IQuickFixCallback> callback = new QuickFixCallbackImpl();
|
||||
auto ret = mainThread_->ScheduleNotifyUnLoadRepairPatch(bundleName, callback);
|
||||
EXPECT_EQ(ret, NO_ERROR);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"quick_fix_callback_proxy_test:unittest",
|
||||
"quick_fix_callback_stub_test:unittest",
|
||||
"quick_fix_info_test:unittest",
|
||||
"quick_fix_manager_client_test:unittest",
|
||||
"quick_fix_manager_proxy_test:unittest",
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2021-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_ABILITY_RUNTIME_MOCK_QUICK_FIX_CALLBACK_STUB_H
|
||||
#define OHOS_ABILITY_RUNTIME_MOCK_QUICK_FIX_CALLBACK_STUB_H
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "quick_fix_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class MockQuickFixCallbackStub : public QuickFixCallbackStub {
|
||||
public:
|
||||
MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel &, MessageParcel &, MessageOption &));
|
||||
MOCK_METHOD1(OnLoadPatchDone, void(int32_t resultCode));
|
||||
MOCK_METHOD1(OnUnloadPatchDone, void(int32_t resultCode));
|
||||
MOCK_METHOD1(OnReloadPageDone, void(int32_t resultCode));
|
||||
|
||||
int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
code_ = code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
int code_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_MOCK_QUICK_FIX_CALLBACK_STUB_H
|
||||
@@ -0,0 +1,53 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
ohos_unittest("quick_fix_callback_proxy_test") {
|
||||
module_out_path = "ability_runtime/quick_fix"
|
||||
|
||||
include_dirs =
|
||||
[ "${ability_runtime_test_path}/unittest/quick_fix/mock/include" ]
|
||||
|
||||
sources = [ "quick_fix_callback_proxy_test.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/common:common_config" ]
|
||||
|
||||
cflags = []
|
||||
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [ ":quick_fix_callback_proxy_test" ]
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#define private public
|
||||
#include "mock_quick_fix_callback_stub.h"
|
||||
#include "quick_fix_callback_proxy.h"
|
||||
#undef private
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class QuickFixCallbackProxyTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
sptr<MockQuickFixCallbackStub> mockCallbackService_ = nullptr;
|
||||
sptr<QuickFixCallbackProxy> quickFixMgrProxy_ = nullptr;
|
||||
};
|
||||
|
||||
void QuickFixCallbackProxyTest::SetUpTestCase(void)
|
||||
{}
|
||||
|
||||
void QuickFixCallbackProxyTest::TearDownTestCase(void)
|
||||
{}
|
||||
|
||||
void QuickFixCallbackProxyTest::SetUp()
|
||||
{
|
||||
mockCallbackService_ = new MockQuickFixCallbackStub();
|
||||
ASSERT_NE(mockCallbackService_, nullptr);
|
||||
|
||||
quickFixMgrProxy_ = new QuickFixCallbackProxy(mockCallbackService_);
|
||||
ASSERT_NE(quickFixMgrProxy_, nullptr);
|
||||
}
|
||||
|
||||
void QuickFixCallbackProxyTest::TearDown()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.name: OnLoadPatchDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackProxyTest, OnLoadPatchDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
EXPECT_CALL(*mockCallbackService_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mockCallbackService_.GetRefPtr(), &MockQuickFixCallbackStub::InvokeSendRequest));
|
||||
|
||||
int32_t resultCode = 0;
|
||||
quickFixMgrProxy_->OnLoadPatchDone(resultCode);
|
||||
|
||||
EXPECT_EQ(mockCallbackService_->code_,
|
||||
static_cast<uint32_t>(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH));
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnUnloadPatchDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackProxyTest, OnUnloadPatchDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
EXPECT_CALL(*mockCallbackService_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mockCallbackService_.GetRefPtr(), &MockQuickFixCallbackStub::InvokeSendRequest));
|
||||
|
||||
int32_t resultCode = 0;
|
||||
quickFixMgrProxy_->OnUnloadPatchDone(resultCode);
|
||||
|
||||
EXPECT_EQ(mockCallbackService_->code_,
|
||||
static_cast<uint32_t>(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH));
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnReloadPageDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackProxyTest, OnReloadPageDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
EXPECT_CALL(*mockCallbackService_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mockCallbackService_.GetRefPtr(), &MockQuickFixCallbackStub::InvokeSendRequest));
|
||||
|
||||
int32_t resultCode = 0;
|
||||
quickFixMgrProxy_->OnReloadPageDone(resultCode);
|
||||
|
||||
EXPECT_EQ(mockCallbackService_->code_,
|
||||
static_cast<uint32_t>(IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE));
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,53 @@
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
ohos_unittest("quick_fix_callback_stub_test") {
|
||||
module_out_path = "ability_runtime/quick_fix"
|
||||
|
||||
include_dirs =
|
||||
[ "${ability_runtime_test_path}/unittest/quick_fix/mock/include" ]
|
||||
|
||||
sources = [ "quick_fix_callback_stub_test.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/common:common_config" ]
|
||||
|
||||
cflags = []
|
||||
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [ ":quick_fix_callback_stub_test" ]
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "quick_fix_callback_stub.h"
|
||||
#include "mock_quick_fix_callback_stub.h"
|
||||
#undef private
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class QuickFixCallbackStubTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
sptr<MockQuickFixCallbackStub> mockQuickFixCallback_ = nullptr;
|
||||
};
|
||||
|
||||
void QuickFixCallbackStubTest::SetUpTestCase(void)
|
||||
{}
|
||||
|
||||
void QuickFixCallbackStubTest::TearDownTestCase(void)
|
||||
{}
|
||||
|
||||
void QuickFixCallbackStubTest::SetUp()
|
||||
{
|
||||
mockQuickFixCallback_ = new MockQuickFixCallbackStub();
|
||||
ASSERT_NE(mockQuickFixCallback_, nullptr);
|
||||
}
|
||||
|
||||
void QuickFixCallbackStubTest::TearDown()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.name: OnLoadPatchDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackStubTest, OnLoadPatchDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
data.WriteInterfaceToken(QuickFixCallbackStub::GetDescriptor());
|
||||
int32_t resultCode = 0;
|
||||
data.WriteInt32(resultCode);
|
||||
|
||||
EXPECT_CALL(*mockQuickFixCallback_, OnLoadPatchDone(_)).Times(1);
|
||||
|
||||
auto result = mockQuickFixCallback_->OnRemoteRequest(
|
||||
IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply, option);
|
||||
EXPECT_EQ(result, NO_ERROR);
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnUnloadPatchDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackStubTest, OnUnloadPatchDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
data.WriteInterfaceToken(QuickFixCallbackStub::GetDescriptor());
|
||||
int32_t resultCode = 0;
|
||||
data.WriteInt32(resultCode);
|
||||
|
||||
EXPECT_CALL(*mockQuickFixCallback_, OnUnloadPatchDone(_)).Times(1);
|
||||
|
||||
auto result = mockQuickFixCallback_->OnRemoteRequest(
|
||||
IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_UNLOAD_PATCH, data, reply, option);
|
||||
EXPECT_EQ(result, NO_ERROR);
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnReloadPageDone_0100
|
||||
* @tc.desc: basic function test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackStubTest, OnReloadPageDone_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
data.WriteInterfaceToken(QuickFixCallbackStub::GetDescriptor());
|
||||
int32_t resultCode = 0;
|
||||
data.WriteInt32(resultCode);
|
||||
|
||||
EXPECT_CALL(*mockQuickFixCallback_, OnReloadPageDone(_)).Times(1);
|
||||
|
||||
auto result = mockQuickFixCallback_->OnRemoteRequest(
|
||||
IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_RELOAD_PAGE, data, reply, option);
|
||||
EXPECT_EQ(result, NO_ERROR);
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnRemoteRequest_0100
|
||||
* @tc.desc: OnRemoteRequest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackStubTest, OnRemoteRequest_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
data.WriteInterfaceToken(u"fake_interface_token");
|
||||
int32_t resultCode = 0;
|
||||
data.WriteInt32(resultCode);
|
||||
|
||||
auto result = mockQuickFixCallback_->OnRemoteRequest(
|
||||
IQuickFixCallback::QuickFixCallbackCmd::ON_NOTIFY_LOAD_PATCH, data, reply, option);
|
||||
EXPECT_EQ(result, ERR_INVALID_STATE);
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnRemoteRequest_0200
|
||||
* @tc.desc: OnRemoteRequest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5OD2E
|
||||
*/
|
||||
HWTEST_F(QuickFixCallbackStubTest, OnRemoteRequest_0200, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
data.WriteInterfaceToken(QuickFixCallbackStub::GetDescriptor());
|
||||
std::string bundleName = "com.ohos.quickfix";
|
||||
data.WriteString(bundleName);
|
||||
|
||||
uint32_t invalidCode = 10;
|
||||
auto result = mockQuickFixCallback_->OnRemoteRequest(invalidCode, data, reply, option);
|
||||
EXPECT_EQ(result, IPC_STUB_UNKNOW_TRANS_ERR);
|
||||
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user