1 /* 2 * Copyright (C) 2021 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 FM_IMMS_PROJECT_PLATFORMAPI_H 17 #define FM_IMMS_PROJECT_PLATFORMAPI_H 18 19 #include <vector> 20 #include <string> 21 #include <memory> 22 #include "iremote_broker.h" 23 #include "iremote_object.h" 24 #include "i_platform_api.h" 25 #include "i_input_method_core.h" 26 #include "input_method_property.h" 27 #include "input_method_setting.h" 28 29 namespace OHOS { 30 namespace MiscServices { 31 class Platform { 32 public: 33 static Platform *Instance(); 34 void SetPlatform(const sptr<IPlatformApi>& platformApi); 35 sptr<IInputMethodCore> BindInputMethodService(int userId, const std::u16string& packageName, 36 const std::u16string& intention); 37 int UnbindInputMethodService(int userId, const std::u16string& packageName); 38 sptr<IRemoteObject> CreateWindowToken(int userId, int displayId, const std::u16string& packageName); 39 int DestroyWindowToken(int userId, const std::u16string& packageName); 40 int ListInputMethod(int userId, std::vector<InputMethodProperty*> *properties); 41 int GetInputMethodProperty(int userId, const std::u16string& packageName, 42 InputMethodProperty *inputMethodProperty); 43 int GetInputMethodSetting(int userId, InputMethodSetting *inputMethodSetting); 44 int SetInputMethodSetting(int userId, const InputMethodSetting& inputMethodSetting); 45 bool CheckPhysicalKeyboard(); 46 bool IsValidWindow(int uid, int pid, int displayId); 47 bool IsWindowFocused(int uid, int pid, int displayId); 48 RemoteBrokerToObject(const sptr<IRemoteBroker> & broker)49 static inline sptr<IRemoteObject> RemoteBrokerToObject(const sptr<IRemoteBroker>& broker) 50 { 51 return broker->AsObject(); 52 } 53 54 private: 55 sptr<IPlatformApi> platformApi; 56 Platform(); 57 ~Platform(); 58 Platform(const Platform&); 59 Platform& operator =(const Platform&); 60 Platform(const Platform&&); 61 Platform& operator =(const Platform&&); 62 }; 63 } 64 } 65 #endif // FM_IMMS_PROJECT_PLATFORMAPI_H 66