mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-23 06:40:06 +00:00
!853 【3.1Release】修改crash
Merge pull request !853 from mashaoyin/OpenHarmony-3.1-Release
This commit is contained in:
commit
b9a10e76cc
@ -28,24 +28,29 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
class Utils {
|
||||
public:
|
||||
static std::string to_utf8(std::u16string str16)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.to_bytes(str16);
|
||||
constexpr int32_t MAIN_USER_ID = 100;
|
||||
class Utils {
|
||||
public:
|
||||
static std::string to_utf8(std::u16string str16)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(str16);
|
||||
}
|
||||
static std::u16string to_utf16(std::string str)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(str);
|
||||
}
|
||||
static int32_t GetUserId()
|
||||
{
|
||||
std::vector<int32_t> userIds;
|
||||
auto ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds);
|
||||
if (ret != ErrorCode::NO_ERROR || userIds.empty()) {
|
||||
IMSA_HILOGE("query active os account id failed");
|
||||
return MAIN_USER_ID;
|
||||
}
|
||||
static std::u16string to_utf16(std::string str)
|
||||
{
|
||||
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> {}.from_bytes(str);
|
||||
}
|
||||
static int32_t GetUserId()
|
||||
{
|
||||
std::vector<int32_t> userIds;
|
||||
AccountSA::OsAccountManager::QueryActiveOsAccountIds(userIds);
|
||||
return userIds[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return userIds[0];
|
||||
}
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user