162b8cbc9Sopenharmony_ci/* 262b8cbc9Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 362b8cbc9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 462b8cbc9Sopenharmony_ci * you may not use this file except in compliance with the License. 562b8cbc9Sopenharmony_ci * You may obtain a copy of the License at 662b8cbc9Sopenharmony_ci * 762b8cbc9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 862b8cbc9Sopenharmony_ci * 962b8cbc9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1062b8cbc9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1162b8cbc9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1262b8cbc9Sopenharmony_ci * See the License for the specific language governing permissions and 1362b8cbc9Sopenharmony_ci * limitations under the License. 1462b8cbc9Sopenharmony_ci */ 1562b8cbc9Sopenharmony_ci 1662b8cbc9Sopenharmony_ci#include <ohos_errno.h> 1762b8cbc9Sopenharmony_ci#include <ohos_init.h> 1862b8cbc9Sopenharmony_ci 1962b8cbc9Sopenharmony_ci#include "feature.h" 2062b8cbc9Sopenharmony_ci#include "gfx_utils/graphic_log.h" 2162b8cbc9Sopenharmony_ci#include "input_event_client_proxy.h" 2262b8cbc9Sopenharmony_ci#include "iproxy_client.h" 2362b8cbc9Sopenharmony_ci#include "iproxy_server.h" 2462b8cbc9Sopenharmony_ci#include "iunknown.h" 2562b8cbc9Sopenharmony_ci#include "samgr_lite.h" 2662b8cbc9Sopenharmony_ci#include "service.h" 2762b8cbc9Sopenharmony_ci 2862b8cbc9Sopenharmony_cinamespace OHOS { 2962b8cbc9Sopenharmony_cistruct DefaultFeatureApi { 3062b8cbc9Sopenharmony_ci INHERIT_SERVER_IPROXY; 3162b8cbc9Sopenharmony_ci}; 3262b8cbc9Sopenharmony_ci 3362b8cbc9Sopenharmony_cistruct IMSService { 3462b8cbc9Sopenharmony_ci INHERIT_SERVICE; 3562b8cbc9Sopenharmony_ci INHERIT_IUNKNOWNENTRY(DefaultFeatureApi); 3662b8cbc9Sopenharmony_ci Identity identity; 3762b8cbc9Sopenharmony_ci}; 3862b8cbc9Sopenharmony_ci 3962b8cbc9Sopenharmony_cistatic const char* GetName(Service* service) 4062b8cbc9Sopenharmony_ci{ 4162b8cbc9Sopenharmony_ci (void)service; 4262b8cbc9Sopenharmony_ci return IMS_SERVICE_NAME; 4362b8cbc9Sopenharmony_ci} 4462b8cbc9Sopenharmony_ci 4562b8cbc9Sopenharmony_cistatic BOOL Initialize(Service* service, Identity identity) 4662b8cbc9Sopenharmony_ci{ 4762b8cbc9Sopenharmony_ci IMSService* example = reinterpret_cast<IMSService*>(service); 4862b8cbc9Sopenharmony_ci example->identity = identity; 4962b8cbc9Sopenharmony_ci GRAPHIC_LOGI("Initialize(%s)! Identity<%d, %d, %p>", IMS_SERVICE_NAME, 5062b8cbc9Sopenharmony_ci identity.serviceId, identity.featureId, identity.queueId); 5162b8cbc9Sopenharmony_ci return TRUE; 5262b8cbc9Sopenharmony_ci} 5362b8cbc9Sopenharmony_ci 5462b8cbc9Sopenharmony_cistatic BOOL MessageHandle(Service* service, Request* msg) 5562b8cbc9Sopenharmony_ci{ 5662b8cbc9Sopenharmony_ci GRAPHIC_LOGI("MessageHandle(%s)! Request<%d, %d, %p>", 5762b8cbc9Sopenharmony_ci service->GetName(service), msg->msgId, msg->msgValue, msg->data); 5862b8cbc9Sopenharmony_ci return FALSE; 5962b8cbc9Sopenharmony_ci} 6062b8cbc9Sopenharmony_ci 6162b8cbc9Sopenharmony_cistatic TaskConfig GetTaskConfig(Service* service) 6262b8cbc9Sopenharmony_ci{ 6362b8cbc9Sopenharmony_ci (void)service; 6462b8cbc9Sopenharmony_ci TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0x800, 20, SHARED_TASK}; 6562b8cbc9Sopenharmony_ci return config; 6662b8cbc9Sopenharmony_ci} 6762b8cbc9Sopenharmony_ci 6862b8cbc9Sopenharmony_cistatic int32 Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, IpcIo* reply) 6962b8cbc9Sopenharmony_ci{ 7062b8cbc9Sopenharmony_ci InputEventClientProxy::GetInstance()->ClientRequestHandle(funcId, origin, req, reply); 7162b8cbc9Sopenharmony_ci return EC_SUCCESS; 7262b8cbc9Sopenharmony_ci} 7362b8cbc9Sopenharmony_ci 7462b8cbc9Sopenharmony_cistatic IMSService g_example = { 7562b8cbc9Sopenharmony_ci .GetName = GetName, 7662b8cbc9Sopenharmony_ci .Initialize = Initialize, 7762b8cbc9Sopenharmony_ci .MessageHandle = MessageHandle, 7862b8cbc9Sopenharmony_ci .GetTaskConfig = GetTaskConfig, 7962b8cbc9Sopenharmony_ci SERVER_IPROXY_IMPL_BEGIN, 8062b8cbc9Sopenharmony_ci .Invoke = Invoke, 8162b8cbc9Sopenharmony_ci IPROXY_END, 8262b8cbc9Sopenharmony_ci}; 8362b8cbc9Sopenharmony_ci 8462b8cbc9Sopenharmony_cistatic void Init(void) 8562b8cbc9Sopenharmony_ci{ 8662b8cbc9Sopenharmony_ci BOOL ret = SAMGR_GetInstance()->RegisterService(reinterpret_cast<Service*>(&g_example)); 8762b8cbc9Sopenharmony_ci if (ret != TRUE) { 8862b8cbc9Sopenharmony_ci GRAPHIC_LOGE("regist service failed."); 8962b8cbc9Sopenharmony_ci return; 9062b8cbc9Sopenharmony_ci } 9162b8cbc9Sopenharmony_ci ret = SAMGR_GetInstance()->RegisterDefaultFeatureApi(IMS_SERVICE_NAME, GET_IUNKNOWN(g_example)); 9262b8cbc9Sopenharmony_ci if (ret != TRUE) { 9362b8cbc9Sopenharmony_ci GRAPHIC_LOGE("regist feature failed."); 9462b8cbc9Sopenharmony_ci return; 9562b8cbc9Sopenharmony_ci } 9662b8cbc9Sopenharmony_ci} 9762b8cbc9Sopenharmony_ci 9862b8cbc9Sopenharmony_ciSYSEX_SERVICE_INIT(Init); 9962b8cbc9Sopenharmony_ci} // namespace OHOS