1f5921b11Sopenharmony_ci/* 2f5921b11Sopenharmony_ci * Copyright (c) 2020-2022 Huawei Device Co., Ltd. 3f5921b11Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4f5921b11Sopenharmony_ci * you may not use this file except in compliance with the License. 5f5921b11Sopenharmony_ci * You may obtain a copy of the License at 6f5921b11Sopenharmony_ci * 7f5921b11Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8f5921b11Sopenharmony_ci * 9f5921b11Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10f5921b11Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11f5921b11Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12f5921b11Sopenharmony_ci * See the License for the specific language governing permissions and 13f5921b11Sopenharmony_ci * limitations under the License. 14f5921b11Sopenharmony_ci */ 15f5921b11Sopenharmony_ci 16f5921b11Sopenharmony_ci#include "pms_inner.h" 17f5921b11Sopenharmony_ci 18f5921b11Sopenharmony_ci#include <ohos_init.h> 19f5921b11Sopenharmony_ci 20f5921b11Sopenharmony_ci#include "feature.h" 21f5921b11Sopenharmony_ci#include "log.h" 22f5921b11Sopenharmony_ci#include "samgr_lite.h" 23f5921b11Sopenharmony_ci 24f5921b11Sopenharmony_ci#include "pms.h" 25f5921b11Sopenharmony_ci#include "pms_common.h" 26f5921b11Sopenharmony_ci 27f5921b11Sopenharmony_cistatic void Init(void); 28f5921b11Sopenharmony_cistatic const char *GetName(Feature *feature); 29f5921b11Sopenharmony_cistatic void OnInitialize(Feature *feature, Service *parent, Identity identity); 30f5921b11Sopenharmony_cistatic void OnStop(Feature *feature, Identity identity); 31f5921b11Sopenharmony_cistatic BOOL OnMessage(const Feature *feature, const Request *request); 32f5921b11Sopenharmony_ci 33f5921b11Sopenharmony_cistatic PmsInner g_permlite = { 34f5921b11Sopenharmony_ci .GetName = GetName, 35f5921b11Sopenharmony_ci .OnInitialize = OnInitialize, 36f5921b11Sopenharmony_ci .OnStop = OnStop, 37f5921b11Sopenharmony_ci .OnMessage = OnMessage, 38f5921b11Sopenharmony_ci DEFAULT_IUNKNOWN_ENTRY_BEGIN, 39f5921b11Sopenharmony_ci .CheckPermission = CheckPermissionStat, 40f5921b11Sopenharmony_ci .QueryPermission = QueryPermission, 41f5921b11Sopenharmony_ci .GrantPermission = GrantPermission, 42f5921b11Sopenharmony_ci .RevokePermission = RevokePermission, 43f5921b11Sopenharmony_ci .GrantRuntimePermission = GrantRuntimePermission, 44f5921b11Sopenharmony_ci .RevokeRuntimePermission = RevokeRuntimePermission, 45f5921b11Sopenharmony_ci .UpdatePermissionFlags = UpdatePermissionFlags, 46f5921b11Sopenharmony_ci DEFAULT_IUNKNOWN_ENTRY_END, 47f5921b11Sopenharmony_ci .identity = {-1, -1, NULL}, 48f5921b11Sopenharmony_ci}; 49f5921b11Sopenharmony_ci 50f5921b11Sopenharmony_cistatic void Init(void) 51f5921b11Sopenharmony_ci{ 52f5921b11Sopenharmony_ci SAMGR_GetInstance()->RegisterFeature(PERMISSION_SERVICE, (Feature *)&g_permlite); 53f5921b11Sopenharmony_ci SAMGR_GetInstance()->RegisterFeatureApi(PERMISSION_SERVICE, PERM_INNER, GET_IUNKNOWN(g_permlite)); 54f5921b11Sopenharmony_ci HILOG_INFO(HILOG_MODULE_APP, "Init pms inner feature success"); 55f5921b11Sopenharmony_ci} 56f5921b11Sopenharmony_ciAPP_FEATURE_INIT(Init); 57f5921b11Sopenharmony_ci 58f5921b11Sopenharmony_cistatic const char *GetName(Feature *feature) 59f5921b11Sopenharmony_ci{ 60f5921b11Sopenharmony_ci (void)feature; 61f5921b11Sopenharmony_ci return PERM_INNER; 62f5921b11Sopenharmony_ci} 63f5921b11Sopenharmony_ci 64f5921b11Sopenharmony_cistatic void OnInitialize(Feature *feature, Service *parent, Identity identity) 65f5921b11Sopenharmony_ci{ 66f5921b11Sopenharmony_ci (void)parent; 67f5921b11Sopenharmony_ci if (feature == NULL) { 68f5921b11Sopenharmony_ci return; 69f5921b11Sopenharmony_ci } 70f5921b11Sopenharmony_ci PmsInner *permlite = (PmsInner *)feature; 71f5921b11Sopenharmony_ci permlite->identity = identity; 72f5921b11Sopenharmony_ci} 73f5921b11Sopenharmony_ci 74f5921b11Sopenharmony_cistatic void OnStop(Feature *feature, Identity identity) 75f5921b11Sopenharmony_ci{ 76f5921b11Sopenharmony_ci (void)feature; 77f5921b11Sopenharmony_ci (void)identity; 78f5921b11Sopenharmony_ci} 79f5921b11Sopenharmony_ci 80f5921b11Sopenharmony_cistatic BOOL OnMessage(const Feature *feature, const Request *request) 81f5921b11Sopenharmony_ci{ 82f5921b11Sopenharmony_ci if (feature == NULL || request == NULL) { 83f5921b11Sopenharmony_ci return FALSE; 84f5921b11Sopenharmony_ci } 85f5921b11Sopenharmony_ci // call func 86f5921b11Sopenharmony_ci return TRUE; 87f5921b11Sopenharmony_ci} 88