• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
62 /* AppParameter.flags bit definition */
63 #define APP_COLD_BOOT 0x01
64 #define APP_BACKUP_EXTENSION 0x02
65 #define APP_DLP_MANAGER 0x04
66 #define APP_DEBUGGABLE 0x08  // debuggable application
67 #define APP_ASANENABLED 0x10
68 #define APP_ACCESS_BUNDLE_DIR 0x20
69 #define APP_NATIVEDEBUG 0X40
70 #define APP_NO_SANDBOX 0x80  // Do not enter sandbox
71 #define APP_OVERLAY_FLAG 0x100
72 
73 #define BITLEN32 32
74 #define FDLEN2 2
75 #define FD_INIT_VALUE 0
76 
77 typedef struct HspList_ {
78     uint32_t totalLength;
79     uint32_t savedLength;
80     char* data;
81 } HspList;
82 
83 typedef struct {
84     uint32_t totalLength;
85     char* data;
86 } OverlayInfo;
87 
88 typedef struct {
89     uint32_t totalLength;
90     char* data;
91 } DataGroupInfoList;
92 
93 typedef struct AppParameter_ {
94     AppOperateType code;
95     uint32_t flags;
96     int32_t pid;                     // query render process exited status by render process pid
97     uint32_t uid;                     // the UNIX uid that the child process setuid() to after fork()
98     uint32_t gid;                     // the UNIX gid that the child process setgid() to after fork()
99     uint32_t gidCount;                // the size of gidTable
100     uint32_t gidTable[APP_MAX_GIDS];      // a list of UNIX gids that the child process setgroups() to after fork()
101     char processName[APP_LEN_PROC_NAME];  // process name
102     char bundleName[APP_LEN_BUNDLE_NAME]; // bundle name
103     char soPath[APP_LEN_SO_PATH];         // so lib path
104     char apl[APP_APL_MAX_LEN];
105     char renderCmd[APP_RENDER_CMD_MAX_LEN];
106     uint32_t accessTokenId;
107     int32_t bundleIndex;
108     uint64_t accessTokenIdEx;
109     uint32_t hapFlags;
110     uint32_t mountPermissionFlags;
111 #ifndef OHOS_LITE
112     uint8_t setAllowInternet;
113     uint8_t allowInternet; // hap sockect allowed
114     uint8_t reserved1;
115     uint8_t reserved2;
116 #endif
117     HspList hspList; // list of cross-app hsp (Harmony Shared Package) to mount onto app sandbox
118     OverlayInfo overlayInfo; // overlay info
119     DataGroupInfoList dataGroupInfoList; // list of the share sandbox path info
120 } AppParameter;
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif
127