From e1ac48571d529485f9e13913a2edc5032a20887e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A1=A2?= Date: Sat, 2 Sep 2023 19:30:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8D=EF=BC=9A?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=BA=94=E7=94=A8=E6=9C=89=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=9B=AE=E5=BD=95=E8=A7=A3=E5=8E=8B=EF=BC=8C?= =?UTF-8?q?=E5=90=A6=E5=88=99=E7=9B=B4=E6=8E=A5=E8=A6=86=E7=9B=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王桢 --- frameworks/native/backup_ext/include/ext_backup.h | 3 +++ frameworks/native/backup_ext/src/ext_backup.cpp | 6 ++++++ frameworks/native/backup_ext/src/ext_backup_js.cpp | 1 + frameworks/native/backup_ext/src/ext_extension.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/frameworks/native/backup_ext/include/ext_backup.h b/frameworks/native/backup_ext/include/ext_backup.h index 73d64e731..81b9e54a5 100644 --- a/frameworks/native/backup_ext/include/ext_backup.h +++ b/frameworks/native/backup_ext/include/ext_backup.h @@ -127,6 +127,8 @@ public: bool WasFromSpeicalVersion(void); + bool UseCustomAbility(void); + public: ExtBackup() = default; ~ExtBackup() override = default; @@ -137,6 +139,7 @@ protected: std::string appVersionStr_; int appVersionCode_; int restoreType_; + bool useCustomAbility_; private: BConstants::ExtensionAction VerifyAndGetAction(const AAFwk::Want &want, diff --git a/frameworks/native/backup_ext/src/ext_backup.cpp b/frameworks/native/backup_ext/src/ext_backup.cpp index cf584ce06..b804be233 100644 --- a/frameworks/native/backup_ext/src/ext_backup.cpp +++ b/frameworks/native/backup_ext/src/ext_backup.cpp @@ -50,6 +50,7 @@ void ExtBackup::Init(const shared_ptr &recor { HILOGI("Init the BackupExtensionAbility(Base)"); AbilityRuntime::ExtensionBase::Init(record, application, handler, token); + useCustomAbility_ = false; } ExtBackup *ExtBackup::Create(const unique_ptr &runtime) @@ -217,6 +218,11 @@ bool ExtBackup::WasFromSpeicalVersion(void) return false; } +bool ExtBackup::UseCustomAbility(void) +{ + return useCustomAbility_; +} + ErrCode ExtBackup::OnBackup(function callback) { HILOGI("BackupExtensionAbility(base) OnBackup."); diff --git a/frameworks/native/backup_ext/src/ext_backup_js.cpp b/frameworks/native/backup_ext/src/ext_backup_js.cpp index ef8cd0e7a..345c9e4ae 100644 --- a/frameworks/native/backup_ext/src/ext_backup_js.cpp +++ b/frameworks/native/backup_ext/src/ext_backup_js.cpp @@ -133,6 +133,7 @@ void ExtBackupJs::Init(const shared_ptr &record, HILOGW("Oops! There's no custom BackupExtensionAbility"); return; } + useCustomAbility_ = true; HILOGI("Wow! Here's a custsom BackupExtensionAbility"); ExportJsContext(); } catch (const BError &e) { diff --git a/frameworks/native/backup_ext/src/ext_extension.cpp b/frameworks/native/backup_ext/src/ext_extension.cpp index 53cdf9bd1..87e9685ae 100644 --- a/frameworks/native/backup_ext/src/ext_extension.cpp +++ b/frameworks/native/backup_ext/src/ext_extension.cpp @@ -312,7 +312,7 @@ int BackupExtExtension::DoRestore(const string &fileName) string tarName = path + fileName; auto tarballFunc = BTarballFactory::Create("cmdline", tarName); - if (extension_->WasFromSpeicalVersion()) { + if (extension_->WasFromSpeicalVersion() || extension_->UseCustomAbility()) { (tarballFunc->untar)(path); } else { (tarballFunc->untar)("/"); -- Gitee