1 /*
2 * Copyright (c) 2020-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 #include <ohos_errno.h>
17 #include <ohos_init.h>
18
19 #include "feature.h"
20 #include "gfx_utils/graphic_log.h"
21 #include "iproxy_client.h"
22 #include "iproxy_server.h"
23 #include "iunknown.h"
24 #include "samgr_lite.h"
25 #include "service.h"
26
27 #include "lite_wms.h"
28
29 namespace OHOS {
30 struct DefaultFeatureApi {
31 INHERIT_SERVER_IPROXY;
32 };
33
34 struct WMSService {
35 INHERIT_SERVICE;
36 INHERIT_IUNKNOWNENTRY(DefaultFeatureApi);
37 Identity identity;
38 };
39
GetName(Service * service)40 static const char* GetName(Service* service)
41 {
42 (void)service;
43 return SERVICE_NAME;
44 }
45
Initialize(Service * service,Identity identity)46 static BOOL Initialize(Service* service, Identity identity)
47 {
48 WMSService* example = reinterpret_cast<WMSService*>(service);
49 example->identity = identity;
50 GRAPHIC_LOGI("Initialize(%s)! Identity<%d, %d, %p>", SERVICE_NAME,
51 identity.serviceId, identity.featureId, identity.queueId);
52 return TRUE;
53 }
54
MessageHandle(Service * service,Request * msg)55 static BOOL MessageHandle(Service* service, Request* msg)
56 {
57 GRAPHIC_LOGI("MessageHandle(%s)! Request<%d, %d, %p>",
58 service->GetName(service), msg->msgId, msg->msgValue, msg->data);
59 return FALSE;
60 }
61
GetTaskConfig(Service * service)62 static TaskConfig GetTaskConfig(Service* service)
63 {
64 (void)service;
65 TaskConfig config = {LEVEL_HIGH, PRI_BELOW_NORMAL, 0x800, 20, SHARED_TASK};
66 return config;
67 }
68
Invoke(IServerProxy * iProxy,int funcId,void * origin,IpcIo * req,IpcIo * reply)69 static int32 Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, IpcIo* reply)
70 {
71 LiteWMS::WMSRequestHandle(funcId, origin, req, reply);
72 return EC_SUCCESS;
73 }
74
75 static WMSService g_example = {
76 .GetName = GetName,
77 .Initialize = Initialize,
78 .MessageHandle = MessageHandle,
79 .GetTaskConfig = GetTaskConfig,
80 SERVER_IPROXY_IMPL_BEGIN,
81 .Invoke = Invoke,
82 IPROXY_END,
83 };
84
Init(void)85 static void Init(void)
86 {
87 SAMGR_GetInstance()->RegisterService((Service*)&g_example);
88 SAMGR_GetInstance()->RegisterDefaultFeatureApi(SERVICE_NAME, GET_IUNKNOWN(g_example));
89 }
90
91 SYSEX_SERVICE_INIT(Init);
92 } // namespace OHOS
93