mini 最小系统隔离,宏定义去除

Signed-off-by: 邹友松 <zouyousong1@h-partners.com>
This commit is contained in:
邹友松
2023-08-04 09:16:36 +08:00
parent 0b3a2aac78
commit 953f202314
24 changed files with 575 additions and 184 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ config("updateengine_inner_library_native_config") {
]
}
ohos_static_library("$updateengine_inner_library_name") {
ohos_shared_library("$updateengine_inner_library_name") {
defines = [ "DUAL_ADAPTER" ]
sources = [
"$updateengine_root_path/interfaces/inner_api/engine/update_service_kits_impl.cpp",
@@ -19,9 +19,7 @@
#include "update_define.h"
#include "update_helper.h"
#include "update_log.h"
#ifdef ABILITY_BASE_ENABLE
#include "update_notify.h"
#endif
#include "update_service.h"
#include "update_service_cache.h"
#include "update_service_util.h"
@@ -102,9 +100,7 @@ void BaseCallbackUtils::NotifyToHap(EventInfo &info)
ENGINE_LOGI("Notify eventInfoStr %{public}s", eventInfoStr.c_str());
if (!eventInfoStr.empty()) {
SubscribeInfo subscribeInfo{GetBusinessSubType()};
#ifdef ABILITY_BASE_ENABLE
OHOS::UpdateEngine::UpdateNotify::NotifyToAppService(eventInfoStr, subscribeInfo.ToJson());
#endif
}
}
} // namespace UpdateEngine
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2023 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 "base_callback_utils.h"
#include "iupdate_callback.h"
#include "update_define.h"
#include "update_helper.h"
#include "update_log.h"
#include "update_service.h"
#include "update_service_cache.h"
#include "update_service_util.h"
namespace OHOS {
namespace UpdateEngine {
void BaseCallbackUtils::NotifyEvent(const std::string &versionDigestInfo, EventId eventId, UpgradeStatus status,
const ErrorMessage &errorMessage, const std::vector<VersionComponent> &versionComponents)
{
ENGINE_LOGI("BaseCallbackUtils NotifyEvent");
}
void BaseCallbackUtils::ProgressCallback(const std::string &versionDigestInfo, const Progress &progress)
{
ENGINE_LOGI("BaseCallbackUtils ProgressCallback");
}
void BaseCallbackUtils::CallbackToHap(EventInfo &eventInfo)
{
ENGINE_LOGI("BaseCallbackUtils CallbackToHap");
}
sptr<IUpdateCallback> BaseCallbackUtils::GetUpgradeCallback(const UpgradeInfo &upgradeInfo)
{
return nullptr;
}
void BaseCallbackUtils::NotifyToHap(EventInfo &info)
{
ENGINE_LOGI("BaseCallbackUtils NotifyToHap");
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -17,15 +17,11 @@
#include <ohos_types.h>
#ifdef NATIVE_PREFERENCES_ENABLE
#include "preferences_helper.h"
#endif
#include "update_log.h"
namespace OHOS {
namespace UpdateEngine {
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> PreferencesUtil::GetPreference()
{
std::string path = GetPath();
@@ -40,19 +36,14 @@ std::shared_ptr<NativePreferences::Preferences> PreferencesUtil::GetPreference()
}
return ptr;
}
#endif
bool PreferencesUtil::DeletePreference()
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::string path = GetPath();
if (path.empty()) {
return false;
}
return NativePreferences::PreferencesHelper::DeletePreferences(path) == NativePreferences::E_OK;
#else
return true;
#endif
}
bool PreferencesUtil::SaveString(const std::string &key, const std::string &value)
@@ -83,7 +74,6 @@ bool PreferencesUtil::SaveFloat(const std::string &key, float value)
template <typename T>
bool PreferencesUtil::Save(const std::string &key, const T &value)
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
return false;
@@ -93,12 +83,8 @@ bool PreferencesUtil::Save(const std::string &key, const T &value)
return false;
}
return RefreshSync();
#else
return true;
#endif
}
#ifdef NATIVE_PREFERENCES_ENABLE
bool PreferencesUtil::SaveInner(
std::shared_ptr<NativePreferences::Preferences> ptr, const std::string &key, const std::string &value)
{
@@ -128,7 +114,6 @@ bool PreferencesUtil::SaveInner(
{
return ptr->PutFloat(key, value) == NativePreferences::E_OK;
}
#endif
std::string PreferencesUtil::ObtainString(const std::string &key, const std::string &defValue)
{
@@ -158,7 +143,6 @@ float PreferencesUtil::ObtainFloat(const std::string &key, float defValue)
template <typename T>
T PreferencesUtil::Obtain(const std::string &key, const T &defValue)
{
#ifdef NATIVE_PREFERENCES_ENABLE
int errCode = OHOS_FAILURE;
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
@@ -166,12 +150,8 @@ T PreferencesUtil::Obtain(const std::string &key, const T &defValue)
return defValue;
}
return ObtainInner(ptr, key, defValue);
#else
return defValue;
#endif
}
#ifdef NATIVE_PREFERENCES_ENABLE
std::string PreferencesUtil::ObtainInner(
std::shared_ptr<NativePreferences::Preferences> ptr, const std::string &key, const std::string &defValue)
{
@@ -201,24 +181,18 @@ float PreferencesUtil::ObtainInner(
{
return ptr->GetFloat(key, defValue);
}
#endif
bool PreferencesUtil::IsExist(const std::string &key)
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
return false;
}
return ptr->HasKey(key);
#else
return true;
#endif
}
bool PreferencesUtil::Remove(const std::string &key)
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
return false;
@@ -227,14 +201,10 @@ bool PreferencesUtil::Remove(const std::string &key)
return false;
}
return RefreshSync();
#else
return true;
#endif
}
bool PreferencesUtil::RemoveAll()
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
return false;
@@ -243,14 +213,10 @@ bool PreferencesUtil::RemoveAll()
return false;
}
return RefreshSync();
#else
return true;
#endif
}
bool PreferencesUtil::RefreshSync()
{
#ifdef NATIVE_PREFERENCES_ENABLE
std::shared_ptr<NativePreferences::Preferences> ptr = GetPreference();
if (ptr == nullptr) {
ENGINE_LOGE("RefreshSync error ptr is null");
@@ -261,9 +227,6 @@ bool PreferencesUtil::RefreshSync()
return false;
}
return true;
#else
return true;
#endif
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2023 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 "preferences_utils.h"
#include <ohos_types.h>
#include "update_log.h"
namespace OHOS {
namespace UpdateEngine {
bool PreferencesUtil::DeletePreference()
{
return true;
}
bool PreferencesUtil::SaveString(const std::string &key, const std::string &value)
{
return true;
}
bool PreferencesUtil::SaveInt(const std::string &key, int value)
{
return true;
}
bool PreferencesUtil::SaveBool(const std::string &key, bool value)
{
return true;
}
bool PreferencesUtil::SaveLong(const std::string &key, int64_t value)
{
return true;
}
bool PreferencesUtil::SaveFloat(const std::string &key, float value)
{
return true;
}
template <typename T>
bool PreferencesUtil::Save(const std::string &key, const T &value)
{
return true;
}
std::string PreferencesUtil::ObtainString(const std::string &key, const std::string &defValue)
{
return defValue;
}
int PreferencesUtil::ObtainInt(const std::string &key, int defValue)
{
return defValue;
}
bool PreferencesUtil::ObtainBool(const std::string &key, bool defValue)
{
return defValue;
}
int64_t PreferencesUtil::ObtainLong(const std::string &key, int64_t defValue)
{
return defValue;
}
float PreferencesUtil::ObtainFloat(const std::string &key, float defValue)
{
return defValue;
}
template <typename T>
T PreferencesUtil::Obtain(const std::string &key, const T &defValue)
{
return defValue;
}
bool PreferencesUtil::IsExist(const std::string &key)
{
return true;
}
bool PreferencesUtil::Remove(const std::string &key)
{
return true;
}
bool PreferencesUtil::RemoveAll()
{
return true;
}
bool PreferencesUtil::RefreshSync()
{
return true;
}
} // namespace UpdateEngine
} // namespace OHOS
+57 -8
View File
@@ -45,8 +45,6 @@ sa_sources = [
"$updateengine_root_path/services/core/ability/adapter/src/device_adapter.cpp",
"$updateengine_root_path/services/core/ability/alarm/src/alarm_manager.cpp",
"$updateengine_root_path/services/core/ability/alarm/src/timer_manager.cpp",
"$updateengine_root_path/services/core/ability/callback/src/base_callback_utils.cpp",
"$updateengine_root_path/services/core/ability/preference/src/preference_utils.cpp",
"$updateengine_root_path/services/core/ability/status_cache/src/status_cache.cpp",
"$updateengine_root_path/services/core/ability/utils/src/file_utils.cpp",
"$updateengine_root_path/services/core/ability/utils/src/sha256_utils.cpp",
@@ -62,18 +60,35 @@ sa_sources = [
"$updateengine_root_path/services/engine/src/update_service_restorer.cpp",
"$updateengine_root_path/services/engine/src/update_service_stub.cpp",
"$updateengine_root_path/services/engine/src/update_service_util_hmos.cpp",
"$updateengine_root_path/services/utils/src/dupdate_net_manager.cpp",
"$updateengine_root_path/services/utils/src/dupdate_timer.c",
]
if (ability_ability_base_enable || ability_ability_runtime_enable) {
sa_sources +=
[ "$updateengine_root_path/services/engine/src/update_notify.cpp" ]
sa_sources += [
"$updateengine_root_path/services/core/ability/callback/src/base_callback_utils.cpp",
"$updateengine_root_path/services/engine/src/update_notify.cpp",
]
} else {
sa_sources += [ "$updateengine_root_path/services/core/ability/callback/src/base_callback_utils_empty.cpp" ]
}
if (communication_netmanager_base_enable) {
sa_sources +=
[ "$updateengine_root_path/services/utils/src/dupdate_net_observer.cpp" ]
sa_sources += [
"$updateengine_root_path/services/utils/src/dupdate_net_manager.cpp",
"$updateengine_root_path/services/utils/src/dupdate_net_observer.cpp",
]
} else {
sa_sources += [
"$updateengine_root_path/services/utils/src/dupdate_net_manager_empty.cpp",
]
}
if (preference_native_preferences_enable) {
sa_sources += [ "$updateengine_root_path/services/core/ability/preference/src/preference_utils.cpp" ]
} else {
sa_sources += [ "$updateengine_root_path/services/core/ability/preference/src/preference_utils_empty.cpp" ]
}
sa_sources += firmware_src
sa_sources += sqlite_src
sa_sources += update_log_src
@@ -108,9 +123,43 @@ sa_include_dirs = [
"//third_party/glib/glib",
"//third_party/glib",
"//third_party/openssl/include",
"third_party/cJSON/",
"//third_party/cJSON/",
]
if (!ability_ability_base_enable || !ability_ability_runtime_enable) {
sa_include_dirs += [
"//foundation/ability/ability_base/interfaces/inner_api/base/include",
"//foundation/ability/ability_base/interfaces/kits/native/uri/include",
"//foundation/ability/ability_base/interfaces/kits/native/want/include",
"//foundation/ability/ability_runtime/frameworks/simulator/common/include",
"//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include",
"//foundation/ability/ability_runtime/interfaces/inner_api/app_manager/include/appmgr",
"//foundation/ability/ability_runtime/interfaces/kits/native/ability/native",
"//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_base/include",
]
}
if (!preference_native_preferences_enable) {
sa_include_dirs += [
"//foundation/distributeddatamgr/preferences/interfaces/inner_api/include",
]
}
if (!communication_netmanager_base_enable) {
sa_include_dirs += [
"//foundation/communication/netmanager_base/interfaces/innerkits/include",
"//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient/include",
"//foundation/communication/netmanager_base/interfaces/innerkits/netconnclient/include/proxy",
]
}
if (!relational_store_native_rdb_enable) {
sa_include_dirs += [
"//base/update/updateservice/services/core/ability/sqlite/core/include",
"//foundation/distributeddatamgr/relational_store/interfaces/inner_api/rdb/include",
]
}
sa_include_dirs += firmware_include
sa_include_dirs += sqlite_include
sa_include_dirs += update_log_include
-2
View File
@@ -16,7 +16,6 @@
#ifndef UPDATE_NOTIFY_H
#define UPDATE_NOTIFY_H
#if defined(ABILITY_BASE_ENABLE) || defined(ABILITY_RUNTIME_ENABLE)
#include <string>
#include "ability_connect_callback_stub.h"
#include "ability_connect_callback_interface.h"
@@ -55,5 +54,4 @@ public:
};
} // namespace UpdateEngine
} // namespace OHOS
#endif // ABILITY_BASE_ENABLE || ABILITY_RUNTIME_ENABLE
#endif // UPDATE_NOTIFY_H
@@ -19,26 +19,8 @@
namespace OHOS {
namespace UpdateEngine {
#ifndef RELATIONAL_STORE_NATIVE_RDB_ENABLE
bool FirmwareComponentOperator::QueryAll(const std::vector<FirmwareComponent> &results)
{
return true;
}
bool FirmwareComponentOperator::Insert(const std::vector<FirmwareComponent> &values)
{
return true;
}
bool FirmwareComponentOperator::DeleteAll()
{
return true;
}
#endif
bool FirmwareComponentOperator::UpdateProgressByUrl(const std::string &url, UpgradeStatus status, int32_t progress)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_COMPONENT_STATUS, CAST_INT(status));
values.PutInt(COLUMN_COMPONENT_PROGRESS, progress);
@@ -46,28 +28,20 @@ bool FirmwareComponentOperator::UpdateProgressByUrl(const std::string &url, Upgr
OHOS::NativeRdb::RdbPredicates predicates(GetTableName());
predicates.EqualTo(COLUMN_COMPONENT_DOWNLOAD_URL, url);
return TableBaseOperator::Update(values, predicates);
#else
return true;
#endif
}
bool FirmwareComponentOperator::UpdateUrlByVersionId(const std::string &versionId, const std::string &url)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutString(COLUMN_COMPONENT_DOWNLOAD_URL, url);
OHOS::NativeRdb::RdbPredicates predicates(GetTableName());
predicates.EqualTo(COLUMN_COMPONENT_VERSION_ID, versionId);
return TableBaseOperator::Update(values, predicates);
#else
return true;
#endif
}
bool FirmwareComponentOperator::QueryByVersionId(const std::string &versionId, FirmwareComponent &component)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
std::vector<FirmwareComponent> components;
OHOS::NativeRdb::RdbPredicates predicates(GetTableName());
predicates.EqualTo(COLUMN_COMPONENT_VERSION_ID, versionId);
@@ -76,14 +50,10 @@ bool FirmwareComponentOperator::QueryByVersionId(const std::string &versionId, F
return true;
}
return false;
#else
return true;
#endif
}
bool FirmwareComponentOperator::QueryByUrl(const std::string &url, FirmwareComponent &component)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
std::vector<FirmwareComponent> components;
OHOS::NativeRdb::RdbPredicates predicates(GetTableName());
predicates.EqualTo(COLUMN_COMPONENT_DOWNLOAD_URL, url);
@@ -92,9 +62,6 @@ bool FirmwareComponentOperator::QueryByUrl(const std::string &url, FirmwareCompo
return true;
}
return false;
#else
return true;
#endif
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023 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 "firmware_component_operator.h"
#include <memory>
namespace OHOS {
namespace UpdateEngine {
bool FirmwareComponentOperator::QueryAll(const std::vector<FirmwareComponent> &results)
{
return true;
}
bool FirmwareComponentOperator::Insert(const std::vector<FirmwareComponent> &values)
{
return true;
}
bool FirmwareComponentOperator::DeleteAll()
{
return true;
}
bool FirmwareComponentOperator::UpdateProgressByUrl(const std::string &url, UpgradeStatus status, int32_t progress)
{
return true;
}
bool FirmwareComponentOperator::UpdateUrlByVersionId(const std::string &versionId, const std::string &url)
{
return true;
}
bool FirmwareComponentOperator::QueryByVersionId(const std::string &versionId, FirmwareComponent &component)
{
return true;
}
bool FirmwareComponentOperator::QueryByUrl(const std::string &url, FirmwareComponent &component)
{
return true;
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -17,9 +17,6 @@
namespace OHOS {
namespace UpdateEngine {
#ifndef RELATIONAL_STORE_NATIVE_RDB_ENABLE
const std::string COLUMN_ID = "id";
#endif
std::string FirmwareComponentTable::GetTableName()
{
return FIRMWARE_TABLE_COMPONENT;
@@ -61,7 +58,6 @@ std::string FirmwareComponentTable::GetTableCreateSql()
.append(")");
}
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
void FirmwareComponentTable::ParseDbValue(ResultSet *resultSet, FirmwareComponent &value)
{
GetColumnValue(resultSet, COLUMN_ID, value.id);
@@ -118,6 +114,5 @@ void FirmwareComponentTable::BuildDbValue(const FirmwareComponent &value, Native
PutColumnValue(dbValue, COLUMN_COMPONENT_STATUS, CAST_INT(value.status));
PutColumnValue(dbValue, COLUMN_COMPONENT_PROGRESS, value.progress);
}
#endif
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 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 "firmware_component_table.h"
namespace OHOS {
namespace UpdateEngine {
const std::string COLUMN_ID = "id";
std::string FirmwareComponentTable::GetTableName()
{
return FIRMWARE_TABLE_COMPONENT;
}
std::string FirmwareComponentTable::GetTableCreateSql()
{
return "";
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -48,18 +48,9 @@ std::string FirmwareDatabase::GetDbStoreDir()
return dbStoreDir_;
}
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::RdbOpenCallback &FirmwareDatabase::GetDbOpenCallback()
{
return dbOpenCallback_;
}
#endif
#ifndef RELATIONAL_STORE_NATIVE_RDB_ENABLE
bool FirmwareDatabase::DeleteDbStore()
{
return true;
}
#endif
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 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 "firmware_database.h"
#include "constant.h"
namespace OHOS {
namespace UpdateEngine {
const std::string FIRMWARE_DB_NAME = "/firmware_sqlite.db";
constexpr int32_t FIRMWARE_DB_VERSION = 1;
FirmwareDatabase::FirmwareDatabase()
{
ENGINE_LOGI("FirmwareDatabase Constructor");
}
FirmwareDatabase::~FirmwareDatabase() {}
std::string FirmwareDatabase::GetDbName()
{
return FIRMWARE_DB_NAME;
}
int32_t FirmwareDatabase::GetDbVersion()
{
return FIRMWARE_DB_VERSION;
}
void FirmwareDatabase::InitDbStoreDir()
{
ENGINE_LOGI("FirmwareDatabase InitDbStoreDir");
}
std::string FirmwareDatabase::GetDbStoreDir()
{
return "";
}
bool FirmwareDatabase::DeleteDbStore()
{
return true;
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -22,21 +22,8 @@
namespace OHOS {
namespace UpdateEngine {
#ifndef RELATIONAL_STORE_NATIVE_RDB_ENABLE
bool FirmwareTaskOperator::Insert(const FirmwareTask &values)
{
return true;
}
bool FirmwareTaskOperator::DeleteAll()
{
return true;
}
#endif
void FirmwareTaskOperator::QueryTask(FirmwareTask &task)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
std::vector<FirmwareTask> taskList;
QueryAll(taskList);
if (taskList.empty()) {
@@ -46,132 +33,89 @@ void FirmwareTaskOperator::QueryTask(FirmwareTask &task)
}
task = taskList[0];
task.isExistTask = true;
#endif
}
bool FirmwareTaskOperator::UpdateProgressByTaskId(const std::string &taskId, UpgradeStatus status, int32_t progress)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_STATUS, CAST_INT(status));
values.PutInt(COLUMN_TASK_PROGRESS, progress);
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateErrMsgByTaskId(const std::string &taskId, int errorCode, const std::string &errorMsg)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_ERROR_CODE, errorCode);
values.PutString(COLUMN_TASK_ERROR_MSG, errorMsg);
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateDownloadTaskIdByTaskId(const std::string &taskId, const std::string &downloadTaskId)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutString(COLUMN_TASK_DOWNLOAD_TASK_ID, downloadTaskId);
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateCombinationTypeByTaskId(const std::string &taskId,
const CombinationType &combinationType)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_COMBINATION_TYPE, CAST_INT(combinationType));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateDownloadModeByTaskId(const std::string &taskId, DownloadMode downloadMode)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_DOWNLOAD_MODE, CAST_INT(downloadMode));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateDownloadAllowNetworkByTaskId(const std::string &taskId, NetType downloadAllowNetwork)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_DOWNLOAD_ALLOW_NETWORK, CAST_INT(downloadAllowNetwork));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateDownloadOrderByTaskId(const std::string &taskId, Order downloadOrder)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_DOWNLOAD_ORDER, CAST_INT(downloadOrder));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateDownloadOptionByTaskId(
const std::string &taskId, DownloadMode downloadMode, NetType downloadAllowNetwork, Order downloadOrder)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_DOWNLOAD_MODE, CAST_INT(downloadMode));
values.PutInt(COLUMN_TASK_DOWNLOAD_ALLOW_NETWORK, CAST_INT(downloadAllowNetwork));
values.PutInt(COLUMN_TASK_DOWNLOAD_ORDER, CAST_INT(downloadOrder));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateUpgradeModeByTaskId(const std::string &taskId, UpgradeMode upgradeMode)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_UPGRADE_MODE, CAST_INT(upgradeMode));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
bool FirmwareTaskOperator::UpdateUpgradeOrderByTaskId(const std::string &taskId, Order upgradeOrder)
{
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
NativeRdb::ValuesBucket values;
values.PutInt(COLUMN_TASK_UPGRADE_ORDER, CAST_INT(upgradeOrder));
return UpdateByTaskId(taskId, values);
#else
return true;
#endif
}
#ifdef RELATIONAL_STORE_NATIVE_RDB_ENABLE
bool FirmwareTaskOperator::UpdateByTaskId(const std::string &taskId, const NativeRdb::ValuesBucket &values)
{
OHOS::NativeRdb::RdbPredicates predicates(GetTableName());
predicates.EqualTo(COLUMN_TASK_TASK_ID, taskId);
return TableBaseOperator::Update(values, predicates);
}
#endif
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2023 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 "firmware_task_operator.h"
#include <memory>
#include "time_utils.h"
#include "update_helper.h"
namespace OHOS {
namespace UpdateEngine {
bool FirmwareTaskOperator::Insert(const FirmwareTask &values)
{
return true;
}
bool FirmwareTaskOperator::DeleteAll()
{
return true;
}
void FirmwareTaskOperator::QueryTask(FirmwareTask &task)
{
FIRMWARE_LOGI("FirmwareTaskOperator QueryTask");
}
bool FirmwareTaskOperator::UpdateProgressByTaskId(const std::string &taskId, UpgradeStatus status, int32_t progress)
{
return true;
}
bool FirmwareTaskOperator::UpdateErrMsgByTaskId(const std::string &taskId, int errorCode, const std::string &errorMsg)
{
return true;
}
bool FirmwareTaskOperator::UpdateDownloadTaskIdByTaskId(const std::string &taskId, const std::string &downloadTaskId)
{
return true;
}
bool FirmwareTaskOperator::UpdateCombinationTypeByTaskId(const std::string &taskId,
const CombinationType &combinationType)
{
return true;
}
bool FirmwareTaskOperator::UpdateDownloadModeByTaskId(const std::string &taskId, DownloadMode downloadMode)
{
return true;
}
bool FirmwareTaskOperator::UpdateDownloadAllowNetworkByTaskId(const std::string &taskId, NetType downloadAllowNetwork)
{
return true;
}
bool FirmwareTaskOperator::UpdateDownloadOrderByTaskId(const std::string &taskId, Order downloadOrder)
{
return true;
}
bool FirmwareTaskOperator::UpdateDownloadOptionByTaskId(
const std::string &taskId, DownloadMode downloadMode, NetType downloadAllowNetwork, Order downloadOrder)
{
return true;
}
bool FirmwareTaskOperator::UpdateUpgradeModeByTaskId(const std::string &taskId, UpgradeMode upgradeMode)
{
return true;
}
bool FirmwareTaskOperator::UpdateUpgradeOrderByTaskId(const std::string &taskId, Order upgradeOrder)
{
return true;
}
} // namespace UpdateEngine
} // namespace OHOS
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 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 "firmware_task_table.h"
#include "itable.h"
#include "update_define.h"
namespace OHOS {
namespace UpdateEngine {
std::string FirmwareTaskTable::GetTableName()
{
return "";
}
std::string FirmwareTaskTable::GetTableCreateSql()
{
return "";
}
} // namespace UpdateEngine
} // namespace OHOS
+13 -4
View File
@@ -55,10 +55,6 @@ ab_update_src = [
firmware_src = [
"$firmware_root_path/callback/src/firmware_callback_utils.cpp",
"$firmware_root_path/common/src/firmware_update_helper.cpp",
"$firmware_root_path/data/db/src/firmware_component_operator.cpp",
"$firmware_root_path/data/db/src/firmware_component_table.cpp",
"$firmware_root_path/data/db/src/firmware_database.cpp",
"$firmware_root_path/data/db/src/firmware_task_operator.cpp",
"$firmware_root_path/data/manager/src/firmware_preferences_utils.cpp",
"$firmware_root_path/event/src/firmware_event_listener.cpp",
"$firmware_root_path/upgrade/data_processor/src/firmware_check_data_processor.cpp",
@@ -82,11 +78,24 @@ firmware_src = [
"$firmware_root_path/utils/src/firmware_changelog_utils.cpp",
"$firmware_root_path/utils/src/firmware_combine_version_utils.cpp",
]
if (relational_store_native_rdb_enable) {
firmware_src += [
"$firmware_root_path/data/db/src/firmware_component_operator.cpp",
"$firmware_root_path/data/db/src/firmware_component_table.cpp",
"$firmware_root_path/data/db/src/firmware_database.cpp",
"$firmware_root_path/data/db/src/firmware_database_callback.cpp",
"$firmware_root_path/data/db/src/firmware_task_operator.cpp",
"$firmware_root_path/data/db/src/firmware_task_table.cpp",
]
} else {
firmware_src += [
"$firmware_root_path/data/db/src/firmware_component_operator_empty.cpp",
"$firmware_root_path/data/db/src/firmware_component_table_empty.cpp",
"$firmware_root_path/data/db/src/firmware_database_empty.cpp",
"$firmware_root_path/data/db/src/firmware_task_operator_empty.cpp",
"$firmware_root_path/data/db/src/firmware_task_table_empty.cpp",
]
}
firmware_src += ab_update_src
@@ -18,9 +18,7 @@
#include "config_parse.h"
#include "constant.h"
#include "dupdate_inet_observer.h"
#ifdef NETMANAGER_BASE_ENABLE
#include "dupdate_net_observer.h"
#endif
#include "firmware_changelog_utils.h"
#include "firmware_combine_version_utils.h"
#include "firmware_common.h"
@@ -16,9 +16,7 @@
#include "firmware_apply_executor.h"
#include <unistd.h>
#ifndef RELATIONAL_STORE_NATIVE_RDB_ENABLE
#include <thread>
#endif
#include "init_reboot.h"
@@ -33,22 +33,13 @@ using NetObserverCallback = std::function<void(NetType)>;
class INetObserverCallback {
public:
#ifdef NETMANAGER_BASE_ENABLE
virtual bool OnNetChange(NetType netType) = 0;
#else
bool OnNetChange(NetType netType);
#endif
};
class DupdateINetObserver {
public:
#ifdef NETMANAGER_BASE_ENABLE
virtual void SetCallback(const std::weak_ptr<INetObserverCallback> &callback) = 0;
virtual void StartObserver() = 0;
#else
void SetCallback(const std::weak_ptr<INetObserverCallback> &callback);
void StartObserver();
#endif
};
} // namespace UpdateEngine
} // namespace OHOS
@@ -44,18 +44,12 @@ public:
NetChangeCallbackType callbackType, const std::set<NetType> &netTypes, NetObserverCallback cb);
void UnregisterCallback(NetChangeCallbackType callbackType);
#ifdef NETMANAGER_BASE_ENABLE
bool OnNetChange(NetType netType) final;
#else
bool OnNetChange(NetType netType);
#endif
private:
bool IsBaseNetType(NetType netType);
#ifdef NETMANAGER_BASE_ENABLE
sptr<NetObserver> observer_ = nullptr;
#endif
std::mutex netChangeMutex_;
NetType netType_ = NetType::NO_NET;
std::map<NetChangeCallbackType, NetChangeCallback> netChangeCallbackMap_;
@@ -16,7 +16,6 @@
#ifndef DUPDATE_NET_OBSERVER_H
#define DUPDATE_NET_OBSERVER_H
#ifdef NETMANAGER_BASE_ENABLE
#include "net_all_capabilities.h"
#include "net_conn_callback_stub.h"
#include "net_specifier.h"
@@ -40,5 +39,4 @@ private:
};
} // namespace UpdateEngine
} // namespace OHOS
#endif // NETMANAGER_BASE_ENABLE
#endif // DUPDATE_NET_OBSERVER_H
@@ -25,16 +25,13 @@ namespace OHOS {
namespace UpdateEngine {
NetManager::NetManager()
{
#ifdef NETMANAGER_BASE_ENABLE
observer_ = new NetObserver();
#endif
}
NetManager::~NetManager() {}
void NetManager::Init()
{
#ifdef NETMANAGER_BASE_ENABLE
ENGINE_LOGI("NetManager init");
if (observer_ == nullptr) {
ENGINE_LOGE("net ovserver is nullptr");
@@ -42,7 +39,6 @@ void NetManager::Init()
}
observer_->SetCallback(weak_from_this());
observer_->StartObserver();
#endif
}
bool NetManager::RegisterCallback(
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2023 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 "dupdate_net_manager.h"
#include <thread>
#include <unistd.h>
#include "update_define.h"
#include "update_log.h"
namespace OHOS {
namespace UpdateEngine {
NetManager::NetManager()
{
ENGINE_LOGI("NetManager NetManager");
}
NetManager::~NetManager() {}
void NetManager::Init()
{
ENGINE_LOGI("NetManager init");
}
bool NetManager::RegisterCallback(
NetChangeCallbackType callbackType, const std::set<NetType> &netTypes, NetObserverCallback cb)
{
ENGINE_LOGI("NetManager RegisterCallback");
return true;
}
void NetManager::UnregisterCallback(NetChangeCallbackType callbackType)
{
ENGINE_LOGI("NetManager UnregisterCallback");
}
NetType NetManager::GetNetType()
{
return netType_;
}
bool NetManager::IsNetAvailable(NetType netType)
{
return true;
}
bool NetManager::OnNetChange(NetType netType)
{
ENGINE_LOGI("NetManager OnNetChange");
return true;
}
bool NetManager::IsBaseNetType(NetType netType)
{
return true;
}
} // namespace UpdateEngine
} // namespace OHOS