OpenHarmony开发者论坛

标题: OpenHarmony4.1软总线测试工具SoftBusDumpDeviceInfo 运行失败 [打印本页]

作者: liuxinli    时间: 2024-7-4 15:04
标题: OpenHarmony 私库搭建求助
在mac 上 搭建私库   创建自动化脚本时  上传har包到远程仓库时需要输入创建公私钥时输入的密码   这一步怎么自动化   目前使用expect 没有效果

#expect

/usr/bin/expect << EOF

spawn ohpm publish name.har --publish_registry http://*********/repos/ohpm

expect "what is your passphrase of the private key"

send "******\r"  

expect eof

interact   

EOF

作者: shixiaocheng    时间: 2024-7-5 17:09
那就添加ohos.permission.DISTRIBUTED_DATASYNC这个权限,例如
inline void AddPermission()
{
    uint64_t tokenId;
    const char *perms[2];
    perms[1] = OHOS_PERMISSION_DISTRIBUTED_SOFTBUS_CENTER;
    perms[0] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
    NativeTokenInfoParams infoInstance = {
        .dcapsNum = 0,
        .permsNum = 2,
        .aclsNum = 0,
        .dcaps = NULL,
        .perms = perms,
        .acls = NULL,
        .processName = "com.huawei.dmsdp.sxc",
        .aplStr = "system_core",
    };
    tokenId = GetAccessTokenId(&infoInstance);
    SetSelfTokenID(tokenId);
}
作者: liuxinli    时间: 2024-7-8 15:15
回复 shixiaocheng: 加入此函数后,需要引用accesstoken相关库,再编译时遇到此问题:

Exception: deps validation part_name: 'dsoftbus', target: '//foundation/communication/dsoftbus/tools:SoftBusDumpDeviceInfo', dep: '//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk' failed!!

BUILD.gz 文件如下:

# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//foundation/communication/dsoftbus/dsoftbus.gni")
import("//base/security/access_token/access_token.gni")

ohos_executable("SoftBusDumpDeviceInfo") {
  sources = [ "device_info/get_device_info.c" ]

  include_dirs = [
    "$dsoftbus_root_path/interfaces/kits/common",
    "$dsoftbus_root_path/interfaces/kits/bus_center",
    "$softbus_adapter_common/include",
    "//base/security/access_token/interfaces/innerkits/token_setproc/include",
    "//base/security/access_token/interfaces/innerkits/nativetoken/include",
    "//base/security/access_token/interfaces/innerkits/accesstoken/include"
  ]

  deps = [
    "$dsoftbus_root_path/sdk:softbus_client",
    "//base/security/access_token/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
    "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
    "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc"
    ]

  part_name = "dsoftbus"
  subsystem_name = "communication"
}

group("tool") {
  deps = [ ":SoftBusDumpDeviceInfo" ]
}

作者: liuxinli    时间: 2024-7-8 15:34
试过命令行: setenforce 0

再运行:SoftBusDumpDeviceInfo 也是一样
作者: shixiaocheng    时间: 2024-7-8 17:30
回复 liuxinli: 试试添加external_deps =
        [ "access_token:libaccesstoken_sdk",
          "access_token:libnativetoken",
          "access_token:libtoken_setproc",
          "bluetooth:btframework" ]
作者: liuxinli    时间: 2024-7-9 10:05
回复 shixiaocheng: 加入 “external_deps ” 后可行,但还需要把 get_device_info.c 文件名有 .c 修改成 .cpp  因为 OpenHarmony4.1 版本的"accesstoken_kit.h" 用到了 c++的头文件。
作者: liuxinli    时间: 2024-7-9 11:08
回复 liuxinli:  
dsoftbus_tool/ Downloads / bind_tool  工具的源码,你这边有吗? 我们用的系统时64位,需要重新编译下
作者: yeyao    时间: 昨天 10:15





欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5