自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

OpenHarmony系統(tǒng)之Service代碼一鍵生成工具介紹(二)

系統(tǒng) OpenHarmony
本篇將介紹如何如何將service工具生成的代碼集成到OpenHarmony 4.1 release上。

想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:

51CTO 鴻蒙開發(fā)者社區(qū)

https://ost.51cto.com

前言

上一篇博客我們簡單介紹了service生成工具如何安裝和使用工具生成代碼,以及如何集成到OpenHarmony 3.2 release上;由于OpenHarmony 4.1 release發(fā)生了很大變化,本篇將介紹如何如何將service工具生成的代碼集成到OpenHarmony 4.1 release上。

使用說明

如何安裝并使用service生成工具,請參考上一篇文章:

OpenHarmony系統(tǒng)之Service代碼一鍵生成工具介紹

集成

將service生成工具生成的代碼集成到OpenHarmony 4.1 release

修改編譯文件

修改testservice/BUILD.gn文件,將utils/native 改為 commonlibrary/c_utils,將samgr_standard改為samgr,? 將hiviewdfx_hilog_native改為hilog,在ohos_shared_library(“testservice”)中include_dirs內(nèi)新增"http://base/startup/init/interfaces/innerkits/include/syspara",將ohos_shared_library(“testservice”)中的deps刪除,并刪除external_deps中的"startup_l2:syspara",同時(shí)在external_deps中新增"c_utils:utils", 將ohos_executable(“testclient”)中的deps刪除,同時(shí)在external_deps中新增"c_utils:utils"。修改后的BUILD.gn文件內(nèi)容如下所示:

import("http://build/ohos.gni")

ohos_shared_library("testservice") {
  sources = [
    "http://testservice/src/i_test_service.cpp",
    "http://testservice/src/test_service_stub.cpp",
    "http://testservice/src/test_service.cpp"
  ]
  include_dirs = [
    "http://testservice/include",
    "http://testservice/interface",
    "http://commonlibrary/c_utils/base/include",
    "http://base/startup/init/interfaces/innerkits/include/syspara",
  ]

  external_deps = [
    "hilog:libhilog",
    "ipc:ipc_core",
    "safwk:system_ability_fwk",
    "samgr:samgr_proxy",
    "c_utils:utils",
  ]

  part_name = "testservice_part"
  subsystem_name = "testservice"
}

ohos_executable("testclient") {
    sources = [
    "http://testservice/src/i_test_service.cpp",
    "http://testservice/src/test_service_proxy.cpp",
    "http://testservice/src/test_client.cpp"
  ]

  include_dirs = [
    "http://testservice/include",
    "http://testservice/interface",
    "http://commonlibrary/c_utils/base/include",
  ]

  external_deps = [
    "hilog:libhilog",
    "ipc:ipc_core",
    "samgr:samgr_proxy",
    "c_utils:utils",
  ]

  part_name = "testservice_part"
  subsystem_name = "testservice"
}

修改testservice/bundle.json文件,將"name": “@ohos/testservice"修改為 “name”: “@ohos/testservice_part”;將"samgr_standard"改為"samgr”,“utils_base"修改為"c_utils”;將"hiviewdfx_hilog_native"修改為"hilog";? 將"deps":“components"下的"starup_l2"修改為"syspara_lite”。修改后的bundle.json文件內(nèi)容如下所示:

{
    "name": "@ohos/testservice_part",
    "description": "system ability framework test",
    "homePage": "https://gitee.com/",
    "version": "4.1",
    "license": "Apache License 2.0",
    "repository": "",
    "publishAs": "code-segment",
    "segment": {
        "destPath": "testservice"
    },
    "dirs": {},
    "scripts": {},
    "component": {
        "name": "testservice_part",
        "subsystem": "testservice",
        "adapted_system_type": [
            "standard"
        ],
        "rom": "2048KB",
        "ram": "~4096KB",
        "deps": {
            "components": [
                "hilog",
                "ipc",
                "samgr",
                "c_utils",
                "safwk",
                "syspara_lite"
            ],
            "third_party": [ "libxml2" ]
        },
        "build": {
            "sub_component": [
                "http://testservice:testservice",
                "http://testservice/sa_profile:testservice_sa_profile",
                "http://testservice:testclient",
                "http://testservice/etc:test_service_init"
            ],
            "inner_kits": [
            ],
            "test": [
            ]
        }
    }
}

步驟 1 修改testservice/sa_profile下的文件以及testservice/etc/test_service.cfg文件, 將testservice/sa_profile/9016.xml文件重命名為9016.json,并將內(nèi)容修改為json格式,修改后的9016.json文件如下所示:

{
  "process":"testservice_sa",
      "systemability":[
          {
              "name":9016,
              "libpath":"libtestservice.z.so",
              "run-on-create":false,
              "auto-restart":true,
              "distributed":false,
              "dump-level":1
          }
      ]
}

