From 54f937af93bbd9106f007faeb398df6ef85b2fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A1=A2?= Date: Tue, 18 Jul 2023 07:44:38 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8D=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=EF=BC=8COnBackup=E5=92=8COnRestore=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9F=BA=E7=B1=BB=E5=AE=9E=E7=8E=B0=E3=80=82=201=E3=80=81exten?= =?UTF-8?q?sion=E7=9B=B4=E6=8E=A5=E8=B0=83=E7=94=A8=E5=9F=BA=E7=B1=BB?= =?UTF-8?q?=EF=BC=8C=E6=A0=B9=E6=8D=AEruntime=E8=B0=83=E7=94=A8=E5=88=B0JS?= =?UTF-8?q?=E7=9A=84=E5=AD=90=E7=B1=BB=202=E3=80=81=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=BB=8EJS=E5=AD=90=E7=B1=BB=E6=8C=AA?= =?UTF-8?q?=E5=88=B0=E5=9F=BA=E7=B1=BB=E3=80=82=203=E3=80=81=E5=9F=BA?= =?UTF-8?q?=E7=B1=BB=E5=AE=9E=E7=8E=B0creater=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=A2=AB=E5=AD=90=E7=B1=BB=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 鐜嬫、 --- .../native/backup_ext/include/ext_backup.h | 103 +++++++++- .../native/backup_ext/include/ext_backup_js.h | 71 +------ .../native/backup_ext/include/ext_extension.h | 16 +- .../native/backup_ext/src/ext_backup.cpp | 179 +++++++++++++++++- .../native/backup_ext/src/ext_backup_js.cpp | 133 +++---------- .../native/backup_ext/src/ext_extension.cpp | 10 +- 6 files changed, 321 insertions(+), 191 deletions(-) diff --git a/frameworks/native/backup_ext/include/ext_backup.h b/frameworks/native/backup_ext/include/ext_backup.h index 6977778af..d02129bd1 100644 --- a/frameworks/native/backup_ext/include/ext_backup.h +++ b/frameworks/native/backup_ext/include/ext_backup.h @@ -16,13 +16,29 @@ #ifndef OHOS_FILEMGMT_BACKUP_EXT_BACKUP_H #define OHOS_FILEMGMT_BACKUP_EXT_BACKUP_H +#include "b_resources/b_constants.h" #include "ext_backup_context.h" #include "extension_base.h" #include "runtime.h" +#include "want.h" namespace OHOS::FileManagement::Backup { + +class ExtBackup; +using CreatorFunc = std::function& runtime)>; + class ExtBackup : public AbilityRuntime::ExtensionBase { public: + + /** + * @brief Called when this extension is started. You must override this function if you want to perform some + * initialization operations during extension startup. + * + * This function can be called only once in the entire lifecycle of an extension. + * @param Want Indicates the {@link Want} structure containing startup information about the extension. + */ + void OnStart(const AAFwk::Want &want) override; + /** * @brief Init the extension. * @@ -36,6 +52,43 @@ public: std::shared_ptr &handler, const sptr &token) override; + /** + * @brief Called back when Service is started. + * This method can be called only by Service. You can use the StartAbility(ohos.aafwk.content.Want) method to start + * Service. Then the system calls back the current method to use the transferred want parameter to execute its own + * logic. + * + * @param want Indicates the want of Service to start. + * @param restart Indicates the startup mode. The value true indicates that Service is restarted after being + * destroyed, and the value false indicates a normal startup. + * @param startId Indicates the number of times the Service extension has been started. The startId is + * incremented by 1 every time the extension is started. For example, if the extension has been started + * for six times, the value of startId is 6. + */ + void OnCommand(const AAFwk::Want &want, bool restart, int startId) override; + + /** + * @brief Called when this backup extension ability is connected for the first time. + * + * You can override this function to implement your own processing logic. + * + * @param want Indicates the {@link Want} structure containing connection information about the backup + * extension. + * @return Returns a pointer to the sid of the connected backup extension ability. + */ + sptr OnConnect(const AAFwk::Want &want) override; + + + /** + * @brief Called when all abilities connected to this Wallpaper extension are disconnected. + * + * You can override this function to implement your own processing logic. + * + */ + void OnDisconnect(const AAFwk::Want &want) override; + +public: + /** * @brief Create Extension. * @@ -44,12 +97,60 @@ public: */ static ExtBackup *Create(const std::unique_ptr &runtime); + /** + * @brief Get the Extension Action object + * + * @return BConstants::ExtensionAction + */ + virtual BConstants::ExtensionAction GetExtensionAction() const; + + /** + * @brief Get the User Config, then check if + * + * @return allowed ro not + */ + virtual bool AllowToBackupRestore() const; + + /** + * @brief Get the user configure + * + * @return user configure + */ + virtual std::string GetUsrConfig() const; + + /** + * @brief do backup. Subclasses can inherit to implement their own custom functionality. + */ + virtual ErrCode OnBackup(void); + + /** + * @brief Called do restore. + */ + virtual ErrCode OnRestore(void); + public: ExtBackup() = default; ~ExtBackup() override = default; + static void SetCreator(const CreatorFunc& creator); + +protected: + + std::string appVersionStr_; + int appVersionCode_; + int restoreType_; + private: + + BConstants::ExtensionAction VerifyAndGetAction(const AAFwk::Want &want, + std::shared_ptr abilityInfo); + + ErrCode GetParament(const AAFwk::Want &want); + + BConstants::ExtensionAction extAction_ {BConstants::ExtensionAction::INVALID}; + + static CreatorFunc creator_; }; } // namespace OHOS::FileManagement::Backup -#endif // OHOS_FILEMGMT_BACKUP_EXT_BACKUP_H \ No newline at end of file +#endif // OHOS_FILEMGMT_BACKUP_EXT_BACKUP_H diff --git a/frameworks/native/backup_ext/include/ext_backup_js.h b/frameworks/native/backup_ext/include/ext_backup_js.h index ae0797887..aaacc7f7b 100644 --- a/frameworks/native/backup_ext/include/ext_backup_js.h +++ b/frameworks/native/backup_ext/include/ext_backup_js.h @@ -31,15 +31,6 @@ namespace OHOS::FileManagement::Backup { class ExtBackupJs : public ExtBackup { public: - /** - * @brief Called when this extension is started. You must override this function if you want to perform some - * initialization operations during extension startup. - * - * This function can be called only once in the entire lifecycle of an extension. - * @param Want Indicates the {@link Want} structure containing startup information about the extension. - */ - void OnStart(const AAFwk::Want &want) override; - /** * @brief Init the extension. * @@ -53,40 +44,6 @@ public: std::shared_ptr &handler, const sptr &token) override; - /** - * @brief Called back when Service is started. - * This method can be called only by Service. You can use the StartAbility(ohos.aafwk.content.Want) method to start - * Service. Then the system calls back the current method to use the transferred want parameter to execute its own - * logic. - * - * @param want Indicates the want of Service to start. - * @param restart Indicates the startup mode. The value true indicates that Service is restarted after being - * destroyed, and the value false indicates a normal startup. - * @param startId Indicates the number of times the Service extension has been started. The startId is - * incremented by 1 every time the extension is started. For example, if the extension has been started - * for six times, the value of startId is 6. - */ - void OnCommand(const AAFwk::Want &want, bool restart, int startId) override; - - /** - * @brief Called when this backup extension ability is connected for the first time. - * - * You can override this function to implement your own processing logic. - * - * @param want Indicates the {@link Want} structure containing connection information about the backup - * extension. - * @return Returns a pointer to the sid of the connected backup extension ability. - */ - sptr OnConnect(const AAFwk::Want &want) override; - - /** - * @brief Called when all abilities connected to this Wallpaper extension are disconnected. - * - * You can override this function to implement your own processing logic. - * - */ - void OnDisconnect(const AAFwk::Want &want) override; - public: /** * @brief Create ExtBackupJs. @@ -97,33 +54,14 @@ public: static ExtBackupJs *Create(const std::unique_ptr &runtime); /** - * @brief Get the File Handle object - * - * @param fileName - * @return UniqueFd - */ - UniqueFd GetFileHandle(std::string &fileName); - - /** - * @brief Get the Extension Action object - * - * @return BConstants::ExtensionAction + * @brief Call the app's OnBackup. */ - BConstants::ExtensionAction GetExtensionAction() const; + ErrCode OnBackup(void) override; /** - * @brief Get the User Config, then check if - * - * @return allowed ro not - */ - bool AllowToBackupRestore() const; - - /** - * @brief Get the user configure - * - * @return user configure + * @brief Call the app's OnRestore. */ - std::string GetUsrConfig() const; + ErrCode OnRestore(void) override; public: explicit ExtBackupJs(AbilityRuntime::JsRuntime &jsRuntime) : jsRuntime_(jsRuntime) {} @@ -138,7 +76,6 @@ private: AbilityRuntime::JsRuntime &jsRuntime_; std::unique_ptr jsObj_; - BConstants::ExtensionAction extAction_ {BConstants::ExtensionAction::INVALID}; }; } // namespace OHOS::FileManagement::Backup diff --git a/frameworks/native/backup_ext/include/ext_extension.h b/frameworks/native/backup_ext/include/ext_extension.h index d0cbc4b74..6b85312ee 100644 --- a/frameworks/native/backup_ext/include/ext_extension.h +++ b/frameworks/native/backup_ext/include/ext_extension.h @@ -34,8 +34,14 @@ public: ErrCode PublishFile(const std::string &fileName) override; ErrCode HandleBackup() override; + /** + * @brief Executing Restoration Tasks Asynchronously + * + */ + void AsyncTaskRestore(); + public: - explicit BackupExtExtension(const std::shared_ptr &extension) : extension_(extension) + explicit BackupExtExtension(const std::shared_ptr &extension) : extension_(extension) { threadPool_.Start(BConstants::EXTENSION_THREAD_POOL_COUNT); } @@ -74,15 +80,9 @@ private: */ void AsyncTaskBackup(const std::string config); - /** - * @brief Executing Restoration Tasks Asynchronously - * - */ - void AsyncTaskRestore(); - private: std::shared_mutex lock_; - std::shared_ptr extension_; + std::shared_ptr extension_; std::vector tars_; OHOS::ThreadPool threadPool_; }; diff --git a/frameworks/native/backup_ext/src/ext_backup.cpp b/frameworks/native/backup_ext/src/ext_backup.cpp index a38123042..5d6c5d9a6 100644 --- a/frameworks/native/backup_ext/src/ext_backup.cpp +++ b/frameworks/native/backup_ext/src/ext_backup.cpp @@ -13,6 +13,21 @@ * limitations under the License. */ +#include +#include +#include +#include + +#include "b_error/b_error.h" +#include "b_error/b_excep_utils.h" +#include "b_json/b_json_cached_entity.h" +#include "b_json/b_json_entity_extension_config.h" +#include "b_resources/b_constants.h" +#include "bundle_mgr_client.h" +#include "ext_extension.h" +#include "filemgmt_libhilog.h" +#include "unique_fd.h" + #include "ext_backup.h" #include "ext_backup_js.h" @@ -20,6 +35,13 @@ namespace OHOS::FileManagement::Backup { using namespace std; + +CreatorFunc ExtBackup::creator_ = nullptr; +void ExtBackup::SetCreator(const CreatorFunc &creator) +{ + creator_ = creator; +} + void ExtBackup::Init(const shared_ptr &record, const shared_ptr &application, shared_ptr &handler, @@ -31,17 +53,170 @@ void ExtBackup::Init(const shared_ptr &recor ExtBackup *ExtBackup::Create(const unique_ptr &runtime) { - HILOGI("Create as an BackupExtensionAbility(Base)"); if (!runtime) { + HILOGD("Create as BackupExtensionAbility(base)"); return new ExtBackup(); } + if (creator_) { + HILOGD("Create as BackupExtensionAbility(creater)"); + return creator_(runtime); + } + switch (runtime->GetLanguage()) { case AbilityRuntime::Runtime::Language::JS: + HILOGD("Create as BackupExtensionAbility(JS)"); return ExtBackupJs::Create(runtime); default: + HILOGD("Create as BackupExtensionAbility(base)"); return new ExtBackup(); } } -} // namespace OHOS::FileManagement::Backup \ No newline at end of file + +void ExtBackup::OnStart(const AAFwk::Want &want) +{ + HILOGI("BackupExtensionAbility was started"); + Extension::OnStart(want); +} + +void ExtBackup::OnCommand(const AAFwk::Want &want, bool restart, int startId) +{ + HILOGI("BackupExtensionAbility was invoked. restart=%{public}d, startId=%{public}d", restart, startId); + + // REM: 处理返回结果 ret + // REM: 通过杀死进程实现 Stop +} + +string ExtBackup::GetUsrConfig() const +{ + vector config; + AppExecFwk::BundleMgrClient client; + BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); + const AppExecFwk::AbilityInfo &info = *abilityInfo_; + if (!client.GetProfileFromAbility(info, "ohos.extension.backup", config)) { + throw BError(BError::Codes::EXT_INVAL_ARG, "Failed to invoke the GetProfileFromAbility method."); + } + + return config.empty() ? "" : config[0]; +} + +bool ExtBackup::AllowToBackupRestore() const +{ + string usrConfig = GetUsrConfig(); + BJsonCachedEntity cachedEntity(usrConfig); + auto cache = cachedEntity.Structuralize(); + if (cache.GetAllowToBackupRestore()) { + return true; + } + return false; +} + +BConstants::ExtensionAction ExtBackup::GetExtensionAction() const +{ + return extAction_; +} + +BConstants::ExtensionAction ExtBackup::VerifyAndGetAction(const AAFwk::Want &want, + std::shared_ptr abilityInfo) +{ + string pendingMsg = "Received an empty ability. You must missed the init proc"; + BExcepUltils::BAssert(abilityInfo, BError::Codes::EXT_INVAL_ARG, pendingMsg); + using namespace BConstants; + ExtensionAction extAction {want.GetIntParam(EXTENSION_ACTION_PARA, static_cast(ExtensionAction::INVALID))}; + if (extAction == ExtensionAction::INVALID) { + int extActionInt = static_cast(extAction); + pendingMsg = string("Want must specify a valid action instead of ").append(to_string(extActionInt)); + throw BError(BError::Codes::EXT_INVAL_ARG, pendingMsg); + } + return extAction; +} + +ErrCode ExtBackup::GetParament(const AAFwk::Want &want) { + if (extAction_ == BConstants::ExtensionAction::RESTORE) { + appVersionStr_ = want.GetStringParam(BConstants::EXTENSION_VERSION_NAME_PARA); + appVersionCode_ = want.GetIntParam(BConstants::EXTENSION_VERSION_CODE_PARA, 0); + restoreType_ = want.GetIntParam(BConstants::EXTENSION_RESTORE_TYPE_PARA, 0); + HILOGI("Get version %{public}s type %{public}d from want when restore.", + appVersionStr_.c_str(), restoreType_); + } + /* backup don't need parament. */ + return ERR_OK; +} + +sptr ExtBackup::OnConnect(const AAFwk::Want &want) +{ + try { + HILOGI("begin"); + BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); + // 发起者必须是备份服务 + auto extAction = VerifyAndGetAction(want, abilityInfo_); + if (extAction_ != BConstants::ExtensionAction::INVALID && extAction == BConstants::ExtensionAction::INVALID && + extAction_ != extAction) { + HILOGE("Verification action failed."); + return nullptr; + } + // 应用必须配置支持备份恢复 + if (!AllowToBackupRestore()) { + HILOGE("The application does not allow to backup and restore."); + return nullptr; + } + extAction_ = extAction; + GetParament(want); + + Extension::OnConnect(want); + + auto remoteObject = + sptr(new BackupExtExtension(std::static_pointer_cast(shared_from_this()))); + + // async do restore. + if (extAction_ == BConstants::ExtensionAction::RESTORE) { + HILOGI("Restore directly when upgrading."); + remoteObject->AsyncTaskRestore(); + } + + return remoteObject->AsObject(); + + } catch (const BError &e) { + return nullptr; + } catch (const exception &e) { + HILOGE("%{public}s", e.what()); + return nullptr; + } catch (...) { + HILOGE(""); + return nullptr; + } +} + +void ExtBackup::OnDisconnect(const AAFwk::Want &want) +{ + try { + HILOGI("begin"); + Extension::OnDisconnect(want); + extAction_ = BConstants::ExtensionAction::INVALID; + HILOGI("end"); + } catch (const BError &e) { + return; + } catch (const exception &e) { + HILOGE("%{public}s", e.what()); + return; + } catch (...) { + HILOGE(""); + return; + } +} + +ErrCode ExtBackup::OnBackup(void) +{ + HILOGI("BackupExtensionAbility(base) OnBackup."); + return ERR_OK; +} + +ErrCode ExtBackup::OnRestore(void) +{ + HILOGI("BackupExtensionAbility(base) OnRestore."); + return ERR_OK; +} + +} // namespace OHOS::FileManagement::Backup + diff --git a/frameworks/native/backup_ext/src/ext_backup_js.cpp b/frameworks/native/backup_ext/src/ext_backup_js.cpp index 3a69b02bc..5b88cc45f 100644 --- a/frameworks/native/backup_ext/src/ext_backup_js.cpp +++ b/frameworks/native/backup_ext/src/ext_backup_js.cpp @@ -13,8 +13,6 @@ * limitations under the License. */ -#include "ext_backup_js.h" - #include #include #include @@ -27,6 +25,7 @@ #include "b_resources/b_constants.h" #include "bundle_mgr_client.h" #include "ext_extension.h" +#include "ext_backup_js.h" #include "filemgmt_libhilog.h" #include "js_runtime_utils.h" #include "unique_fd.h" @@ -34,12 +33,6 @@ namespace OHOS::FileManagement::Backup { using namespace std; -void ExtBackupJs::OnStart(const AAFwk::Want &want) -{ - HILOGI("BackupExtensionAbility(JS) was started"); - Extension::OnStart(want); -} - static string GetSrcPath(const AppExecFwk::AbilityInfo &info) { using AbilityRuntime::Extension; @@ -119,116 +112,38 @@ void ExtBackupJs::Init(const shared_ptr &record, return {BError(BError::Codes::OK).GetCode(), ret}; } -void ExtBackupJs::OnCommand(const AAFwk::Want &want, bool restart, int startId) -{ - HILOGI("BackupExtensionAbility(JS) was invoked. restart=%{public}d, startId=%{public}d", restart, startId); - - // REM: 澶勭悊杩斿洖缁撴灉 ret - // REM: 閫氳繃鏉姝昏繘绋嬪疄鐜 Stop -} - ExtBackupJs *ExtBackupJs::Create(const unique_ptr &runtime) { HILOGI("Create as an BackupExtensionAbility(JS)"); return new ExtBackupJs(static_cast(*runtime)); } -string ExtBackupJs::GetUsrConfig() const +ErrCode ExtBackupJs::OnBackup(void) { - vector config; - AppExecFwk::BundleMgrClient client; - BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); - const AppExecFwk::AbilityInfo &info = *abilityInfo_; - if (!client.GetProfileFromAbility(info, "ohos.extension.backup", config)) { - throw BError(BError::Codes::EXT_INVAL_ARG, "Failed to invoke the GetProfileFromAbility method."); - } - - return config.empty() ? "" : config[0]; -} - -bool ExtBackupJs::AllowToBackupRestore() const -{ - string usrConfig = GetUsrConfig(); - BJsonCachedEntity cachedEntity(usrConfig); - auto cache = cachedEntity.Structuralize(); - if (cache.GetAllowToBackupRestore()) { - return true; - } - return false; + HILOGI("BackupExtensionAbility(JS) OnBackup."); + auto ret = CallObjectMethod("onBackup"); + auto err = std::get<0>(ret); /* ErrCodo is the 1th(0) of return tuple. */ + return err; } -BConstants::ExtensionAction ExtBackupJs::GetExtensionAction() const +ErrCode ExtBackupJs::OnRestore(void) { - return extAction_; -} - -static BConstants::ExtensionAction VerifyAndGetAction(const AAFwk::Want &want, - std::shared_ptr abilityInfo) -{ - string pendingMsg = "Received an empty ability. You must missed the init proc"; - BExcepUltils::BAssert(abilityInfo, BError::Codes::EXT_INVAL_ARG, pendingMsg); - using namespace BConstants; - ExtensionAction extAction {want.GetIntParam(EXTENSION_ACTION_PARA, static_cast(ExtensionAction::INVALID))}; - if (extAction == ExtensionAction::INVALID) { - int extActionInt = static_cast(extAction); - pendingMsg = string("Want must specify a valid action instead of ").append(to_string(extActionInt)); - throw BError(BError::Codes::EXT_INVAL_ARG, pendingMsg); - } - - return extAction; + HILOGI("BackupExtensionAbility(JS) OnRestore."); + vector argv; + NativeValue *verCode = jsRuntime_.GetNativeEngine().CreateNumber(appVersionCode_); + NativeValue *verStr = jsRuntime_.GetNativeEngine().CreateString( + appVersionStr_.c_str(), appVersionStr_.length()); + + NativeValue *param = jsRuntime_.GetNativeEngine().CreateObject(); + auto paramObj = reinterpret_cast(param->GetInterface(NativeObject::INTERFACE_ID)); + paramObj->SetProperty("code", verCode); + paramObj->SetProperty("name", verStr); + + argv.push_back(param); + + auto ret = CallObjectMethod("onRestore", argv); + auto err = std::get<0>(ret); /* ErrCodo is the 1th(0) of return tuple. */ + return err; } -sptr ExtBackupJs::OnConnect(const AAFwk::Want &want) -{ - try { - HILOGI("begin"); - BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); - // 鍙戣捣鑰呭繀椤绘槸澶囦唤鏈嶅姟 - auto extAction = VerifyAndGetAction(want, abilityInfo_); - if (extAction_ != BConstants::ExtensionAction::INVALID && extAction == BConstants::ExtensionAction::INVALID && - extAction_ != extAction) { - HILOGI("Verification failed."); - return nullptr; - } - // 搴旂敤蹇呴』閰嶇疆鏀寔澶囦唤鎭㈠ - if (!AllowToBackupRestore()) { - HILOGI("The application does not allow to backup and restore."); - return nullptr; - } - extAction_ = extAction; - - Extension::OnConnect(want); - - auto remoteObject = - sptr(new BackupExtExtension(std::static_pointer_cast(shared_from_this()))); - HILOGI("end"); - return remoteObject->AsObject(); - } catch (const BError &e) { - return nullptr; - } catch (const exception &e) { - HILOGE("%{public}s", e.what()); - return nullptr; - } catch (...) { - HILOGE(""); - return nullptr; - } -} - -void ExtBackupJs::OnDisconnect(const AAFwk::Want &want) -{ - try { - HILOGI("begin"); - Extension::OnDisconnect(want); - extAction_ = BConstants::ExtensionAction::INVALID; - HILOGI("end"); - } catch (const BError &e) { - return; - } catch (const exception &e) { - HILOGE("%{public}s", e.what()); - return; - } catch (...) { - HILOGE(""); - return; - } -} -} // namespace OHOS::FileManagement::Backup \ No newline at end of file +} // namespace OHOS::FileManagement::Backup diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index 5d8ef02d8..62c2dad59 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -371,10 +371,11 @@ void BackupExtExtension::AsyncTaskBackup(const string config) if (proxy == nullptr) { HILOGE("Failed to obtain the ServiceProxy handle"); return; - } else { - proxy->AppDone(ret); } + ptr->extension_->OnBackup(); + proxy->AppDone(ret); + // 娓呯┖澶囦唤鐩綍 ptr->HandleClear(); }; @@ -500,10 +501,11 @@ void BackupExtExtension::AsyncTaskRestore() if (proxy == nullptr) { HILOGE("Failed to obtain the ServiceProxy handle"); return; - } else { - proxy->AppDone(ret); } + ptr->extension_->OnRestore(); + proxy->AppDone(ret); + // 娓呯┖鎭㈠鐩綍 ptr->HandleClear(); }; -- Gitee