1 /* 2 * Copyright (c) 2021-2023 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 #ifndef APPSPAWN_MSG_H 17 #define APPSPAWN_MSG_H 18 19 #include <stdint.h> 20 #include <stdlib.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #if defined(__MUSL__) 27 #ifndef APPSPAWN_TEST 28 #define SOCKET_DIR "/dev/unix/socket/" 29 #else 30 #define SOCKET_DIR "/data/appspawn_ut/dev/unix/socket/" 31 #endif 32 #else 33 #define SOCKET_DIR "/dev/socket/" 34 #endif 35 36 37 #define NWEBSPAWN_SOCKET_NAME "NWebSpawn" 38 #define NWEBSPAWN_SERVER_NAME "nwebspawn" 39 #define APPSPAWN_SOCKET_NAME "AppSpawn" 40 #define APPSPAWN_SERVER_NAME "appspawn" 41 42 43 enum AppType { 44 APP_TYPE_DEFAULT = 0, // JavaScript app 45 APP_TYPE_NATIVE // Native C++ app 46 }; 47 48 typedef enum AppOperateType_ { 49 DEFAULT = 0, 50 GET_RENDER_TERMINATION_STATUS, 51 SPAWN_NATIVE_PROCESS 52 } AppOperateType; 53 54 #define APP_MSG_MAX_SIZE 4096 // appspawn message max size 55 #define APP_LEN_PROC_NAME 256 // process name length 56 #define APP_LEN_BUNDLE_NAME 256 // bundle name length 57 #define APP_LEN_SO_PATH 256 // load so lib 58 #define APP_MAX_GIDS 64 59 #define APP_APL_MAX_LEN 32 60 #define APP_RENDER_CMD_MAX_LEN 1024 61 #define APP_OWNER_ID_LEN 64 62 63 /* AppParameter.flags bit definition */ 64 #define APP_COLD_BOOT 0x01 65 #define APP_BACKUP_EXTENSION 0x02 66 #define APP_DLP_MANAGER 0x04 67 #define APP_DEBUGGABLE 0x08 // debuggable application 68 #define APP_ASANENABLED 0x10 69 #define APP_ACCESS_BUNDLE_DIR 0x20 70 #define APP_NATIVEDEBUG 0X40 71 #define APP_NO_SANDBOX 0x80 // Do not enter sandbox 72 #define APP_OVERLAY_FLAG 0x100 73 #define GET_BUNDLE_RESOURCES_FLAG 0x200 74 75 #define BITLEN32 32 76 #define FDLEN2 2 77 #define FD_INIT_VALUE 0 78 79 typedef struct ExtraInfo_ { 80 uint32_t totalLength; 81 uint32_t savedLength; 82 char* data; 83 } ExtraInfo; 84 85 typedef struct AppParameter_ { 86 AppOperateType code; 87 uint32_t flags; 88 int32_t pid; // query render process exited status by render process pid 89 uint32_t uid; // the UNIX uid that the child process setuid() to after fork() 90 uint32_t gid; // the UNIX gid that the child process setgid() to after fork() 91 uint32_t gidCount; // the size of gidTable 92 uint32_t gidTable[APP_MAX_GIDS]; // a list of UNIX gids that the child process setgroups() to after fork() 93 char processName[APP_LEN_PROC_NAME]; // process name 94 char bundleName[APP_LEN_BUNDLE_NAME]; // bundle name 95 char soPath[APP_LEN_SO_PATH]; // so lib path 96 char apl[APP_APL_MAX_LEN]; 97 char renderCmd[APP_RENDER_CMD_MAX_LEN]; 98 char ownerId[APP_OWNER_ID_LEN]; // app identifier id 99 uint32_t accessTokenId; 100 int32_t bundleIndex; 101 uint64_t accessTokenIdEx; 102 uint32_t hapFlags; 103 uint32_t mountPermissionFlags; 104 #ifndef OHOS_LITE 105 uint8_t setAllowInternet; 106 uint8_t allowInternet; // hap sockect allowed 107 uint8_t reserved1; 108 uint8_t reserved2; 109 #endif 110 ExtraInfo extraInfo; // Extera info using by format |type1|...|type1|type2|...|type2| 111 } AppParameter; 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif 118