mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 17:01:21 +00:00
!1149 修改requestShowinput打开requestHideInput IPC通信
Merge pull request !1149 from mashaoyin/master
This commit is contained in:
commit
79e4436dca
@ -20,7 +20,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace MiscServices {
|
||||
enum class RequestType : int32_t { NORMAL = 0, START_INPUT, STOP_INPUT, REQUEST_HIDE };
|
||||
enum class RequestType : int32_t { NORMAL = 0, START_INPUT, STOP_INPUT, REQUEST_SHOW, REQUEST_HIDE };
|
||||
class FreezeManager {
|
||||
public:
|
||||
explicit FreezeManager(pid_t pid) : pid_(pid)
|
||||
|
@ -34,7 +34,7 @@ void FreezeManager::BeforeIpc(RequestType type)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (type == RequestType::START_INPUT) {
|
||||
if (type == RequestType::START_INPUT || type == RequestType::REQUEST_SHOW) {
|
||||
isImeInUse_ = true;
|
||||
}
|
||||
if (!isFrozen_) {
|
||||
@ -51,7 +51,7 @@ void FreezeManager::AfterIpc(RequestType type, bool isSuccess)
|
||||
bool shouldFreeze = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (type == RequestType::START_INPUT) {
|
||||
if (type == RequestType::START_INPUT || type == RequestType::REQUEST_SHOW) {
|
||||
isImeInUse_ = isSuccess;
|
||||
}
|
||||
if (type == RequestType::REQUEST_HIDE && isImeInUse_) {
|
||||
|
@ -76,6 +76,27 @@ public:
|
||||
CheckAllState(false, true);
|
||||
}
|
||||
}
|
||||
static void TestRequestShowInput(bool isSuccess)
|
||||
{
|
||||
IMSA_HILOGI("run in, isSuccess: %{public}d", isSuccess);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
bool ret = freezeManager_->IsIpcNeeded(RequestType::REQUEST_SHOW);
|
||||
if (!ret) {
|
||||
return;
|
||||
}
|
||||
freezeManager_->BeforeIpc(RequestType::REQUEST_SHOW);
|
||||
CheckFreezable(false);
|
||||
}
|
||||
usleep(IPC_COST_TIME);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mtx_);
|
||||
freezeManager_->AfterIpc(RequestType::REQUEST_SHOW, isSuccess);
|
||||
if (isSuccess) {
|
||||
CheckAllState(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void TestRequestHideInput(bool isSuccess)
|
||||
{
|
||||
IMSA_HILOGI("run in, isSuccess: %{public}d", isSuccess);
|
||||
@ -249,5 +270,18 @@ HWTEST_F(ImeFreezeManagerTest, MultiThread_FullTest_001, TestSize.Level0)
|
||||
SET_THREAD_NUM(5);
|
||||
GTEST_RUN_TASK(FullTestTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SingleThread_RequestShow_001
|
||||
* @tc.desc: test freeze manager
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(ImeFreezeManagerTest, SingleThread_RequestShow_001, TestSize.Level0)
|
||||
{
|
||||
IMSA_HILOGI("ImeFreezeManagerTest::SingleThread_RequestShow_001");
|
||||
EXPECT_NE(ImeFreezeManagerTest::freezeManager_, nullptr);
|
||||
ClearState();
|
||||
TestRequestShowInput(true);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user