fix telephony data stage.

Signed-off-by: dingxiaochen <dingxiaochen@huawei.com>
This commit is contained in:
dingxiaochen 2023-03-02 17:40:02 +08:00
parent de145307c9
commit 5dfd82cd3f
3 changed files with 23 additions and 31 deletions

View File

@ -103,7 +103,7 @@ bool SettingUtils::Query(Uri uri, const std::string &key, std::string &value)
return false;
}
if (result->GoToFirstRow() != NativeRdb::E_OK) {
if (result->GoToFirstRow() != DataShare::E_OK) {
TELEPHONY_LOGE("SettingUtils: query error, go to first row error");
return false;
}

View File

@ -20,12 +20,13 @@
#include <libxml/xmlmemory.h>
#include <vector>
#include "abs_shared_result_set.h"
#include "common_event.h"
#include "common_event_manager.h"
#include "config_policy_utils.h"
#include "data_ability_helper.h"
#include "data_ability_predicates.h"
#include "datashare_helper.h"
#include "datashare_predicates.h"
#include "datashare_result_set.h"
#include "datashare_values_bucket.h"
#include "event_handler.h"
#include "inner_event.h"
#include "iremote_broker.h"
@ -35,14 +36,12 @@
#include "sim_file_manager.h"
#include "system_ability_definition.h"
#include "telephony_log_wrapper.h"
#include "uri.h"
#include "values_bucket.h"
#include "want.h"
namespace OHOS {
namespace Telephony {
static const std::string OPKEY_URI = "dataability:///com.ohos.opkeyability";
const std::string OPKEY_INFO_URI = "dataability:///com.ohos.opkeyability/opkey/opkey_info";
static const std::string OPKEY_URI = "datashare:///com.ohos.opkeyability";
const std::string OPKEY_INFO_URI = "datashare:///com.ohos.opkeyability/opkey/opkey_info";
class OperatorConfigLoader {
public:
@ -53,16 +52,15 @@ public:
private:
std::string LoadOpKeyOnMccMnc(int32_t slotId);
std::shared_ptr<AppExecFwk::DataAbilityHelper> CreateDataAHelper(
int32_t systemAbilityId, std::shared_ptr<Uri> dataAbilityUri) const;
std::shared_ptr<AppExecFwk::DataAbilityHelper> CreateOpKeyHelper();
std::string GetOpKey(std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet, int32_t slotId);
bool MatchOperatorRule(std::shared_ptr<NativeRdb::AbsSharedResultSet> &resultSet, int row);
std::shared_ptr<DataShare::DataShareHelper> CreateDataAHelper() const;
std::shared_ptr<DataShare::DataShareHelper> CreateOpKeyHelper();
std::string GetOpKey(std::shared_ptr<DataShare::DataShareResultSet> resultSet, int32_t slotId);
bool MatchOperatorRule(std::shared_ptr<DataShare::DataShareResultSet> &resultSet, int row);
private:
std::shared_ptr<SimFileManager> simFileManager_ = nullptr;
std::shared_ptr<OperatorConfigCache> operatorConfigCache_ = nullptr;
std::shared_ptr<AppExecFwk::DataAbilityHelper> opKeyDataAbilityHelper_ = nullptr;
std::shared_ptr<DataShare::DataShareHelper> opKeyDataAbilityHelper_ = nullptr;
std::string iccidFromSim_;
std::string imsiFromSim_;
std::string spnFromSim_;

View File

@ -57,23 +57,23 @@ std::string OperatorConfigLoader::LoadOpKeyOnMccMnc(int32_t slotId)
}
Uri uri(OPKEY_INFO_URI);
std::vector<std::string> colume;
NativeRdb::DataAbilityPredicates predicates;
std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet;
std::shared_ptr<AppExecFwk::DataAbilityHelper> helper = CreateOpKeyHelper();
DataShare::DataSharePredicates predicates;
std::shared_ptr<DataShare::DataShareResultSet> resultSet;
std::shared_ptr<DataShare::DataShareHelper> helper = CreateOpKeyHelper();
if (helper == nullptr || simFileManager_ == nullptr) {
TELEPHONY_LOGE("helper or simFileManager_ is nullptr");
return DEFAULT_OPERATOR_KEY;
}
std::string mccmncFromSim = Str16ToStr8(simFileManager_->GetSimOperatorNumeric());
predicates.EqualTo(MCCMNC, mccmncFromSim);
resultSet = helper->Query(uri, colume, predicates);
resultSet = helper->Query(uri, predicates, colume);
if (resultSet != nullptr) {
return GetOpKey(resultSet, slotId);
}
return DEFAULT_OPERATOR_KEY;
}
std::string OperatorConfigLoader::GetOpKey(std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet, int32_t slotId)
std::string OperatorConfigLoader::GetOpKey(std::shared_ptr<DataShare::DataShareResultSet> resultSet, int32_t slotId)
{
if (resultSet == nullptr) {
TELEPHONY_LOGE("GetOpKey resultSet is nullptr");
@ -119,7 +119,7 @@ std::string OperatorConfigLoader::GetOpKey(std::shared_ptr<NativeRdb::AbsSharedR
return opKeyVal;
}
bool OperatorConfigLoader::MatchOperatorRule(std::shared_ptr<NativeRdb::AbsSharedResultSet> &resultSet, int row)
bool OperatorConfigLoader::MatchOperatorRule(std::shared_ptr<DataShare::DataShareResultSet> &resultSet, int row)
{
if (resultSet == nullptr) {
TELEPHONY_LOGE("resultSet is nullptr");
@ -169,21 +169,15 @@ bool OperatorConfigLoader::MatchOperatorRule(std::shared_ptr<NativeRdb::AbsShare
return isAllRuleMatch;
}
std::shared_ptr<AppExecFwk::DataAbilityHelper> OperatorConfigLoader::CreateOpKeyHelper()
std::shared_ptr<DataShare::DataShareHelper> OperatorConfigLoader::CreateOpKeyHelper()
{
if (opKeyDataAbilityHelper_ == nullptr) {
std::shared_ptr<Uri> dataAbilityUri = std::make_shared<Uri>(OPKEY_URI);
if (dataAbilityUri == nullptr) {
TELEPHONY_LOGE("CreateOpKeyHelper dataAbilityUri is nullptr");
return nullptr;
}
opKeyDataAbilityHelper_ = CreateDataAHelper(TELEPHONY_CORE_SERVICE_SYS_ABILITY_ID, dataAbilityUri);
opKeyDataAbilityHelper_ = CreateDataAHelper();
}
return opKeyDataAbilityHelper_;
}
std::shared_ptr<AppExecFwk::DataAbilityHelper> OperatorConfigLoader::CreateDataAHelper(
int32_t systemAbilityId, std::shared_ptr<Uri> dataAbilityUri) const
std::shared_ptr<DataShare::DataShareHelper> OperatorConfigLoader::CreateDataAHelper() const
{
TELEPHONY_LOGI("OperatorConfigLoader::CreateDataAHelper");
auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
@ -191,12 +185,12 @@ std::shared_ptr<AppExecFwk::DataAbilityHelper> OperatorConfigLoader::CreateDataA
TELEPHONY_LOGE("OperatorConfigLoader Get system ability mgr failed");
return nullptr;
}
auto remoteObj = saManager->GetSystemAbility(systemAbilityId);
auto remoteObj = saManager->GetSystemAbility(TELEPHONY_CORE_SERVICE_SYS_ABILITY_ID);
if (remoteObj == nullptr) {
TELEPHONY_LOGE("OperatorConfigLoader GetSystemAbility Service Failed");
return nullptr;
}
return AppExecFwk::DataAbilityHelper::Creator(remoteObj, dataAbilityUri);
return DataShare::DataShareHelper::Creator(remoteObj, OPKEY_URI);
}
} // namespace Telephony
} // namespace OHOS