mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
commit
ea51bcf9fe
@ -47,6 +47,7 @@ struct FullImeInfo {
|
||||
bool isNewIme{ false };
|
||||
uint32_t tokenId{ 0 };
|
||||
std::string appId;
|
||||
uint32_t versionCode;
|
||||
Property prop;
|
||||
std::vector<SubProperty> subProps;
|
||||
};
|
||||
|
@ -124,8 +124,10 @@ bool SecurityModeParser::IsDefaultFullMode(const std::string &bundleName, int32_
|
||||
return true;
|
||||
}
|
||||
std::string appId;
|
||||
if (!ImeInfoInquirer::GetInstance().GetImeAppId(userId, bundleName, appId)) {
|
||||
IMSA_HILOGE("%{public}s failed to get app id", bundleName.c_str());
|
||||
uint32_t versionCode;
|
||||
if (!ImeInfoInquirer::GetInstance().GetImeAppId(userId, bundleName, appId)
|
||||
|| !ImeInfoInquirer::GetInstance().GetImeVersionCode(userId, bundleName, versionCode)) {
|
||||
IMSA_HILOGE("%{public}s failed to get appId and versionCode", bundleName.c_str());
|
||||
return false;
|
||||
}
|
||||
std::vector<DefaultFullImeInfo> defaultFullImeList;
|
||||
@ -139,7 +141,12 @@ bool SecurityModeParser::IsDefaultFullMode(const std::string &bundleName, int32_
|
||||
IMSA_HILOGD("not default FULL");
|
||||
return false;
|
||||
}
|
||||
bool isDefaultFull = !IsExpired(ime->expirationTime);
|
||||
bool isDefaultFull = false;
|
||||
if (ime->expirationVersionCode > 0) {
|
||||
isDefaultFull = !IsExpired(ime->expirationTime) || versionCode < ime->expirationVersionCode;
|
||||
} else {
|
||||
isDefaultFull = !IsExpired(ime->expirationTime);
|
||||
}
|
||||
IMSA_HILOGI("ime: %{public}s, isDefaultFull: %{public}d", bundleName.c_str(), isDefaultFull);
|
||||
return isDefaultFull;
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
std::shared_ptr<SubProperty> FindTargetSubtypeByCondition(const std::vector<SubProperty> &subProps,
|
||||
const Condition &condition);
|
||||
bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId);
|
||||
bool GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode);
|
||||
int32_t GetDefaultInputMethod(const int32_t userId, std::shared_ptr<Property> &prop, bool isBrief = false);
|
||||
int32_t GetInputMethodConfig(const int32_t userId, AppExecFwk::ElementName &inputMethodConfig);
|
||||
int32_t ListInputMethod(int32_t userId, InputMethodStatus status, std::vector<Property> &props, bool enableOn);
|
||||
@ -105,7 +106,7 @@ private:
|
||||
SubProperty GetExtends(const std::vector<OHOS::AppExecFwk::Metadata> &metaData);
|
||||
std::string GetStringById(const std::string &bundleName, const std::string &moduleName, const uint32_t labelId,
|
||||
const int32_t userId);
|
||||
bool GetAppIdByBundleName(int32_t userId, const std::string &bundleName, std::string &appId);
|
||||
bool GetBundleInfoByBundleName(int32_t userId, const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo);
|
||||
std::shared_ptr<ImeInfo> GetImeInfoFromCache(const int32_t userId, const std::string &bundleName,
|
||||
const std::string &subName);
|
||||
std::shared_ptr<ImeInfo> GetImeInfoFromBundleMgr(
|
||||
|
@ -100,10 +100,12 @@ struct SysPanelAdjustCfg : public Serializable {
|
||||
struct DefaultFullImeInfo : public Serializable {
|
||||
std::string appId;
|
||||
std::string expirationTime;
|
||||
uint32_t expirationVersionCode{ 0 };
|
||||
bool Unmarshal(cJSON *node) override
|
||||
{
|
||||
bool ret = GetValue(node, GET_NAME(appIdentifier), appId);
|
||||
ret &= GetValue(node, GET_NAME(expirationTime), expirationTime);
|
||||
GetValue(node, GET_NAME(expirationVersionCode), expirationVersionCode);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
@ -1063,8 +1063,10 @@ int32_t ImeInfoInquirer::GetFullImeInfo(
|
||||
GetStringById(extInfos[0].bundleName, extInfos[0].moduleName, extInfos[0].applicationInfo.labelId, userId);
|
||||
imeInfo.prop.labelId = extInfos[0].applicationInfo.labelId;
|
||||
imeInfo.prop.iconId = extInfos[0].applicationInfo.iconId;
|
||||
if (!GetAppIdByBundleName(userId, imeInfo.prop.name, imeInfo.appId)) {
|
||||
IMSA_HILOGE("%{public}s failed to get app id!", imeInfo.prop.name.c_str());
|
||||
BundleInfo bundleInfo;
|
||||
if (GetBundleInfoByBundleName(userId, imeInfo.prop.name, bundleInfo)) {
|
||||
imeInfo.appId = bundleInfo.signatureInfo.appIdentifier;
|
||||
imeInfo.versionCode = bundleInfo.versionCode;
|
||||
}
|
||||
return ErrorCode::NO_ERROR;
|
||||
}
|
||||
@ -1130,25 +1132,44 @@ bool ImeInfoInquirer::GetImeAppId(int32_t userId, const std::string &bundleName,
|
||||
appId = imeInfo.appId;
|
||||
return true;
|
||||
}
|
||||
return GetAppIdByBundleName(userId, bundleName, appId);
|
||||
BundleInfo bundleInfo;
|
||||
if (!GetBundleInfoByBundleName(userId, bundleName, bundleInfo)) {
|
||||
return false;
|
||||
}
|
||||
appId = bundleInfo.signatureInfo.appIdentifier;
|
||||
return !appId.empty();
|
||||
}
|
||||
|
||||
bool ImeInfoInquirer::GetAppIdByBundleName(int32_t userId, const std::string &bundleName, std::string &appId)
|
||||
bool ImeInfoInquirer::GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode)
|
||||
{
|
||||
FullImeInfo imeInfo;
|
||||
if (FullImeInfoManager::GetInstance().Get(bundleName, userId, imeInfo)) {
|
||||
versionCode = imeInfo.versionCode;
|
||||
return true;
|
||||
}
|
||||
BundleInfo bundleInfo;
|
||||
if (!GetBundleInfoByBundleName(userId, bundleName, bundleInfo)) {
|
||||
return false;
|
||||
}
|
||||
versionCode = bundleInfo.versionCode;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImeInfoInquirer::GetBundleInfoByBundleName(
|
||||
int32_t userId, const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo)
|
||||
{
|
||||
auto bundleMgr = GetBundleMgr();
|
||||
if (bundleMgr == nullptr) {
|
||||
IMSA_HILOGE("failed to get bundleMgr!");
|
||||
return false;
|
||||
}
|
||||
BundleInfo bundleInfo;
|
||||
auto ret = bundleMgr->GetBundleInfo(
|
||||
bundleName, static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO), bundleInfo, userId);
|
||||
if (!ret) {
|
||||
IMSA_HILOGE("failed to get bundle info");
|
||||
return false;
|
||||
}
|
||||
appId = bundleInfo.signatureInfo.appIdentifier;
|
||||
return !appId.empty();
|
||||
return true;
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -42,10 +42,16 @@ std::shared_ptr<Property> ImeInfoInquirer::GetDefaultImeCfgProp()
|
||||
return defaultImeProperty_;
|
||||
}
|
||||
|
||||
bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId)
|
||||
bool ImeInfoInquirer::GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId)
|
||||
{
|
||||
appId = MOCK_APP_ID;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImeInfoInquirer::GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode)
|
||||
{
|
||||
versionCode = 0;
|
||||
return true;
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -33,6 +33,7 @@ public:
|
||||
std::shared_ptr<Property> GetCurrentInputMethod(int32_t userId);
|
||||
std::shared_ptr<Property> GetDefaultImeCfgProp();
|
||||
bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId);
|
||||
bool GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<ImeInfo> defaultIme_;
|
||||
|
Loading…
Reference in New Issue
Block a user