1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef INPUTMETHOD_IMF_INPUT__CLIENT_INFO_H 17 #define INPUTMETHOD_IMF_INPUT__CLIENT_INFO_H 18 19 #include "iinput_client.h" 20 #include "iinput_data_channel.h" 21 #include "input_attribute.h" 22 #include "input_death_recipient.h" 23 24 namespace OHOS { 25 namespace MiscServices { 26 enum class UpdateFlag : uint32_t { 27 EVENTFLAG = 0, 28 ISSHOWKEYBOARD, 29 BINDIMETYPE, 30 STATE, 31 TEXT_CONFIG, 32 UIEXTENSION_TOKENID, 33 CLIENT_TYPE, 34 BIND_IME_PID, 35 }; 36 enum class ImeType : int32_t { 37 IME = 0, 38 PROXY_IME, 39 PROXY_AGENT_IME, 40 IME_MIRROR, 41 NONE 42 }; 43 enum class ClientState : uint32_t { 44 INACTIVE = 0, 45 ACTIVE 46 }; 47 48 enum ClientType : uint32_t { 49 CAPI, 50 JS, 51 CJ, 52 INNER_KIT, 53 CLIENT_TYPE_END, 54 }; 55 56 constexpr uint32_t NO_EVENT_ON = 0; 57 constexpr uint32_t IMF_INVALID_TOKENID = 0; 58 constexpr uint64_t DEFAULT_DISPLAY_ID = 0; 59 constexpr int64_t INVALID_PID = -1; 60 struct InputClientInfo { 61 pid_t pid { -1 }; // process id 62 pid_t uid { -1 }; // uid 63 int32_t userID { 0 }; // user id of input client 64 uint64_t displayId { DEFAULT_DISPLAY_ID }; 65 bool isShowKeyboard { false }; // soft keyboard status 66 ImeType bindImeType { ImeType::NONE }; // type of the ime client bind 67 TextTotalConfig config = {}; // text config 68 uint32_t eventFlag { NO_EVENT_ON }; // the flag of the all listen event 69 InputAttribute attribute; // the input client attribute 70 sptr<IInputClient> client { nullptr }; // the remote object handler for service to callback input client 71 sptr<IRemoteObject> channel { nullptr }; // the remote object handler for ime to callback input client 72 sptr<InputDeathRecipient> deathRecipient { nullptr }; // death recipient of client 73 ClientState state { ClientState::INACTIVE }; // the state of input client 74 bool isNotifyInputStart { true }; 75 bool needHide { false }; // panel needs to be hidden first, when input pattern is switched between pwd and normal 76 uint32_t uiExtensionTokenId { IMF_INVALID_TOKENID }; // the value is valid only in curClient and only UIExtension 77 RequestKeyboardReason requestKeyboardReason { RequestKeyboardReason::NONE }; // show keyboard reason 78 ClientType type{ INNER_KIT }; // for hiSysEvent 79 std::string name; // for hiSysEvent, client name:SA/processName app/bundleName 80 pid_t bindImePid { -1 }; 81 }; 82 83 struct InputClientInfoInner : public Parcelable { 84 pid_t pid { -1 }; // process id 85 pid_t uid { -1 }; // uid 86 int32_t userID { 0 }; // user id of input client 87 uint64_t displayId { DEFAULT_DISPLAY_ID }; 88 bool isShowKeyboard { false }; // soft keyboard status 89 ImeType bindImeType { ImeType::NONE }; // type of the ime client bind 90 TextTotalConfigInner config = {}; // text config 91 uint32_t eventFlag { NO_EVENT_ON }; // the flag of the all listen event 92 InputAttributeInner attribute; // the input client attribute 93 sptr<IInputClient> client { nullptr }; // the remote object handler for service to callback input client 94 sptr<IRemoteObject> channel { nullptr }; // the remote object handler for ime to callback input client 95 sptr<InputDeathRecipient> deathRecipient { nullptr }; // death recipient of client 96 ClientState state { ClientState::INACTIVE }; // the state of input client 97 bool isNotifyInputStart { true }; 98 bool needHide { false }; // panel needs to be hidden first, when input pattern is switched between pwd and normal 99 uint32_t uiExtensionTokenId { IMF_INVALID_TOKENID }; // the value is valid only in curClient and only UIExtension 100 RequestKeyboardReason requestKeyboardReason { RequestKeyboardReason::NONE }; // show keyboard reason 101 ClientType type{ INNER_KIT }; // for hiSysEvent 102 std::string name; // for hiSysEvent, client name:SA/processName app/bundleName 103 104 bool ReadFromParcel(Parcel &in); 105 bool Marshalling(Parcel &out) const; 106 bool MarshallingOne(Parcel &in) const; 107 bool MarshallingTwo(Parcel &in) const; 108 static InputClientInfoInner *Unmarshalling(Parcel &in); 109 }; 110 111 struct HiSysEventClientInfo { 112 int64_t pid{ -1 }; 113 ClientType type{ INNER_KIT }; 114 std::string name; 115 }; 116 } // namespace MiscServices 117 } // namespace OHOS 118 119 #endif // INPUTMETHOD_IMF_INPUT_CLIENT_INFO_H 120