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 "iproxy_client.h"
2262b8cbc9Sopenharmony_ci#include "iproxy_server.h"
2362b8cbc9Sopenharmony_ci#include "iunknown.h"
2462b8cbc9Sopenharmony_ci#include "samgr_lite.h"
2562b8cbc9Sopenharmony_ci#include "service.h"
2662b8cbc9Sopenharmony_ci
2762b8cbc9Sopenharmony_ci#include "lite_wms.h"
2862b8cbc9Sopenharmony_ci
2962b8cbc9Sopenharmony_cinamespace OHOS {
3062b8cbc9Sopenharmony_cistruct DefaultFeatureApi {
3162b8cbc9Sopenharmony_ci    INHERIT_SERVER_IPROXY;
3262b8cbc9Sopenharmony_ci};
3362b8cbc9Sopenharmony_ci
3462b8cbc9Sopenharmony_cistruct WMSService {
3562b8cbc9Sopenharmony_ci    INHERIT_SERVICE;
3662b8cbc9Sopenharmony_ci    INHERIT_IUNKNOWNENTRY(DefaultFeatureApi);
3762b8cbc9Sopenharmony_ci    Identity identity;
3862b8cbc9Sopenharmony_ci};
3962b8cbc9Sopenharmony_ci
4062b8cbc9Sopenharmony_cistatic const char* GetName(Service* service)
4162b8cbc9Sopenharmony_ci{
4262b8cbc9Sopenharmony_ci    (void)service;
4362b8cbc9Sopenharmony_ci    return SERVICE_NAME;
4462b8cbc9Sopenharmony_ci}
4562b8cbc9Sopenharmony_ci
4662b8cbc9Sopenharmony_cistatic BOOL Initialize(Service* service, Identity identity)
4762b8cbc9Sopenharmony_ci{
4862b8cbc9Sopenharmony_ci    WMSService* example = reinterpret_cast<WMSService*>(service);
4962b8cbc9Sopenharmony_ci    example->identity = identity;
5062b8cbc9Sopenharmony_ci    GRAPHIC_LOGI("Initialize(%s)! Identity<%d, %d, %p>", SERVICE_NAME,
5162b8cbc9Sopenharmony_ci        identity.serviceId, identity.featureId, identity.queueId);
5262b8cbc9Sopenharmony_ci    return TRUE;
5362b8cbc9Sopenharmony_ci}
5462b8cbc9Sopenharmony_ci
5562b8cbc9Sopenharmony_cistatic BOOL MessageHandle(Service* service, Request* msg)
5662b8cbc9Sopenharmony_ci{
5762b8cbc9Sopenharmony_ci    GRAPHIC_LOGI("MessageHandle(%s)! Request<%d, %d, %p>",
5862b8cbc9Sopenharmony_ci        service->GetName(service), msg->msgId, msg->msgValue, msg->data);
5962b8cbc9Sopenharmony_ci    return FALSE;
6062b8cbc9Sopenharmony_ci}
6162b8cbc9Sopenharmony_ci
6262b8cbc9Sopenharmony_cistatic TaskConfig GetTaskConfig(Service* service)
6362b8cbc9Sopenharmony_ci{
6462b8cbc9Sopenharmony_ci    (void)service;
6562b8cbc9Sopenharmony_ci    TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0x800, 20, SHARED_TASK};
6662b8cbc9Sopenharmony_ci    return config;
6762b8cbc9Sopenharmony_ci}
6862b8cbc9Sopenharmony_ci
6962b8cbc9Sopenharmony_cistatic int32 Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, IpcIo* reply)
7062b8cbc9Sopenharmony_ci{
7162b8cbc9Sopenharmony_ci    LiteWMS::WMSRequestHandle(funcId, origin, req, reply);
7262b8cbc9Sopenharmony_ci    return EC_SUCCESS;
7362b8cbc9Sopenharmony_ci}
7462b8cbc9Sopenharmony_ci
7562b8cbc9Sopenharmony_cistatic WMSService g_example = {
7662b8cbc9Sopenharmony_ci    .GetName = GetName,
7762b8cbc9Sopenharmony_ci    .Initialize = Initialize,
7862b8cbc9Sopenharmony_ci    .MessageHandle = MessageHandle,
7962b8cbc9Sopenharmony_ci    .GetTaskConfig = GetTaskConfig,
8062b8cbc9Sopenharmony_ci    SERVER_IPROXY_IMPL_BEGIN,
8162b8cbc9Sopenharmony_ci    .Invoke = Invoke,
8262b8cbc9Sopenharmony_ci    IPROXY_END,
8362b8cbc9Sopenharmony_ci};
8462b8cbc9Sopenharmony_ci
8562b8cbc9Sopenharmony_cistatic void Init(void)
8662b8cbc9Sopenharmony_ci{
8762b8cbc9Sopenharmony_ci    SAMGR_GetInstance()->RegisterService((Service*)&g_example);
8862b8cbc9Sopenharmony_ci    SAMGR_GetInstance()->RegisterDefaultFeatureApi(SERVICE_NAME, GET_IUNKNOWN(g_example));
8962b8cbc9Sopenharmony_ci}
9062b8cbc9Sopenharmony_ci
9162b8cbc9Sopenharmony_ciSYSEX_SERVICE_INIT(Init);
9262b8cbc9Sopenharmony_ci} // namespace OHOS
93