1 /*
2  * Copyright (c) 2020 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 "broadcast_service.h"
17 #include "ohos_init.h"
18 #include "common.h"
19 #include "samgr_lite.h"
20 #include "thread_adapter.h"
21 #include "pub_sub_feature.h"
22 static const char *GetName(Service *service);
23 static BOOL Initialize(Service *service, Identity identity);
24 static TaskConfig GetTaskConfig(Service *service);
25 static BOOL MessageHandle(Service *service, Request *request);
26 static BroadcastService g_broadcastService = {
27     GetName,
28     Initialize,
29     MessageHandle,
30     GetTaskConfig,
31 };
32 
Init(void)33 static void Init(void)
34 {
35     SAMGR_GetInstance()->RegisterService((Service *)&g_broadcastService);
36 }
37 SYS_SERVICE_INIT(Init);
38 
GetName(Service * service)39 static const char *GetName(Service *service)
40 {
41     (void)service;
42     return BROADCAST_SERVICE;
43 }
44 
Initialize(Service * service,Identity identity)45 static BOOL Initialize(Service *service, Identity identity)
46 {
47     (void)identity;
48     if (service == NULL) {
49         return FALSE;
50     }
51     return TRUE;
52 }
53 
MessageHandle(Service * service,Request * request)54 static BOOL MessageHandle(Service *service, Request *request)
55 {
56     (void)service;
57     switch (request->msgId) {
58         case BROADCAST_MSG:
59             break;
60         default:
61             break;
62     }
63     return TRUE;
64 }
65 
GetTaskConfig(Service * service)66 static TaskConfig GetTaskConfig(Service *service)
67 {
68     (void)service;
69     TaskConfig config = {LEVEL_HIGH, PRI_ABOVE_NORMAL, 0x800, 40, SPECIFIED_TASK};
70     return config;
71 }
72