• 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 #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__) || defined(NWEB_SPAWN)
27 #define  SOCKET_DIR "/dev/unix/socket/"
28 #else
29 #define  SOCKET_DIR "/dev/socket/"
30 #endif
31 
32 #ifdef NWEB_SPAWN
33 #define APPSPAWN_SOCKET_NAME "NWebSpawn"
34 #define APPSPAWN_SERVER_NAME "nwebspawn"
35 #else
36 #define APPSPAWN_SOCKET_NAME "AppSpawn"
37 #define APPSPAWN_SERVER_NAME "appspawn"
38 #endif
39 
40 enum AppType {
41     APP_TYPE_DEFAULT = 0,  // JavaScript app
42     APP_TYPE_NATIVE        // Native C++ app
43 };
44 
45 typedef enum AppOperateType_ {
46     DEFAULT = 0,
47     GET_RENDER_TERMINATION_STATUS,
48 } AppOperateType;
49 
50 #define APP_MSG_MAX_SIZE 4096  // appspawn message max size
51 #define APP_LEN_PROC_NAME 256         // process name length
52 #define APP_LEN_BUNDLE_NAME 256       // bundle name length
53 #define APP_LEN_SO_PATH 256             // load so lib
54 #define APP_MAX_GIDS 64
55 #define APP_APL_MAX_LEN 32
56 #define APP_RENDER_CMD_MAX_LEN 1024
57 
58 /* AppParameter.flags bit definition */
59 #define APP_COLD_BOOT 0x01
60 #define APP_BACKUP_EXTENSION 0x02
61 #define APP_DLP_MANAGER 0x04
62 #define APP_DEBUGGABLE 0x08  // debuggable application
63 #define APP_ASANENABLED 0x10
64 #define APP_ACCESS_BUNDLE_DIR 0x20
65 
66 #define BITLEN32 32
67 #define FDLEN2 2
68 #define FD_INIT_VALUE 0
69 
70 typedef struct AppParameter_ {
71     uint32_t cloneFlags;
72     uint32_t uid;                     // the UNIX uid that the child process setuid() to after fork()
73     uint32_t gid;                     // the UNIX gid that the child process setgid() to after fork()
74     uint32_t gidTable[APP_MAX_GIDS];      // a list of UNIX gids that the child process setgroups() to after fork()
75     uint32_t gidCount;                // the size of gidTable
76     char processName[APP_LEN_PROC_NAME];  // process name
77     char bundleName[APP_LEN_BUNDLE_NAME]; // bundle name
78     char soPath[APP_LEN_SO_PATH];         // so lib path
79     uint32_t accessTokenId;
80     char apl[APP_APL_MAX_LEN];
81     char renderCmd[APP_RENDER_CMD_MAX_LEN];
82     uint32_t flags;
83     int32_t pid;                     // query render process exited status by render process pid
84     int32_t bundleIndex;
85     AppOperateType code;
86 #ifndef APPSPAWN_TEST
87 #ifndef OHOS_LITE
88     uint8_t setAllowInternet;
89     uint8_t allowInternet; // hap sockect allowed
90     uint8_t reserved1;
91     uint8_t reserved2;
92 #endif
93 #endif
94 } AppParameter;
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif
101