• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-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 "pms_inner.h"
17 
18 #include <ohos_init.h>
19 
20 #include "feature.h"
21 #include "log.h"
22 #include "samgr_lite.h"
23 
24 #include "pms.h"
25 #include "pms_common.h"
26 
27 static void Init(void);
28 static const char *GetName(Feature *feature);
29 static void OnInitialize(Feature *feature, Service *parent, Identity identity);
30 static void OnStop(Feature *feature, Identity identity);
31 static BOOL OnMessage(const Feature *feature, const Request *request);
32 
33 static PmsInner g_permlite = {
34     .GetName = GetName,
35     .OnInitialize = OnInitialize,
36     .OnStop = OnStop,
37     .OnMessage = OnMessage,
38     DEFAULT_IUNKNOWN_ENTRY_BEGIN,
39     .CheckPermission = CheckPermissionStat,
40     .QueryPermission = QueryPermission,
41     .GrantPermission = GrantPermission,
42     .RevokePermission = RevokePermission,
43     .GrantRuntimePermission = GrantRuntimePermission,
44     .RevokeRuntimePermission = RevokeRuntimePermission,
45     .UpdatePermissionFlags = UpdatePermissionFlags,
46     DEFAULT_IUNKNOWN_ENTRY_END,
47     .identity = {-1, -1, NULL},
48 };
49 
Init(void)50 static void Init(void)
51 {
52     SAMGR_GetInstance()->RegisterFeature(PERMISSION_SERVICE, (Feature *)&g_permlite);
53     SAMGR_GetInstance()->RegisterFeatureApi(PERMISSION_SERVICE, PERM_INNER, GET_IUNKNOWN(g_permlite));
54     HILOG_INFO(HILOG_MODULE_APP, "Init pms inner feature success");
55 }
56 APP_FEATURE_INIT(Init);
57 
GetName(Feature * feature)58 static const char *GetName(Feature *feature)
59 {
60     (void)feature;
61     return PERM_INNER;
62 }
63 
OnInitialize(Feature * feature,Service * parent,Identity identity)64 static void OnInitialize(Feature *feature, Service *parent, Identity identity)
65 {
66     (void)parent;
67     if (feature == NULL) {
68         return;
69     }
70     PmsInner *permlite = (PmsInner *)feature;
71     permlite->identity = identity;
72 }
73 
OnStop(Feature * feature,Identity identity)74 static void OnStop(Feature *feature, Identity identity)
75 {
76     (void)feature;
77     (void)identity;
78 }
79 
OnMessage(const Feature * feature,const Request * request)80 static BOOL OnMessage(const Feature *feature, const Request *request)
81 {
82     if (feature == NULL || request == NULL) {
83         return FALSE;
84     }
85     // call func
86     return TRUE;
87 }
88