• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "permission_service.h"
17 
18 #include <ohos_init.h>
19 
20 #include "log.h"
21 
22 #include "samgr_lite.h"
23 
24 #define STACK_SIZE 0x800
25 #define QUEUE_SIZE 20
26 
27 static void Init();
28 static const char *GetName(Service *service);
29 static BOOL Initialize(Service *service, Identity identity);
30 static TaskConfig GetTaskConfig(Service *service);
31 static BOOL MessageHandle(const Service *service, const Request *request);
32 
33 static PermissionService g_permissionService = {
34     .GetName = GetName,
35     .Initialize = Initialize,
36     .MessageHandle = MessageHandle,
37     .GetTaskConfig = GetTaskConfig,
38     .identity = {-1, -1, NULL}
39 };
40 
Init()41 static void Init()
42 {
43     SAMGR_GetInstance()->RegisterService((Service *)&g_permissionService);
44     HILOG_INFO(HILOG_MODULE_APP, "Init pms service success");
45 }
46 APP_SERVICE_INIT(Init);
47 
GetName(Service * service)48 static const char *GetName(Service *service)
49 {
50     (void)service;
51     return PERMISSION_SERVICE;
52 }
53 
Initialize(Service * service,Identity identity)54 static BOOL Initialize(Service *service, Identity identity)
55 {
56     if (service == NULL) {
57         return FALSE;
58     }
59     PermissionService *pms = (PermissionService *)service;
60     pms->identity = identity;
61     return TRUE;
62 }
63 
MessageHandle(const Service * service,const Request * request)64 static BOOL MessageHandle(const Service *service, const Request *request)
65 {
66     (void)service;
67     if (request == NULL) {
68         return FALSE;
69     }
70     return FALSE;
71 }
72 
GetTaskConfig(Service * service)73 static TaskConfig GetTaskConfig(Service *service)
74 {
75     (void)service;
76     TaskConfig config = {LEVEL_HIGH, PRI_NORMAL, STACK_SIZE, QUEUE_SIZE, SINGLE_TASK};
77     return config;
78 }
79