修改testservice/sa_profile/BUILD.gn文件:將sources = [ “9016.xml” ]修改為sources = [ “9016.json” ]。

修改testservice/etc/test_service.cfg文件:將"path"內(nèi)的testservice_sa.xml修改為testservice_sa.json。

修改系統(tǒng)公共文件

基礎(chǔ)配置

服務(wù)配置:
在foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include/
system_ability_definition.h增加以下一行:

TEST_SERVICE_ID                 = 9016,

在base/hiviewdfx/hidumper/frameworks/native/dump_utils.cpp文件內(nèi)的saNameMap中新增以下一行:

{ TEST_SERVICE_ID, "testservice" },

其中,TEST_SERVICE_ID宏值與用戶定義的serviceID一致。

子系統(tǒng)配置:
在build/subsystem_config.json中增加以下內(nèi)容。

"testservice": {
  "path":"testservice",
  "name": "testservice" 
}

產(chǎn)品配置,如rk3568:
在vendor/kaihong/rk3568/config.json中增加以下內(nèi)容:

{  
 "subsystem": "testservice", 
 "components": [
  {
   "component": "testservice_part",
   "features": []
  }
 ]
}

權(quán)限配置:
在相應(yīng)的產(chǎn)品目錄的vendor/kaihong/rk3568/security_config/high_privilege_process_list.json中增加以下內(nèi)容:

{
  "name": "testservice", 
  "uid": "system",
  "gid": ["root", "system"]
}

selinux權(quán)限配置

上述基礎(chǔ)配置時(shí)關(guān)閉了selinux 權(quán)限配置,用戶新增服務(wù)時(shí)需根據(jù)自身需求配置selinux 權(quán)限 。

若要配置selinux權(quán)限,首先應(yīng)將vendor/hihope/rk3568/config.json中"build_selinux"屬性改為true,然后修改以下文件:

testservice/etc/sample_service.cfg

"secon" : "u:r:testservice:s0"

base/security/selinux_adapter/sepolicy/base/public/service_contexts

9016                 u:object_r:sa_testservice:s0

base/security/selinux_adapter/sepolicy/base/public/service.te

type sa_testservice, sa_service_attr;

base/security/selinux_adapter/sepolicy/ohos_policy/startup/init/system/init.te

allow init testservice:process { getattr rlimitinh siginh transition };

base/security/selinux/sepolicy/base/public/type.te

type testservice, sadomain, domain;

/base/security/selinux/sepolicy/base/te目錄下增加新service的te文件,新增文件名即為服務(wù)名,例如:testservice.te

allow testservice init_param:file { map open read };
allow testservice sa_testservice:samgr_class { add get };

運(yùn)行

用戶根據(jù)需求增加服務(wù)端客戶端代碼,編譯鏡像并燒錄到開發(fā)板,查看服務(wù)是否正常啟動,并運(yùn)行客戶端查看運(yùn)行結(jié)果。具體如何增加示例代碼以及查看最終結(jié)果,可查看上一篇文章:

OpenHarmony系統(tǒng)之Service代碼一鍵生成工具介紹

想了解更多關(guān)于開源的內(nèi)容,請?jiān)L問:

51CTO 鴻蒙開發(fā)者社區(qū)

https://ost.51cto.com

責(zé)任編輯:jianghua 來源: 51CTO 鴻蒙開發(fā)者社區(qū)
相關(guān)推薦

2023-06-01 15:30:30

Service代碼生成工具

2024-06-21 10:27:21

Service生成工具鴻蒙

2024-01-03 15:41:49

2020-10-10 14:57:16

代碼開發(fā)工具

2020-06-30 15:10:58

命令行應(yīng)用開發(fā)工具

2024-03-26 15:25:55

應(yīng)用接口文件轉(zhuǎn)換工具鴻蒙

2021-11-30 08:09:52

PostgreSQLPGTune工具數(shù)據(jù)庫

2019-10-11 11:00:53

Nginx神器前端

2022-08-02 14:27:01

HDF驅(qū)動框架驅(qū)動開發(fā)

2024-03-15 14:34:12

Oracle數(shù)據(jù)庫一鍵巡檢

2015-02-09 15:25:52

換膚

2020-05-11 09:40:47

IDEA代碼神器

2023-12-19 15:45:07

Linux工具

2025-03-03 03:35:00

DeepSeekXmind思維導(dǎo)圖

2023-03-05 23:11:07

Go語言服務(wù)

2020-12-24 10:20:43

文檔工具語言

2022-01-09 23:09:08

Windows 10Windows微軟

2011-09-15 19:05:49

windows 7一鍵關(guān)機(jī)

2023-03-31 09:30:21

ChatGPT論文

2011-09-29 15:23:18

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號