From 5cfc5e97a6f9be6603b8d59bcb122e30676fc3a5 Mon Sep 17 00:00:00 2001 From: Pumpkin_G Date: Fri, 11 Mar 2022 13:11:13 +0800 Subject: [PATCH 1/4] update code Signed-off-by: Pumpkin_G --- 1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 1 diff --git a/1 b/1 new file mode 100644 index 00000000..e69de29b -- Gitee From 0638fb92f037ef636b77f574a0c052f5706d7c04 Mon Sep 17 00:00:00 2001 From: Pumpkin_G Date: Fri, 11 Mar 2022 13:11:45 +0800 Subject: [PATCH 2/4] update code Signed-off-by: Pumpkin_G --- 1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 1 diff --git a/1 b/1 deleted file mode 100644 index e69de29b..00000000 -- Gitee From d21dcdfa0aeaa5342bc94b0b41fa617f5841d449 Mon Sep 17 00:00:00 2001 From: Zheng Yongjun Date: Fri, 4 Mar 2022 14:41:17 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1,=20=E4=BF=AE=E6=94=B9webview=E4=B8=BAnweb?= =?UTF-8?q?=202,=20=E7=BC=A9=E5=B0=8F/mnt=E7=9B=AE=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zheng Yongjun --- src/appspawn_server.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 434ae54f..c444a790 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -53,7 +53,7 @@ #include constexpr static mode_t FILE_MODE = 0711; -constexpr static mode_t WEBVIEW_FILE_MODE = 0511; +constexpr static mode_t NWEB_FILE_MODE = 0511; #define APPSPAWN_LOGI(fmt, ...) STARTUP_LOGI("appspawn_server.log", "APPSPAWN", fmt, ##__VA_ARGS__) #define APPSPAWN_LOGE(fmt, ...) STARTUP_LOGE("appspawn_server.log", "APPSPAWN", fmt, ##__VA_ARGS__) @@ -616,6 +616,7 @@ int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appPr std::string destel1DataPath = rootPath + "/data/storage/el1/base"; std::string destel2DataPath = rootPath + "/data/storage/el2/base"; std::string destappdataPath = rootPath + oriappdataPath; + int rc = 0; std::string bundleName = appProperty->bundleName; @@ -642,7 +643,7 @@ int32_t AppSpawnServer::DoAppSandboxMount(const ClientSocket::AppProperty *appPr // to create some useful dir when mount point created std::vector mkdirInfo; std::string dirPath; - mkdirInfo.push_back("/data/storage/el1/bundle/webview"); + mkdirInfo.push_back("/data/storage/el1/bundle/nweb"); for (int i = 0; i < mkdirInfo.size(); i++) { dirPath = rootPath + mkdirInfo[i]; @@ -667,6 +668,10 @@ int32_t AppSpawnServer::DoAppSandboxMountCustomized(const ClientSocket::AppPrope std::string destbundlesPath = rootPath + "/data/bundles/"; DoAppSandboxMountOnce(oriapplicationsPath.c_str(), destbundlesPath.c_str()); + std::string orimntHmdfsPath = "/mnt/hmdfs/"; + std::string destmntHmdfsPath = rootPath + orimntHmdfsPath; + DoAppSandboxMountOnce(orimntHmdfsPath.c_str(), destmntHmdfsPath.c_str()); + // Add distributedfile module support, later reconstruct it std::string oriDistributedPath = "/mnt/hmdfs/" + currentUserId + "/account/merge_view/data/" + bundleName; std::string destDistributedPath = rootPath + "/data/storage/el2/distributedfiles"; @@ -676,11 +681,11 @@ int32_t AppSpawnServer::DoAppSandboxMountCustomized(const ClientSocket::AppPrope std::string destDistributedGroupPath = rootPath + "/data/storage/el2/auth_groups"; DoAppSandboxMountOnce(oriDistributedGroupPath.c_str(), destDistributedGroupPath.c_str()); - // do webview adaption - std::string oriwebviewPath = "/data/app/el1/bundle/public/com.ohos.webviewhap"; - std::string destwebviewPath = destInstallPath + "/webview"; - chmod(destwebviewPath.c_str(), WEBVIEW_FILE_MODE); - DoAppSandboxMountOnce(oriwebviewPath.c_str(), destwebviewPath.c_str()); + // do nweb adaption + std::string orinwebPath = "/data/app/el1/bundle/public/com.ohos.nweb"; + std::string destnwebPath = destInstallPath + "/nweb"; + chmod(destnwebPath.c_str(), NWEB_FILE_MODE); + DoAppSandboxMountOnce(orinwebPath.c_str(), destnwebPath.c_str()); if (bundleName.find("medialibrary") != std::string::npos) { std::string oriMediaPath = "/storage/media/" + currentUserId; @@ -696,6 +701,8 @@ void AppSpawnServer::DoAppSandboxMkdir(std::string sandboxPackagePath, const Cli std::vector mkdirInfo; std::string dirPath; + mkdirInfo.push_back("/mnt/"); + mkdirInfo.push_back("/mnt/hmdfs/"); mkdirInfo.push_back("/data/"); mkdirInfo.push_back("/storage/"); mkdirInfo.push_back("/storage/media"); @@ -763,7 +770,6 @@ int32_t AppSpawnServer::DoSandboxRootFolderCreate(std::string sandboxPackagePath vecInfo.push_back("/sys"); vecInfo.push_back("/sys-prod"); vecInfo.push_back("/system"); - vecInfo.push_back("/mnt"); for (int i = 0; i < vecInfo.size(); i++) { tmpDir = sandboxPackagePath + vecInfo[i]; -- Gitee From 59eb1c4fae295deae63a1946b7c68c6077ca3966 Mon Sep 17 00:00:00 2001 From: Pumpkin_G Date: Fri, 11 Mar 2022 13:42:19 +0800 Subject: [PATCH 4/4] sync code webview to nweb Signed-off-by: Pumpkin_G --- BUILD.gn | 22 +++--- appspawn.gni | 2 +- bundle.json | 122 +++++++++++++++--------------- webviewspawn.cfg => nwebspawn.cfg | 38 +++++----- src/appspawn_server.cpp | 24 +++--- src/include/appspawn_server.h | 4 +- src/main.cpp | 4 +- src/socket/server_socket.cpp | 6 +- 8 files changed, 111 insertions(+), 111 deletions(-) rename webviewspawn.cfg => nwebspawn.cfg (72%) diff --git a/BUILD.gn b/BUILD.gn index 1a1a33e1..c59f4a43 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -116,12 +116,12 @@ ohos_prebuilt_etc("appspawn.rc") { part_name = "${part_name}" } -ohos_executable("webviewspawn") { - defines = [ "WEBVIEW_SPAWN" ] +ohos_executable("nwebspawn") { + defines = [ "NWEB_SPAWN" ] sources = [ "${appspawn_path}/src/main.cpp" ] configs = [ ":appspawn_config" ] deps = [ - "${appspawn_path}:webviewspawn_server", + "${appspawn_path}:nwebspawn_server", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] @@ -131,10 +131,10 @@ ohos_executable("webviewspawn") { part_name = "${part_name}" } -ohos_static_library("webviewspawn_server") { +ohos_static_library("nwebspawn_server") { defines = [ "INIT_AGENT", - "WEBVIEW_SPAWN", + "NWEB_SPAWN", ] sources = [ "${appspawn_path}/src/appspawn_msg_peer.cpp", @@ -172,19 +172,19 @@ ohos_static_library("webviewspawn_server") { part_name = "${part_name}" } -ohos_prebuilt_etc("webviewspawn.rc") { - source = "webviewspawn.cfg" +ohos_prebuilt_etc("nwebspawn.rc") { + source = "nwebspawn.cfg" relative_install_dir = "init" subsystem_name = "${subsystem_name}" part_name = "${part_name}" } -group("webview") { +group("nweb") { deps = [] - if (appspawn_support_webview) { + if (appspawn_support_nweb) { deps += [ - ":webviewspawn", - ":webviewspawn.rc", + ":nwebspawn", + ":nwebspawn.rc", ] } } diff --git a/appspawn.gni b/appspawn.gni index 5fc789cf..6f978961 100644 --- a/appspawn.gni +++ b/appspawn.gni @@ -21,5 +21,5 @@ part_name = "appspawn" module_output_path = "${part_name}/appspawn_l2" declare_args() { - appspawn_support_webview = true + appspawn_support_nweb = true } diff --git a/bundle.json b/bundle.json index ead2fb03..ff9f7319 100644 --- a/bundle.json +++ b/bundle.json @@ -1,62 +1,62 @@ -{ - "name": "@ohos/startup_appspawn", - "description": "app start manager", - "homePage": "https://gitee.com/openharmony", - "version": "3.1", - "license": "Apache License 2.0", - "repository": "https://gitee.com/openharmony/startup_appspawn", - "publishAs": "code-segment", - "segment": { - "destPath": "base/startup/appspawn_standard" - }, - "dirs": {}, - "scripts": {}, - "component": { - "name": "appspawn", - "subsystem": "startup", - "adapted_system_type": [ - "standard" - ], - "features": [ - "appspawn_support_webview" - ], - "rom": "", - "ram": "", - "deps": { - "components": [ - "ability_base", - "hiviewdfx_hilog_native", - "ipc", - "safwk", - "samgr_standard", - "utils_base" - ] - }, - "build": { - "sub_component": [ - "//base/startup/appspawn_standard:appspawn", - "//base/startup/appspawn_standard:appspawn.rc", - "//base/startup/appspawn_standard:appspawn_server", - "//base/startup/appspawn_standard:appspawntools", - "//base/startup/appspawn_standard:webview", - "//base/startup/appspawn_standard/interfaces/innerkits:appspawn_socket_client" - ], - "inner_kits": [ - { - "header": { - "header_base": "//base/startup/appspawn_standard/interfaces/innerkits/include/", - "header_files": [ - "appspawn_socket.h", - "client_socket.h" - ] - }, - "name": "//base/startup/appspawn_standard/interfaces/innerkits:appspawn_socket_client" - } - ], - "test": [ - "//base/startup/appspawn_standard/test:moduletest", - "//base/startup/appspawn_standard/test:unittest" - ] - } - } +{ + "name": "@ohos/startup_appspawn", + "description": "app start manager", + "homePage": "https://gitee.com/openharmony", + "version": "3.1", + "license": "Apache License 2.0", + "repository": "https://gitee.com/openharmony/startup_appspawn", + "publishAs": "code-segment", + "segment": { + "destPath": "base/startup/appspawn_standard" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "appspawn", + "subsystem": "startup", + "adapted_system_type": [ + "standard" + ], + "features": [ + "appspawn_support_nweb" + ], + "rom": "", + "ram": "", + "deps": { + "components": [ + "ability_base", + "hiviewdfx_hilog_native", + "ipc", + "safwk", + "samgr_standard", + "utils_base" + ] + }, + "build": { + "sub_component": [ + "//base/startup/appspawn_standard:appspawn", + "//base/startup/appspawn_standard:appspawn.rc", + "//base/startup/appspawn_standard:appspawn_server", + "//base/startup/appspawn_standard:appspawntools", + "//base/startup/appspawn_standard:nweb", + "//base/startup/appspawn_standard/interfaces/innerkits:appspawn_socket_client" + ], + "inner_kits": [ + { + "header": { + "header_base": "//base/startup/appspawn_standard/interfaces/innerkits/include/", + "header_files": [ + "appspawn_socket.h", + "client_socket.h" + ] + }, + "name": "//base/startup/appspawn_standard/interfaces/innerkits:appspawn_socket_client" + } + ], + "test": [ + "//base/startup/appspawn_standard/test:moduletest", + "//base/startup/appspawn_standard/test:unittest" + ] + } + } } \ No newline at end of file diff --git a/webviewspawn.cfg b/nwebspawn.cfg similarity index 72% rename from webviewspawn.cfg rename to nwebspawn.cfg index dc23b829..f077c365 100644 --- a/webviewspawn.cfg +++ b/nwebspawn.cfg @@ -1,19 +1,19 @@ -{ - "services" : [{ - "name" : "webviewspawn", - "path" : ["/system/bin/webviewspawn"], - "socket" : [{ - "name" : "WebViewSpawn", - "family" : "AF_LOCAL", - "type" : "SOCK_SEQPACKET", - "protocol" : "default", - "permissions" : "0666", - "uid" : "root", - "gid" : "root", - "option" : [ - ] - }], - "ondemand" : true - } - ] -} \ No newline at end of file +{ + "services" : [{ + "name" : "nwebspawn", + "path" : ["/system/bin/nwebspawn"], + "socket" : [{ + "name" : "NWebSpawn", + "family" : "AF_LOCAL", + "type" : "SOCK_SEQPACKET", + "protocol" : "default", + "permissions" : "0666", + "uid" : "root", + "gid" : "root", + "option" : [ + ] + }], + "ondemand" : true + } + ] +} diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index c444a790..512cb894 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -220,7 +220,7 @@ void AppSpawnServer::HandleSignal() void AppSpawnServer::LoadAceLib() { #ifdef WEBVIEW_SPAWN - std::string enginelibdir("/data/app/el1/bundle/public/com.ohos.webviewhap" + std::string enginelibdir("/data/app/el1/bundle/public/com.ohos.nweb" "/libs/arm/libweb_engine.so"); HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libweb_engine. Start calling dlopen enginelibdir."); void *handle = dlopen(enginelibdir.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -231,16 +231,16 @@ void AppSpawnServer::LoadAceLib() } HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libweb_engine. End calling dlopen."); - std::string execlibdir("/data/app/el1/bundle/public/com.ohos.webviewhap" - "/libs/arm/libwebview_exec_proc.so"); - HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libwebview_exec_proc. Start calling dlopen execlibdir."); - webviewHandle = dlopen(execlibdir.c_str(), RTLD_NOW | RTLD_GLOBAL); - if (webviewHandle == nullptr) { + std::string execlibdir("/data/app/el1/bundle/public/com.ohos.nweb" + "/libs/arm/libnweb_render.so"); + HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libnweb_render. Start calling dlopen execlibdir."); + nwebHandle = dlopen(execlibdir.c_str(), RTLD_NOW | RTLD_GLOBAL); + if (nwebHandle == nullptr) { HiLog::Error(LABEL, "Fail to dlopen %{public}s, [%{public}s]", execlibdir.c_str(), dlerror()); } else { HiLog::Info(LABEL, "Success to dlopen %{public}s", execlibdir.c_str()); } - HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libwebview_exec_proc. End calling dlopen."); + HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary libnweb_render. End calling dlopen."); #else std::string acelibdir("/system/lib/libace.z.so"); void *AceAbilityLib = nullptr; @@ -935,14 +935,14 @@ bool AppSpawnServer::SetAppProcProperty(const ClientSocket::AppProperty *appProp // notify success to father process and start app process NotifyResToParentProc(fd, ret); -#ifdef WEBVIEW_SPAWN +#ifdef NWEB_SPAWN using FuncType = void (*)(const char *cmd); - FuncType funcWebViewExecuteProcess = reinterpret_cast(dlsym(webviewHandle, "WebViewExecuteProcess")); - if (funcWebViewExecuteProcess == nullptr) { - HiLog::Error(LABEL, "webviewspawn dlsym ERROR=%{public}s", dlerror()); + FuncType funcNWebRenderMain = reinterpret_cast(dlsym(nwebHandle, "NWebRenderMain")); + if (funcNWebRenderMain == nullptr) { + HiLog::Error(LABEL, "nwebspawn dlsym ERROR=%{public}s", dlerror()); return false; } - funcWebViewExecuteProcess(appProperty->renderCmd); + funcNWebRenderMain(appProperty->renderCmd); #else AppExecFwk::MainThread::Start(); #endif diff --git a/src/include/appspawn_server.h b/src/include/appspawn_server.h index 10f491d1..5836b32d 100644 --- a/src/include/appspawn_server.h +++ b/src/include/appspawn_server.h @@ -209,8 +209,8 @@ private: bool isChildDie_ { false }; pid_t childPid_ {}; std::map appMap_; -#ifdef WEBVIEW_SPAWN - void *webviewHandle = nullptr; +#ifdef NWEB_SPAWN + void *nwebHandle = nullptr; #endif }; } // namespace AppSpawn diff --git a/src/main.cpp b/src/main.cpp index 41e40b2a..95ae423a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,8 +26,8 @@ int main(int argc, char *const argv[]) uintptr_t end = reinterpret_cast(strchr(argv[argc - 1], 0)); uintptr_t argvSize = end - start; -#ifdef WEBVIEW_SPAWN - OHOS::AppSpawn::AppSpawnServer appspawnServer("/dev/unix/socket/WebViewSpawn"); +#ifdef NWEB_SPAWN + OHOS::AppSpawn::AppSpawnServer appspawnServer("/dev/unix/socket/NWebSpawn"); #else OHOS::AppSpawn::AppSpawnServer appspawnServer("AppSpawn"); #endif diff --git a/src/socket/server_socket.cpp b/src/socket/server_socket.cpp index c7def029..7a0b1444 100644 --- a/src/socket/server_socket.cpp +++ b/src/socket/server_socket.cpp @@ -153,8 +153,8 @@ int ServerSocket::RegisterServerSocket(int &connectFd) return -EINVAL; } -#ifdef WEBVIEW_SPAWN - connectFd = GetControlSocket("WebViewSpawn"); +#ifdef NWEB_SPAWN + connectFd = GetControlSocket("NWebSpawn"); #else connectFd = CreateSocket(); #endif @@ -162,7 +162,7 @@ int ServerSocket::RegisterServerSocket(int &connectFd) return connectFd; } -#ifndef WEBVIEW_SPAWN +#ifndef NWEB_SPAWN if ((BindSocket(connectFd) != 0) || (listen(connectFd, listenBacklog_) < 0)) { HiLog::Error(LABEL, "Server: Register socket fd %d with backlog %d error: %d", -- Gitee