* Copyright (c) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef APPSPAWN_SPM_H
#define APPSPAWN_SPM_H
#include <stdint.h>
#include <sys/types.h>
#include "appspawn_manager.h"
#include "appspawn_mount_permission.h"
#define MAX_KERNEL_PERMISSIONS 256
#define MAX_EXT_PERMISSIONS 64
#define MAX_GRANTED_PERMISSIONS 256
#define MAX_PERM_SIZE 8192
#define MAX_EXTEND_PERM_SIZE 2048
#define MAX_BUNDLE_NAME_LEN 256
#define SPM_REF_NONE 0x00
#define SPM_REF_TOKENID 0x01
#define SPM_REF_UID 0x02
typedef enum {
SPM_SUCCESS = 0,
SPM_ERROR_INVALID_PARAM = -1,
SPM_ERROR_NO_MEMORY = -2,
SPM_ERROR_TOKENID_ATTR_MISMATCH = -3,
SPM_ERROR_INVALID_DATA = -4,
SPM_ERROR_REF_COUNT_LIMIT = -5,
SPM_ERROR_REF_COUNT_INC_FAILED = -6,
SPM_ERROR_GET_SPM_FAILED = -7,
SPM_ERROR_TLV_BUILD_FAILED = -8,
SPM_ERROR_MSG_REBUILD_FAILED = -9,
SPM_ERROR_UID_MISMATCH = -10,
SPM_ERROR_MISSING_MSG_DATA = -11,
SPM_ERROR_SPM_NOSUPP = -12,
} SpmErrorCode;
#ifdef __cplusplus
extern "C" {
#endif
* @brief APL (Ability Privilege Level) enumeration
* Must be consistent with access_token module
*/
typedef enum {
APL_INVALID = 0,
APL_NORMAL = 1,
APL_SYSTEM_BASIC = 2,
APL_SYSTEM_CORE = 3,
} AplLevel;
uint32_t GetSpawnId(void);
int CleanupStaleSpawns(void);
int OnMessageRebuildFromSPM(AppSpawnMgr *mgr, AppSpawningCtx *ctx);
int OnSpawnAbortUpdateRefCount(AppSpawnMgr *mgr, AppSpawningCtx *ctx);
int OnAppExitUpdateRefCount(const AppSpawnMgr *mgr, const AppSpawnedProcess *appInfo);
#ifdef __cplusplus
}
#endif
#endif