提交 2cf32991 编写于 作者: X xionglei6

fix:支持js GetUdid接口安全校验

支持js GetUdid接口安全校验
支持js GetSerial接口安全校验
Signed-off-by: Nxionglei6 <xionglei6@huawei.com>
上级 424c315d
......@@ -43,11 +43,12 @@
"//base/startup/init_lite/services/begetctl:paramshell",
"//base/startup/init_lite/services/plugin:plugin",
"//base/startup/init_lite/interfaces/innerkits:libbegetutil",
"//base/startup/init_lite/interfaces/innerkits:libservice_watcher",
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/interfaces/innerkits/file:libfile",
"//base/startup/init_lite/interfaces/innerkits/socket:libsocket",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/interfaces/innerkits/plugin:libplugin"
"//base/startup/init_lite/interfaces/innerkits/plugin:libplugin",
"//base/startup/init_lite/device_info:device_info_group"
],
"inner_kits": [
{
......@@ -72,7 +73,7 @@
"service_watcher.h"
]
},
"name": "//base/startup/init_lite/interfaces/innerkits:libservice_watcher"
"name": "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy"
}
],
"test": [
......
# Copyright (c) 2021 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("//build/ohos.gni")
import("//build/ohos/sa_profile/sa_profile.gni")
ohos_sa_profile("device_info_profile") {
sources = [ "etc/3902.xml" ]
part_name = "init"
}
ohos_prebuilt_etc("device_info.cfg") {
source = "etc/deviceinfoservice.cfg"
relative_install_dir = "init"
part_name = "init"
}
ohos_shared_library("deviceinfoservice") {
sources = [ "device_info_stub.cpp" ]
defines = [
"INIT_AGENT",
"DINFO_LABEL=\"DeviceInfoService\"",
]
include_dirs = [
".",
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/syspara_lite/hals/parameter/include",
"//utils/native/base/include",
"//utils/system/safwk/native/include",
]
deps = [
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/syspara_lite/hals/parameter:sysparam_hal",
"//third_party/bounds_checking_function:libsec_shared",
"//utils/native/base:utils",
]
external_deps = [
"access_token:libaccesstoken_sdk",
"hilog_native:libhilog",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
install_images = [ "system" ]
part_name = "init"
}
group("device_info_group") {
deps = [
":device_info.cfg",
":device_info_profile",
":deviceinfoservice",
]
}
/*
* Copyright (c) 2021 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.
*/
#include "device_info_kits.h"
#include "beget_ext.h"
#include "device_info_proxy.h"
#include "idevice_info.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "securec.h"
namespace {
static constexpr int UDID_LEN = 65;
static constexpr int MAX_SERIAL_LEN = 65;
} // namespace name
namespace OHOS {
namespace device_info {
DeviceInfoKits::DeviceInfoKits() {}
DeviceInfoKits::~DeviceInfoKits() {}
DeviceInfoKits &DeviceInfoKits::GetInstance()
{
return DelayedRefSingleton<DeviceInfoKits>::GetInstance();
}
void DeviceInfoKits::ResetService(const wptr<IRemoteObject> &remote)
{
std::lock_guard<std::mutex> lock(lock_);
if (deviceInfoService_ != nullptr) {
sptr<IRemoteObject> object = deviceInfoService_->AsObject();
if ((object != nullptr) && (remote == object)) {
object->RemoveDeathRecipient(deathRecipient_);
deviceInfoService_ = nullptr;
}
}
}
sptr<IDeviceInfo> DeviceInfoKits::GetService()
{
std::lock_guard<std::mutex> lock(lock_);
if (deviceInfoService_ != nullptr) {
return deviceInfoService_;
}
sptr<ISystemAbilityManager> samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
DINFO_CHECK(samgr != nullptr, return nullptr, "Get samgr failed");
sptr<IRemoteObject> object = samgr->GetSystemAbility(SYSPARAM_DEVICE_SERVICE_ID);
DINFO_CHECK(object != nullptr, return nullptr, "Get device service object from samgr failed");
if (deathRecipient_ == nullptr) {
deathRecipient_ = new DeathRecipient();
}
if ((object->IsProxyObject()) && (!object->AddDeathRecipient(deathRecipient_))) {
DINFO_LOGE("Failed to add death recipient");
}
deviceInfoService_ = iface_cast<IDeviceInfo>(object);
if (deviceInfoService_ == nullptr) {
DINFO_LOGE("device service iface_cast failed");
}
return deviceInfoService_;
}
void DeviceInfoKits::DeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
{
DelayedRefSingleton<DeviceInfoKits>::GetInstance().ResetService(remote);
}
int32_t DeviceInfoKits::GetUdid(std::string& result)
{
printf("DeviceInfoKits::GetUdid \n");
auto deviceService = GetService();
DINFO_CHECK(deviceService != nullptr, return -1, "Failed to get watcher manager");
return deviceService->GetUdid(result);
}
int32_t DeviceInfoKits::GetSerialID(std::string& result)
{
auto deviceService = GetService();
DINFO_CHECK(deviceService != nullptr, return -1, "Failed to get watcher manager");
return deviceService->GetSerialID(result);
}
} // namespace device_info
} // namespace OHOS
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
int AclGetDevUdid(char *udid, int size)
{
if (udid == nullptr || size < UDID_LEN) {
return -1;
}
printf("AclGetDevUdid \n");
DINFO_LOGI("AclGetDevUdid");
std::string result = {};
OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance();
int ret = instance.GetUdid(result);
if (ret == 0) {
ret = strcpy_s(udid, size, result.c_str());
}
printf("GetDevUdid %s \n", udid);
DINFO_LOGI("GetDevUdid %s", udid);
return ret;
}
const char *AclGetSerial(void)
{
DINFO_LOGI("AclGetSerial");
static char serialNumber[MAX_SERIAL_LEN] = {"1234567890"};
std::string result = {};
OHOS::device_info::DeviceInfoKits &instance = OHOS::device_info::DeviceInfoKits::GetInstance();
int ret = instance.GetSerialID(result);
if (ret == 0) {
(void)strcpy_s(serialNumber, sizeof(serialNumber), result.c_str());
}
DINFO_LOGI("GetSerial %s", serialNumber);
return serialNumber;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#ifndef OHOS_SYSTEM_DEVICE_ID_KITS_S
#define OHOS_SYSTEM_DEVICE_ID_KITS_S
#include <mutex>
#include "idevice_info.h"
#include "singleton.h"
namespace OHOS {
namespace device_info {
class DeviceInfoKits final : public DelayedRefSingleton<DeviceInfoKits> {
DECLARE_DELAYED_REF_SINGLETON(DeviceInfoKits);
public:
DISALLOW_COPY_AND_MOVE(DeviceInfoKits);
static DeviceInfoKits &GetInstance();
int32_t GetUdid(std::string& result);
int32_t GetSerialID(std::string& result);
void ResetService(const wptr<IRemoteObject> &remote);
// For death event procession
class DeathRecipient final : public IRemoteObject::DeathRecipient {
public:
DeathRecipient() = default;
~DeathRecipient() final = default;
DISALLOW_COPY_AND_MOVE(DeathRecipient);
void OnRemoteDied(const wptr<IRemoteObject> &remote) final;
};
sptr<IRemoteObject::DeathRecipient> GetDeathRecipient()
{
return deathRecipient_;
}
private:
sptr<IDeviceInfo> GetService();
std::mutex lock_;
sptr<IDeviceInfo> deviceInfoService_ {};
sptr<IRemoteObject::DeathRecipient> deathRecipient_ {};
};
} // namespace device_info
} // namespace OHOS
#endif // OHOS_SYSTEM_DEVICE_ID_KITS_S
/*
* Copyright (c) 2021 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.
*/
#include "device_info_proxy.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "parcel.h"
#include "string_ex.h"
namespace OHOS {
namespace device_info {
int32_t DeviceInfoProxy::GetUdid(std::string& result)
{
MessageParcel data;
MessageParcel reply;
MessageOption option { MessageOption::TF_SYNC };
printf("DeviceInfoProxy::GetUdid \n");
data.WriteInterfaceToken(DeviceInfoProxy::GetDescriptor());
int32_t ret = Remote()->SendRequest(COMMAND_GET_UDID, data, reply, option);
DINFO_CHECK(ret == ERR_NONE, return ret, "getUdid failed, error code is %d", ret);
result = Str16ToStr8(reply.ReadString16());
return ERR_OK;
}
int32_t DeviceInfoProxy::GetSerialID(std::string& result)
{
MessageParcel data;
MessageParcel reply;
MessageOption option { MessageOption::TF_SYNC };
data.WriteInterfaceToken(DeviceInfoProxy::GetDescriptor());
int32_t ret = Remote()->SendRequest(COMMAND_GET_SERIAL_ID, data, reply, option);
DINFO_CHECK(ret == ERR_NONE, return ret, "GetSerial failed, error code is %d", ret);
result = Str16ToStr8(reply.ReadString16());
return ERR_OK;
}
} // namespace device_info
} // namespace OHOS
/*
* Copyright (c) 2021 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.
*/
#ifndef OHOS_SYSTEM_DEVICEIDPROXY_H
#define OHOS_SYSTEM_DEVICEIDPROXY_H
#include "iremote_proxy.h"
#include "idevice_info.h"
namespace OHOS {
namespace device_info {
class DeviceInfoProxy : public IRemoteProxy<IDeviceInfo> {
public:
explicit DeviceInfoProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IDeviceInfo>(impl) {}
virtual ~DeviceInfoProxy() {}
virtual int32_t GetUdid(std::string& result) override;
virtual int32_t GetSerialID(std::string& result) override;
private:
static inline BrokerDelegator<DeviceInfoProxy> delegator_;
};
} // namespace system
} // namespace OHOS
#endif // OHOS_SYSTEM_DEVICEIDPROXY_H
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#include "device_info_stub.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "ipc_skeleton.h"
#include "accesstoken_kit.h"
#include "parameter_hal.h"
#include "parcel.h"
#include "string_ex.h"
#include "system_ability_definition.h"
using std::u16string;
namespace {
static constexpr int UDID_LEN = 65;
} // namespace name
namespace OHOS {
using namespace Security;
using namespace Security::AccessToken;
namespace device_info {
REGISTER_SYSTEM_ABILITY_BY_ID(DeviceInfoService, SYSPARAM_DEVICE_SERVICE_ID, true)
int32_t DeviceInfoStub::OnRemoteRequest(uint32_t code,
MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
std::u16string myDescripter = IDeviceInfo::GetDescriptor();
std::u16string remoteDescripter = data.ReadInterfaceToken();
DINFO_CHECK(myDescripter == remoteDescripter, return ERR_INVALD_DESC, "Invalid remoteDescripter");
int ret = ERR_FAIL;
switch (code) {
case COMMAND_GET_UDID: {
if (!CheckPermission(data, PERMISSION_UDID)) {
return ERR_FAIL;
}
char localDeviceInfo[UDID_LEN] = {0};
ret = HalGetDevUdid(localDeviceInfo, UDID_LEN);
DINFO_CHECK(ret == 0, break, "Failed to get dev udid");
reply.WriteString16(Str8ToStr16(localDeviceInfo));
break;
}
case COMMAND_GET_SERIAL_ID: {
if (!CheckPermission(data, PERMISSION_UDID)) {
return ERR_FAIL;
}
const char *serialNumber = HalGetSerial();
DINFO_CHECK(serialNumber != nullptr, break, "Failed to get serialNumber");
reply.WriteString16(Str8ToStr16(serialNumber));
break;
}
default: {
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}
return ret;
}
bool DeviceInfoStub::CheckPermission(MessageParcel &data, const std::string &permission)
{
AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
int32_t result = TypePermissionState::PERMISSION_GRANTED;
int32_t tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken);
if (tokenType == TOKEN_NATIVE) {
#ifdef SUPPORT_NATIVE
result = AccessTokenKit::VerifyNativeToken(callerToken, permission);
#endif
} else if (tokenType == TOKEN_HAP) {
result = AccessTokenKit::VerifyAccessToken(callerToken, permission);
} else {
DINFO_LOGE("AccessToken type:%d, permission:%d denied!", tokenType, callerToken);
return false;
}
if (result == TypePermissionState::PERMISSION_DENIED) {
DINFO_LOGE("AccessTokenID:%d, permission:%s denied!", callerToken, permission.c_str());
return false;
}
DINFO_LOGI("dAccessTokenID:%d, permission:%s matched!", callerToken, permission.c_str());
return true;
}
int32_t DeviceInfoService::GetUdid(std::string& result)
{
return 0;
}
int32_t DeviceInfoService::GetSerialID(std::string& result)
{
return 0;
}
void DeviceInfoService::OnStart(void)
{
DINFO_LOGI("WatcherManager OnStart");
bool res = Publish(this);
if (!res) {
DINFO_LOGE("WatcherManager Publish failed");
}
return;
}
void DeviceInfoService::OnStop()
{
}
} // namespace device_info
} // namespace OHOS
/*
* Copyright (c) 2021 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.
*/
#ifndef OHOS_SYSTEM_DEVICEIDSTUB_H
#define OHOS_SYSTEM_DEVICEIDSTUB_H
#include "iremote_stub.h"
#include "idevice_info.h"
#include "system_ability.h"
namespace OHOS {
namespace device_info {
class DeviceInfoStub : public IRemoteStub<IDeviceInfo> {
public:
int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
MessageOption &option) override;
private:
bool CheckPermission(MessageParcel &data, const std::string &permission);
};
class DeviceInfoService : public SystemAbility, public DeviceInfoStub {
public:
DECLARE_SYSTEM_ABILITY(DeviceInfoService);
DISALLOW_COPY_AND_MOVE(DeviceInfoService);
explicit DeviceInfoService(int32_t systemAbilityId, bool runOnCreate = true)
: SystemAbility(systemAbilityId, runOnCreate)
{
}
~DeviceInfoService() override {}
virtual int32_t GetUdid(std::string& result) override;
virtual int32_t GetSerialID(std::string& result) override;
protected:
void OnStart() override;
void OnStop() override;
};
} // namespace device_info
} // namespace OHOS
#endif // OHOS_SYSTEM_DEVICEIDSTUB_H
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2021 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.
-->
<info>
<process>deviceinfoservice</process>
<systemability>
<name>3902</name>
<libpath>libdeviceinfoservice.z.so</libpath>
<run-on-create>true</run-on-create>
<distributed>false</distributed>
<dump-level>1</dump-level>
</systemability>
</info>
\ No newline at end of file
{
"jobs" : [ {
"name" : "services:deviceinfoservice",
"cmds" : [
"chown shell system /data/init_agent",
"chmod 0771 /data/init_agent",
"chown shell system /data/init_agent/begetctrl.log",
"chown shell system /data/init_agent/device_infokits.log",
"chmod 0666 /data/init_agent/begetctrl.log",
"chmod 0666 /data/init_agent/param.log",
"chmod 0666 /data/init_agent/device_infokits.log"
]
}
],
"services" : [{
"name" : "deviceinfoservice",
"path" : ["/system/bin/sa_main", "/system/profile/deviceinfoservice.xml"],
"uid" : "system",
"gid" : ["system", "shell"],
"jobs" : {
"on-start" : "services:deviceinfoservice"
}
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#ifndef OHOS_SYSTEM_IDEVICEID_H
#define OHOS_SYSTEM_IDEVICEID_H
#include <iostream>
#include "beget_ext.h"
#include "iremote_broker.h"
#include "iremote_proxy.h"
namespace OHOS {
namespace device_info {
class IDeviceInfo : public OHOS::IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.system.IDeviceInfo");
virtual int32_t GetUdid(std::string& result) = 0;
virtual int32_t GetSerialID(std::string& result) = 0;
static constexpr int COMMAND_GET_UDID = MIN_TRANSACTION_ID + 0;
static constexpr int COMMAND_GET_SERIAL_ID = MIN_TRANSACTION_ID + 1;
static constexpr int ERR_FAIL = -1;
static constexpr int ERR_INVALD_DESC = -1;
const std::string PERMISSION_UDID = "ohos.permission.sec.ACCESS_UDID";
};
} // namespace device_info
} // namespace OHOS
#define DINFO_LOGI(fmt, ...) STARTUP_LOGI("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGE(fmt, ...) STARTUP_LOGE("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_LOGV(fmt, ...) STARTUP_LOGV("begetctrl.log", "DeviceInfoKits", fmt, ##__VA_ARGS__)
#define DINFO_CHECK(ret, exper, ...) \
if (!(ret)) { \
DINFO_LOGE(__VA_ARGS__); \
exper; \
}
#define DINFO_ONLY_CHECK(ret, exper, ...) \
if (!(ret)) { \
exper; \
}
#endif // OHOS_SYSTEM_IDEVICEID_H
\ No newline at end of file
......@@ -63,29 +63,38 @@ ohos_shared_library("libbegetutil") {
}
# watcher lib must separate compilation avoid interdependence.
ohos_shared_library("libservice_watcher") {
sources = [ "service_watcher/service_watcher.c" ]
ohos_shared_library("libbeget_proxy") {
sources = [
"//base/startup/init_lite/device_info/device_info_kits.cpp",
"//base/startup/init_lite/device_info/device_info_proxy.cpp",
"service_watcher/service_watcher.c",
]
include_dirs = [
"./include",
"//base/startup/init_lite/device_info",
"//utils/native/base/include",
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/include/param",
"//third_party/bounds_checking_function/include",
]
deps = [
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//utils/native/base:utils",
]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
part_name = "init"
install_images = [
"system",
"updater",
external_deps = [
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
part_name = "init"
install_images = [ "system" ]
}
# For init only
......
......@@ -52,7 +52,7 @@ ohos_executable("begetctl") {
if (param_test) {
sources += [ "//base/startup/init_lite/test/plugintest/plugin_param_cmd.c" ]
deps += [
"//base/startup/init_lite/interfaces/innerkits:libservice_watcher",
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
]
......@@ -110,7 +110,7 @@ ohos_executable("paramshell") {
if (param_test) {
sources += [ "//base/startup/init_lite/test/plugintest/plugin_param_cmd.c" ]
deps += [
"//base/startup/init_lite/interfaces/innerkits:libservice_watcher",
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
]
......
......@@ -25,6 +25,7 @@
#include "service_watcher.h"
#include "shell_utils.h"
#include "sys_param.h"
#include "parameter.h"
#define READ_DURATION 100000
static char *GetLocalBuffer(uint32_t *buffSize)
......@@ -148,6 +149,16 @@ static int32_t BShellParamCmdGroupTest(BShellHandle shell, int32_t argc, char *a
return 0;
}
static int32_t BShellParamCmdUdidGet(BShellHandle shell, int32_t argc, char *argv[])
{
PLUGIN_CHECK(argc >= 1, return -1, "Invalid parameter");
PLUGIN_LOGI("BShellParamCmdUdidGet ");
char localDeviceId[65] = {0}; // 65 udid len
AclGetDevUdid(localDeviceId, 65); // 65 udid len
BShellEnvOutput(shell, " udid: %s\r\n", localDeviceId);
return 0;
}
int32_t BShellCmdRegister(BShellHandle shell, int execMode)
{
if (execMode == 0) {
......@@ -165,6 +176,7 @@ int32_t BShellCmdRegister(BShellHandle shell, int execMode)
{"install", BShellParamCmdInstall, "install plugin", "install [name]", ""},
{"uninstall", BShellParamCmdInstall, "uninstall plugin", "uninstall [name]", ""},
{"group", BShellParamCmdGroupTest, "group test", "group test [stage]", "group test"},
{"display", BShellParamCmdUdidGet, "display udid", "display udid", "display udid"},
};
for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++) {
BShellEnvRegitsterCmd(GetShellHandle(), &infos[i]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册