diff --git a/frameworks/native/backup_ext/include/ext_backup.h b/frameworks/native/backup_ext/include/ext_backup.h index 73d64e73181e2126d2339328bf56d177a21d58a1..81b9e54a53c9f1f4e01b9de5b0bac422bac9315b 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 cf584ce068b64f7790ee38daa39936c1cfc0bc24..b804be2332ca71b6d557dfb971a7207cffb82d2e 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 ef8cd0e7a80be9c20a7fc2567253f9a7bbc132f9..345c9e4aedd0badf48fcfb878720fb27ae4f164d 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 53cdf9bd15c3bc2bf2d063b56c12990ffcf7d08e..87e9685ae604a6f417110e49378b63dbef1096cc 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)("/");