diff --git a/frameworks/native/inputmethod_controller/IInputMethodSystemAbility.idl b/frameworks/native/inputmethod_controller/IInputMethodSystemAbility.idl index e24a1faf09133d99277388888ec00e2e5073a503..cbf590478d40b39d6f38f0ecb770f1a0f7b70ca3 100644 --- a/frameworks/native/inputmethod_controller/IInputMethodSystemAbility.idl +++ b/frameworks/native/inputmethod_controller/IInputMethodSystemAbility.idl @@ -60,6 +60,7 @@ interface OHOS.MiscServices.IInputMethodSystemAbility { void EnableIme([in] String bundleName, [out] boolean resultValue); void ConnectSystemCmd([in] IRemoteObject channel, [out] IRemoteObject agent); void GetInputMethodState([out] int state); + void UpdateBigMemoryState([in] int memoryState); void IsSystemApp([out] boolean resultValue); void HideCurrentInputDeprecated(); void ShowCurrentInputDeprecated(); diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index c9009bee9c453f7fac1e6d6c38967672f99ffdd0..0f1ece802bf9b420d42773036d5de1c8648be5fd 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp @@ -1626,6 +1626,17 @@ int32_t InputMethodController::GetInputMethodState(EnabledStatus &state) return ret; } +int32_t InputMethodController::UpdateBigMemoryState(const int32_t memoryState) +{ + IMSA_HILOGD("called."); + auto proxy = GetSystemAbilityProxy(); + if (proxy == nullptr) { + IMSA_HILOGE("proxy is nullptr"); + return ErrorCode::ERROR_NULL_POINTER; + } + return proxy->UpdateBigMemoryState(memoryState); +} + int32_t InputMethodController::SetPreviewText(const std::string &text, const Range &range) { auto ret = SetPreviewTextInner(text, range); diff --git a/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h b/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h index b14b45adbb56fb8007fd19f4959e99de9cb84c62..7fccd3d8a51cf5747823b46aca7751142710bced 100644 --- a/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h +++ b/interfaces/inner_api/inputmethod_controller/include/input_method_controller.h @@ -907,6 +907,8 @@ public: IMF_API void ReportBaseTextOperation(int32_t eventCode, int32_t errCode); + IMF_API int32_t UpdateBigMemoryState(const int32_t memoryState); + IMF_API void UpdateTextPreviewState(bool isSupport); /** diff --git a/services/include/input_method_system_ability.h b/services/include/input_method_system_ability.h index 3ccc7346f6c1827135dd748785a4bc9a8738e139..ebc13e1871140d600f1de5713b6b848c6aa96065 100644 --- a/services/include/input_method_system_ability.h +++ b/services/include/input_method_system_ability.h @@ -88,6 +88,7 @@ public: ErrCode EnableIme(const std::string &bundleName, bool& resultValue) override; ErrCode GetInputMethodState(int32_t &status) override; ErrCode IsSystemApp(bool& resultValue) override; + ErrCode UpdateBigMemoryState(const int32_t memoryState) override; int32_t RegisterProxyIme( uint64_t displayId, const sptr &core, const sptr &agent) override; int32_t UnregisterProxyIme(uint64_t displayId) override; diff --git a/services/include/peruser_session.h b/services/include/peruser_session.h index c7de5b2fdc30df8b7158d1b2e3782d40d522b582..964e24e36377b540a76646d28393deb4bd3e8617 100644 --- a/services/include/peruser_session.h +++ b/services/include/peruser_session.h @@ -55,6 +55,10 @@ enum class ImeAction : uint32_t { DO_ACTION_IN_NULL_IME_DATA, DO_ACTION_IN_IME_EVENT_CONVERT_FAILED, }; +enum BigMemoryState : int32_t { + BIG_MEMORY_START = 2, + BIG_MEMORY_END = 3, +}; struct ImeData { static constexpr int64_t START_TIME_OUT = 8000; sptr core{ nullptr }; @@ -149,6 +153,7 @@ public: int32_t SpecialSendPrivateData(const std::unordered_map &privateCommand); uint64_t GetDisplayGroupId(uint64_t displayId); bool IsDefaultDisplayGroup(uint64_t displayId); + int32_t UpdateBigMemoryState(const int32_t memoryState); private: struct ResetManager { @@ -277,6 +282,7 @@ private: std::atomic agentDisplayId_{ DEFAULT_DISPLAY_ID }; std::mutex clientGroupLock_{}; std::unordered_map> clientGroupMap_; + std::atomic memoryState_ = BigMemoryState::BIG_MEMORY_END; }; } // namespace MiscServices } // namespace OHOS diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index a16e64851b433f605adfee310347936c076c09b3..171a7beb905b13b48947eea9bff393d925cfd66e 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -2453,6 +2453,18 @@ ErrCode InputMethodSystemAbility::GetInputMethodState(int32_t& status) return ErrorCode::NO_ERROR; } +int32_t InputMethodSystemAbility::UpdateBigMemoryState(const int32_t memoryState) +{ + IMSA_HILOGD("UpdateBigMemory start."); + auto userId = GetCallingUserId(); + auto session = UserSessionManager::GetInstance().GetUserSession(userId_); + if (session == nullptr) { + IMSA_HILOGE("%{public}d session is nullptr.", userId); + return ErrorCode::ERROR_NULL_POINTER; + } + return session->UpdateBigMemoryState(memoryState); +} + int32_t InputMethodSystemAbility::GetInputMethodState( int32_t userId, const std::string &bundleName, EnabledStatus &status) { diff --git a/services/src/peruser_session.cpp b/services/src/peruser_session.cpp index 9fe291ebc51c8b195db0e36b008a3927f766ed4a..50223e97041b4ded15c3f2633894a997f45404bb 100644 --- a/services/src/peruser_session.cpp +++ b/services/src/peruser_session.cpp @@ -766,6 +766,20 @@ int32_t PerUserSession::OnUnregisterProxyIme(uint64_t displayId) return ErrorCode::NO_ERROR; } +int32_t PerUserSession::UpdateBigMemoryState(const int32_t memoryState) +{ + if (memoryState_ == memoryState) { + IMSA_HILOGI("big memory state: Duplicate message."); + return ErrorCode::NO_ERROR; + } + memoryState_ = memoryState; + IMSA_HILOGI("big memory state: %{public}d", memoryState); + if (memoryState_ == BigMemoryState::BIG_MEMORY_END) { + StartImeIfInstalled(); + } + return ErrorCode::NO_ERROR; +} + int32_t PerUserSession::OnUnRegisteredProxyIme(UnRegisteredType type, const sptr &core) { IMSA_HILOGD("proxy unregister type: %{public}d.", type); @@ -823,6 +837,10 @@ void PerUserSession::StartImeInImeDied() IMSA_HILOGW("not ready to start ime."); return; } + if (memoryState_ == BigMemoryState::BIG_MEMORY_START) { + IMSA_HILOGI("big memory start, do not restart."); + return; + } StartImeIfInstalled(); }