mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
@@ -15,7 +15,7 @@
|
||||
|
||||
sequenceable QuickFixInfo..OHOS.AAFwk.ApplicationQuickFixInfo;
|
||||
interface OHOS.AAFwk.IQuickFixManager {
|
||||
void ApplyQuickFix([in] String[] quickFixFiles, [in] boolean isDebug);
|
||||
void ApplyQuickFix([in] String[] quickFixFiles, [in] boolean isDebug, [in] boolean isReplace);
|
||||
void GetApplyedQuickFixInfo([in] String bundleName, [out] ApplicationQuickFixInfo quickFixInfo);
|
||||
void RevokeQuickFix([in] String bundleName);
|
||||
}
|
||||
@@ -39,9 +39,10 @@ public:
|
||||
*
|
||||
* @param quickFixFiles quick fix files need to apply, this value should include file path and file name.
|
||||
* @param isDebug this value is for the quick fix debug mode selection.
|
||||
* @param isReplace this value is for the quick fix replace mode selection.
|
||||
* @return returns 0 on success, error code on failure.
|
||||
*/
|
||||
int32_t ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug = false);
|
||||
int32_t ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug = false, bool isReplace = false);
|
||||
|
||||
/**
|
||||
* @brief Get applyed quick fix info.
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace {
|
||||
const int LOAD_SA_TIMEOUT_MS = 4 * 1000;
|
||||
} // namespace
|
||||
|
||||
int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug,
|
||||
bool isReplace)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "called");
|
||||
@@ -57,7 +58,7 @@ int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector<std::string> &qui
|
||||
QUICK_FIX_COPY_FILES_FAILED;
|
||||
}
|
||||
|
||||
return quickFixMgr->ApplyQuickFix(destFiles, isDebug);
|
||||
return quickFixMgr->ApplyQuickFix(destFiles, isDebug, isReplace);
|
||||
}
|
||||
|
||||
int32_t QuickFixManagerClient::GetApplyedQuickFixInfo(const std::string &bundleName,
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
QUICK_FIX_REVOKE,
|
||||
};
|
||||
|
||||
void Run(const std::vector<std::string> &quickFixFiles, bool isDebug = false);
|
||||
void Run(const std::vector<std::string> &quickFixFiles, bool isDebug = false, bool isReplace = false);
|
||||
void HandlePatchDeployed();
|
||||
void HandlePatchSwitched();
|
||||
void HandlePatchDeleted();
|
||||
@@ -65,7 +65,8 @@ public:
|
||||
void PostRevokeQuickFixDeleteTask();
|
||||
void PostRevokeQuickFixProcessDiedTask();
|
||||
private:
|
||||
void PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles, bool isDebug = false);
|
||||
void PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles, bool isDebug = false,
|
||||
bool isReplace = false);
|
||||
void PostTimeOutTask();
|
||||
void PostNotifyLoadRepairPatchTask();
|
||||
void PostNotifyUnloadRepairPatchTask();
|
||||
|
||||
@@ -51,9 +51,11 @@ public:
|
||||
*
|
||||
* @param quickFixFiles Quick fix files need to apply, this value should include file path and file name.
|
||||
* @param isDebug this value is for the quick fix debug mode selection.
|
||||
* @param isReplace this value is for the quick fix replace mode selection.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
int32_t ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug = false) override;
|
||||
int32_t ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug = false,
|
||||
bool isReplace = false) override;
|
||||
|
||||
/**
|
||||
* @brief Get applyed quick fix info.
|
||||
|
||||
@@ -307,12 +307,12 @@ QuickFixManagerApplyTask::~QuickFixManagerApplyTask()
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "destroyed");
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::Run(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
void QuickFixManagerApplyTask::Run(const std::vector<std::string> &quickFixFiles, bool isDebug, bool isReplace)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::QUICKFIX, "Run apply task");
|
||||
taskType_ = TaskType::QUICK_FIX_APPLY;
|
||||
PostDeployQuickFixTask(quickFixFiles, isDebug);
|
||||
PostDeployQuickFixTask(quickFixFiles, isDebug, isReplace);
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::RunRevoke()
|
||||
@@ -385,7 +385,8 @@ void QuickFixManagerApplyTask::HandlePatchDeleted()
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector<std::string> &quickFixFiles, bool isDebug,
|
||||
bool isReplace)
|
||||
{
|
||||
auto callback = sptr<QuickFixManagerStatusCallback>::MakeSptr(shared_from_this());
|
||||
if (callback == nullptr) {
|
||||
@@ -396,7 +397,7 @@ void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector<std::str
|
||||
}
|
||||
|
||||
std::weak_ptr<QuickFixManagerApplyTask> thisWeakPtr(weak_from_this());
|
||||
auto deployTask = [thisWeakPtr, quickFixFiles, callback, isDebug]() {
|
||||
auto deployTask = [thisWeakPtr, quickFixFiles, callback, isDebug, isReplace]() {
|
||||
auto applyTask = thisWeakPtr.lock();
|
||||
if (applyTask == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "null apply task");
|
||||
@@ -410,8 +411,8 @@ void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector<std::str
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "isDebug is %d", isDebug);
|
||||
auto ret = applyTask->bundleQfMgr_->DeployQuickFix(quickFixFiles, callback, isDebug);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "isDebug is %d isReplace is %d", isDebug, isReplace);
|
||||
auto ret = applyTask->bundleQfMgr_->DeployQuickFix(quickFixFiles, callback, isDebug, "", isReplace);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "failed: %{public}d", ret);
|
||||
applyTask->NotifyApplyStatus(QUICK_FIX_DEPLOY_FAILED);
|
||||
|
||||
@@ -55,7 +55,8 @@ bool QuickFixManagerService::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug,
|
||||
bool isReplace)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "called");
|
||||
@@ -80,7 +81,7 @@ int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &qu
|
||||
}
|
||||
auto applyTask = std::make_shared<QuickFixManagerApplyTask>(bundleQfMgr, appMgr, eventHandler_, this);
|
||||
AddApplyTask(applyTask);
|
||||
applyTask->Run(quickFixFiles, isDebug);
|
||||
applyTask->Run(quickFixFiles, isDebug, isReplace);
|
||||
|
||||
return QUICK_FIX_OK;
|
||||
}
|
||||
|
||||
@@ -168,8 +168,9 @@ public:
|
||||
|
||||
class QuickFixManagerHostImpl : public QuickFixManagerHost {
|
||||
public:
|
||||
MOCK_METHOD4(DeployQuickFix, ErrCode(const std::vector<std::string>& bundleFilePaths,
|
||||
const sptr<IQuickFixStatusCallback>& statusCallback, bool isDebug, const std::string& targetPath));
|
||||
MOCK_METHOD5(DeployQuickFix, ErrCode(const std::vector<std::string>& bundleFilePaths,
|
||||
const sptr<IQuickFixStatusCallback>& statusCallback, bool isDebug, const std::string& targetPath,
|
||||
bool isReplace));
|
||||
MOCK_METHOD3(SwitchQuickFix, ErrCode(const std::string& bundleName, bool enable,
|
||||
const sptr<IQuickFixStatusCallback>& statusCallback));
|
||||
MOCK_METHOD2(DeleteQuickFix, ErrCode(const std::string& bundleName,
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace AAFwk {
|
||||
class MockQuickFixManagerStub : public QuickFixManagerStub {
|
||||
public:
|
||||
MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel&, MessageParcel&, MessageOption&));
|
||||
MOCK_METHOD2(ApplyQuickFix, int32_t(const std::vector<std::string>&, bool isDebug));
|
||||
MOCK_METHOD3(ApplyQuickFix, int32_t(const std::vector<std::string>&, bool isDebug, bool isReplace));
|
||||
MOCK_METHOD2(GetApplyedQuickFixInfo, int32_t(const std::string&, ApplicationQuickFixInfo&));
|
||||
MOCK_METHOD1(RevokeQuickFix, int32_t(const std::string &));
|
||||
|
||||
|
||||
+3
-2
@@ -75,11 +75,12 @@ HWTEST_F(QuickFixManagerClientTest, ApplyQuickFix_0100, TestSize.Level1)
|
||||
TAG_LOGI(AAFwkTag::TEST, "%{public}s start", __func__);
|
||||
|
||||
quickFixClient_->quickFixMgr_ = mockQuickFixMgrService_;
|
||||
EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_, _)).Times(1);
|
||||
EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_, _, _)).Times(1);
|
||||
|
||||
std::vector<std::string> quickfixFiles;
|
||||
bool isDebug = false;
|
||||
auto ret = quickFixClient_->ApplyQuickFix(quickfixFiles, isDebug);
|
||||
bool isReplace = false;
|
||||
auto ret = quickFixClient_->ApplyQuickFix(quickfixFiles, isDebug, isReplace);
|
||||
EXPECT_EQ(ret, QUICK_FIX_OK);
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "%{public}s end", __func__);
|
||||
|
||||
+2
-1
@@ -58,7 +58,8 @@ bool QuickFixManagerService::Init()
|
||||
return g_mockInitState;
|
||||
}
|
||||
|
||||
int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string>& quickFixFiles, bool isDebug)
|
||||
int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string>& quickFixFiles, bool isDebug,
|
||||
bool isReplace)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ HWTEST_F(QuickFixManagerApplyTaskTest, Run_0100, TestSize.Level1)
|
||||
quickFixMs_->eventHandler_, quickFixMs_);
|
||||
ASSERT_NE(applyTask, nullptr);
|
||||
|
||||
EXPECT_CALL(*bundleQfMgr_, DeployQuickFix(_, _, _, _)).Times(1);
|
||||
EXPECT_CALL(*bundleQfMgr_, DeployQuickFix(_, _, _, _, _)).Times(1);
|
||||
std::vector<std::string> quickFixFiles;
|
||||
applyTask->Run(quickFixFiles);
|
||||
WaitUntilTaskDone(quickFixMs_->eventHandler_);
|
||||
|
||||
Reference in New Issue
Block a user