mirror of
https://github.com/openharmony/device_manager.git
synced 2026-07-19 18:13:32 -04:00
@@ -11,13 +11,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
lite_component("devicemanager_lite") {
|
||||
features = [
|
||||
"utils:devicemanagerutils",
|
||||
"services/devicemanagerservice:devicemanagerservice",
|
||||
"interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
]
|
||||
if (ohos_kernel_type == "liteos_m") {
|
||||
} else {
|
||||
features = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* 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_DEVICE_MANAGER_CONSTANTS_H
|
||||
#define OHOS_DEVICE_MANAGER_CONSTANTS_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
const std::string TARGET_PKG_NAME_KEY = "targetPkgName";
|
||||
const std::string HOST_PKG_NAME_KEY = "hostPackageName";
|
||||
|
||||
const int32_t LOG_MAX_LEN = 512;
|
||||
const int32_t MIN_PIN_TOKEN = 10000000;
|
||||
const int32_t MAX_PIN_TOKEN = 90000000;
|
||||
const int32_t MIN_PIN_CODE = 100000;
|
||||
const int32_t MAX_PIN_CODE = 999999;
|
||||
const int32_t TOKEN_LEN = 9;
|
||||
|
||||
const int32_t FAIL = -1;
|
||||
const int32_t SUCCESS = 0;
|
||||
const int32_t ERROR_INPUT_PARA_EMPTY = 2000;
|
||||
const int32_t ERROR_INPUT_PARA_INVALID = 2001;
|
||||
const int32_t ERROR_TARGET_PKG_NAME_NULL = 2002;
|
||||
const int32_t ERROR_PKG_NAME_NOT_ON_DISCOVERY = 2003;
|
||||
const int32_t ERROR_START_REMOTE_DM = 2006;
|
||||
const int32_t ERROR_OPEN_CHANNEL_FAIL = 2008;
|
||||
const int32_t ERROR_SEND_COMMAND_FAIL = 2009;
|
||||
const int32_t ERROR_CHANNEL_BROKEN = 2010;
|
||||
const int32_t ERROR_DUPLICATE_REQUEST = 2011;
|
||||
const int32_t ERROR_TIME_OUT = 2012;
|
||||
const int32_t ERROR_REQUEST_CANCEL = 2013;
|
||||
const int32_t ERROR_USER_REJECT = 2015;
|
||||
const int32_t ERROR_USER_BUSY = 2016;
|
||||
const int32_t ERROR_API_NOT_SUPPORT = 2018;
|
||||
const int32_t ERROR_SESSION_NOT_EXIT = 2019;
|
||||
const int32_t ERROR_CREAT_GROUP_FAIL = 2020;
|
||||
const int32_t ERROR_JOIN_GROUP_FAIL = 2021;
|
||||
const int32_t ERROR_GET_LOCAL_DEVICE_INFO_FAIL = 2022;
|
||||
const int32_t ERROR_CHECK_AUTH_FAIL = 2023;
|
||||
const int32_t ERROR_NETWORK_UNAVAILABLE = 2028;
|
||||
const int32_t ERROR_DEVICE_INFO_NULL = 2030;
|
||||
const int32_t ERROR_APP_NAME_NULL = 2031;
|
||||
const int32_t ERROR_APP_DESCRIPTION_INVALID = 2032;
|
||||
const int32_t ERROR_APP_ICON_INVALID = 2033;
|
||||
const int32_t ERROR_APP_THUMBNAIL_INVALID = 2034;
|
||||
const int32_t ERROR_FA_START_FAIL = 2100;
|
||||
|
||||
const int32_t ENCRYPT_TAG_LEN = 32;
|
||||
|
||||
const std::string TAG_REQUESTER = "REQUESTER";
|
||||
const std::string TAG_TOKEN = "TOKEN";
|
||||
const std::string TAG_HOST = "HOST";
|
||||
const std::string TAG_TARGET = "TARGET";
|
||||
const std::string TAG_VISIBILITY = "VISIBILITY";
|
||||
const std::string TAG_GROUPIDS = "GROUPIDLIST";
|
||||
const std::string TAG_REPLY = "REPLY";
|
||||
const std::string TAG_NET_ID = "NETID";
|
||||
const std::string TAG_GROUP_ID = "GROUPID";
|
||||
const std::string TAG_GROUP_NAME = "GROUPNAME";
|
||||
const std::string TAG_REQUEST_ID = "REQUESTID";
|
||||
const std::string TAG_DEVICE_ID = "DEVICEID";
|
||||
const std::string TAG_DEVICE_TYPE = "DEVICETYPE";
|
||||
const std::string TAG_APP_NAME = "APPNAME";
|
||||
const std::string TAG_APP_DESCRIPTION = "APPDESC";
|
||||
const std::string TAG_APP_ICON = "APPICON";
|
||||
const std::string TAG_APP_THUMBNAIL = "APPTHUM";
|
||||
const std::string TAG_INDEX = "INDEX";
|
||||
const std::string TAG_SLICE_NUM = "SLICE";
|
||||
const std::string TAG_THUMBNAIL_SIZE = "THUMSIZE";
|
||||
const std::string TAG_AUTH_TYPE = "AUTHTYPE";
|
||||
|
||||
const std::string TAG_VER = "ITF_VER";
|
||||
const std::string TAG_TYPE = "MSG_TYPE";
|
||||
const std::string DM_ITF_VER = "1.0";
|
||||
const std::string TAG = "DM_MSG_CODEC";
|
||||
|
||||
// GroupConstants
|
||||
const int32_t GROUP_VISIBILITY_IS_PUBLIC = -1;
|
||||
const int32_t GROUP_VISIBILITY_IS_PRIVATE = 0;
|
||||
const std::string REQUEST_AUTH_ADD_ID = "REQUEST_AUTH_ADD_ID";
|
||||
const std::string INVITATE_AUTH_ADD_ID = "INVITE_AUTH_ADD_ID";
|
||||
const int32_t PIN_CODE_INVALID = -1;
|
||||
|
||||
// AuthConstants
|
||||
const int32_t AUTH_SESSION_SIDE_SERVER = 0;
|
||||
const int32_t AUTH_SESSION_SIDE_CLIENT = 1;
|
||||
const int32_t SESSION_TYPE_IS_DEVICE_AUTH = 0;
|
||||
const int32_t SESSION_TYPE_IS_APP_AUTH = 1;
|
||||
const int32_t SESSION_REPLY_UNKNOWN = -1;
|
||||
const int32_t SESSION_REPLY_ACCEPT = 0;
|
||||
const int32_t SESSION_REPLY_CANCEL = 1;
|
||||
const int32_t SESSION_REPLY_TIMEOUT = 2;
|
||||
const int32_t SESSION_REPLY_AUTH_CONFIRM_TIMEOUT = 2;
|
||||
const int32_t SESSION_REPLY_CANCEL_PINCODE_DISPLAY = 3;
|
||||
const int32_t SESSION_REPLY_CANCEL_PINCODE_INPUT = 4;
|
||||
const int32_t SESSION_REPLY_CREAT_GROUP_FAILED = 7;
|
||||
const int32_t REQUEST_OPERATION = 0;
|
||||
const int32_t QR_OPERATION = 1;
|
||||
const int32_t PIN_OPERATION = 2;
|
||||
const int32_t START_ACTIVITY_DIALOG = 1;
|
||||
const int32_t START_ACTIVITY_QR = 2;
|
||||
const int32_t START_ACTIVITY_FINISH = 3;
|
||||
const int32_t START_ACTIVITY_PIN = 4;
|
||||
const int32_t AUTH_STATUS_SKIP = 3;
|
||||
const int32_t DEFAULT_PIN_CODE = 0;
|
||||
const int32_t DEFAULT_PIN_TOKEN = 0;
|
||||
const std::string DEVICE_NAME_KEY = "deviceName";
|
||||
const std::string DISPLAY_TIME_KEY = "displayTime";
|
||||
const std::string QR_BITMAP_KEY = "qrBitMap";
|
||||
const std::string PIN_CODE_KEY = "pinCode";
|
||||
const std::string START_ACTIVITY_KEY = "startActivityType";
|
||||
const std::string AUTH_TYPE = "authType";
|
||||
const std::string TOKEN = "token";
|
||||
const std::string PIN_TOKEN = "pinToken";
|
||||
const int32_t MSG_TYPE_TO_REMOTE = 0;
|
||||
const int32_t MSG_TYPE_TO_CLOSED_CHANNEL = 1;
|
||||
const std::string APP_NAME_KEY = "appName";
|
||||
const std::string APP_DESCRIPTION_KEY = "appDescription";
|
||||
const std::string APP_ICON_KEY = "appIcon";
|
||||
const std::string APP_THUMBNAIL_KEY = "appThumbnail";
|
||||
const std::string CANCEL_DISPLAY_KEY = "cancelPinCodeDisplay";
|
||||
const int32_t SLICE_NUM_INVALID = -1;
|
||||
const int32_t AUTH_TYPE_QR = 0;
|
||||
const int32_t AUTH_TYPE_PIN = 1;
|
||||
const std::string DISPLAY_OWNER = "displayOwner";
|
||||
const int32_t DISPLAY_OWNER_SYSTEM = 0;
|
||||
const int32_t DISPLAY_OWNER_OTHER = 1;
|
||||
|
||||
// DmService constants
|
||||
const int32_t MSG_MAX_SIZE = 45 * 1024;
|
||||
const int32_t DES_SLICE_MAX_NUM = 5;
|
||||
const int32_t ABILITY_ON = 1;
|
||||
const int32_t ABILITY_INVALID = -1;
|
||||
const int32_t DES_MAX_LEN = 256;
|
||||
const int32_t ICON_MAX_LEN = 32 * 1024;
|
||||
const int32_t THUMB_MAX_LEN = 153 * 1024;
|
||||
|
||||
const int32_t DEVICE_UUID_LENGTH = 65;
|
||||
const int32_t GROUP_TYPE_IDENTICAL_ACCOUNT_GROUP = 1;
|
||||
const int32_t GROUP_TYPE_PEER_TO_PEER_GROUP = 256;
|
||||
|
||||
const int32_t GROUP_VISIBILITY_PUBLIC = -1;
|
||||
|
||||
const int32_t BUSINESS_FA_MIRGRATION = 0;
|
||||
const int32_t BUSINESS_RESOURCE_ACCESS = 1;
|
||||
|
||||
// Base64 Constants
|
||||
const int32_t BASE64_BYTE_LEN_3 = 3;
|
||||
const int32_t BASE64_BYTE_LEN_4 = 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* 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_DEVICE_MANAGER_ERRNO_H
|
||||
#define OHOS_DEVICE_MANAGER_ERRNO_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
enum {
|
||||
DEVICEMANAGER_FAILED = (-10000),
|
||||
DEVICEMANAGER_SERVICE_NOT_READY,
|
||||
DEVICEMANAGER_DEVICE_ALREADY_TRUSTED,
|
||||
DEVICEMANAGER_GET_TRUSTED_DEVICE_FAILED,
|
||||
DEVICEMANAGER_ALREADY_INIT,
|
||||
DEVICEMANAGER_INIT_FAILED,
|
||||
DEVICEMANAGER_MALLOC_ERROR,
|
||||
DEVICEMANAGER_LOCK_ERROR,
|
||||
DEVICEMANAGER_INVALID_PARAM,
|
||||
DEVICEMANAGER_INVALID_VALUE,
|
||||
DEVICEMANAGER_COPY_FAILED,
|
||||
DEVICEMANAGER_NULLPTR,
|
||||
DEVICEMANAGER_DISCOVERY_FAILED,
|
||||
DEVICEMANAGER_FLATTEN_OBJECT,
|
||||
DEVICEMANAGER_WRITE_FAILED,
|
||||
DEVICEMANAGER_IPC_FAILED,
|
||||
DEVICEMANAGER_IPC_TRANSACTION_FAILED,
|
||||
DEVICEMANAGER_IPC_NOT_REGISTER_FUNC,
|
||||
HICHAIN_GROUP_CREATE_FAILED,
|
||||
HICHAIN_MEMBER_ADD_FAILED,
|
||||
HICHAIN_CREATE_CHANNEL_FAILED,
|
||||
MSG_DECODE_PARA_FAILED,
|
||||
ENCRYPT_UTILS_INVALID_PARAM,
|
||||
ENCRYPT_UTILS_GCM_SETKEY_FAILED,
|
||||
ENCRYPT_UTILS_GCM_CRYPT_FAILED,
|
||||
ENCRYPT_UTILS_GCM_AUTH_DECRYPT_FAILED,
|
||||
ENCRYPT_UTILS_AES_GCM_ENCRYPT_FAILED,
|
||||
ENCRYPT_UTILS_AES_GCM_DECRYPT_FAILED,
|
||||
ERR_GEN_RANDOM_PINTOKEN_FAILED,
|
||||
PIN_CODE_CHECK_FAILED,
|
||||
PIN_TOKEN_CHECK_FAILED,
|
||||
DEVICEMANAGER_CREATE_SESSION_SERVER_FAILED,
|
||||
DEVICEMANAGER_OPEN_SESSION_FAILED,
|
||||
AUTH_PARA_INVALID,
|
||||
ENCODE_DATA_ERROR,
|
||||
DEVICEMANAGER_OK = 0
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_ERRNO_H
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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_DM_CONSTANTS_H
|
||||
#define OHOS_DM_CONSTANTS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager";
|
||||
const std::string DM_SESSION_NAME = "ohos.distributedhardware.devicemanager.resident";
|
||||
|
||||
const std::string DISCOVER_STATUS_KEY = "persist.distributed_hardware.device_manager.discover_status";
|
||||
const std::string DISCOVER_STATUS_ON = "1";
|
||||
const std::string DISCOVER_STATUS_OFF = "0";
|
||||
const std::string AUTH_LOAD_JSON_KEY = "devicemanager_auth_components";
|
||||
const std::string ADAPTER_LOAD_JSON_KEY = "devicemanager_adapter_components";
|
||||
const std::string AUTH_JSON_TYPE_KEY = "AUTHENTICATE";
|
||||
const std::string CPYPTO_JSON_TYPE_KEY = "CPYPTO";
|
||||
const std::string PROFILE_JSON_TYPE_KEY = "PROFILE";
|
||||
const std::string DECISION_JSON_TYPE_KEY = "DECISION";
|
||||
|
||||
const int32_t DM_NAPI_SUBSCRIBE_CAPABILITY_DDMP = 0;
|
||||
const int32_t DM_NAPI_SUBSCRIBE_CAPABILITY_OSD = 1;
|
||||
const int32_t MIN_PIN_TOKEN = 10000000;
|
||||
const int32_t MAX_PIN_TOKEN = 90000000;
|
||||
const int32_t MIN_PIN_CODE = 100000;
|
||||
const int32_t MAX_PIN_CODE = 999999;
|
||||
const int32_t DISCOVER_STATUS_LEN = 20;
|
||||
const int32_t COMMON_CALLBACK_MAX_SIZE = 200;
|
||||
|
||||
enum {
|
||||
DM_OK = 0,
|
||||
DM_FAILED = 1000,
|
||||
DM_TIME_OUT,
|
||||
DM_NOT_INIT,
|
||||
DM_INT_MULTIPLE,
|
||||
DM_INIT_FAILED,
|
||||
DM_UNINIT_FAILED,
|
||||
DM_POINT_NULL,
|
||||
DM_INPUT_PARA_EMPTY,
|
||||
DM_NOT_SYSTEM_APP,
|
||||
DM_INVALID_VALUE,
|
||||
DM_FLATTEN_OBJECT,
|
||||
DM_MALLOC_ERROR,
|
||||
DM_COPY_FAILED,
|
||||
DM_WRITE_FAILED,
|
||||
DM_DISCOVERY_FAILED,
|
||||
DM_MAKE_SHARED_FAIL,
|
||||
DM_SERVICE_NOT_READY,
|
||||
DM_DEVICE_ALREADY_TRUSTED,
|
||||
DM_IPC_FAILED = 2000,
|
||||
DM_IPC_TRANSACTION_FAILED,
|
||||
DM_IPC_FLATTEN_OBJECT,
|
||||
DM_IPC_COPY_FAILED,
|
||||
DM_IPC_SEND_REQUEST_FAILED,
|
||||
DM_IPC_NOT_REGISTER_FUNC,
|
||||
DM_IPC_RESPOND_ERROR,
|
||||
DM_DISCOVERY_REPEATED,
|
||||
DM_AUTH_NOT_SUPPORT,
|
||||
DM_AUTH_BUSINESS_BUSY,
|
||||
DM_AUTH_INPUT_FAILED,
|
||||
DM_AUTH_STATE_FAILED,
|
||||
DM_AUTH_DEVICE_AUTHED,
|
||||
DM_AUTH_OPEN_SESSION_FAILED,
|
||||
DM_AUTH_PEER_REJECT,
|
||||
DM_AUTH_NOT_AUTH,
|
||||
DM_SOFTBUS_FAILED = 3000,
|
||||
DM_SOFTBUS_CREATE_SESSION_SERVER_FAILED,
|
||||
DM_HICHAIN_FAILED = 4000,
|
||||
DM_HICHAIN_GROUP_CREATE_FAILED,
|
||||
DM_HICHAIN_MEMBER_ADD_FAILED,
|
||||
DM_HICHAIN_CREATE_CHANNEL_FAILED,
|
||||
};
|
||||
const std::string TARGET_PKG_NAME_KEY = "targetPkgName";
|
||||
const std::string HOST_PKG_NAME_KEY = "hostPackageName";
|
||||
const std::string TAG_REQUESTER = "REQUESTER";
|
||||
const std::string TAG_TOKEN = "TOKEN";
|
||||
const std::string TAG_HOST = "HOST";
|
||||
const std::string TAG_TARGET = "TARGET";
|
||||
const std::string TAG_VISIBILITY = "VISIBILITY";
|
||||
const std::string TAG_GROUPIDS = "GROUPIDLIST";
|
||||
const std::string TAG_REPLY = "REPLY";
|
||||
const std::string TAG_NET_ID = "NETID";
|
||||
const std::string TAG_GROUP_ID = "groupId";
|
||||
const std::string TAG_GROUP_NAME = "GROUPNAME";
|
||||
const std::string TAG_REQUEST_ID = "REQUESTID";
|
||||
const std::string TAG_DEVICE_ID = "DEVICEID";
|
||||
const std::string TAG_LOCAL_DEVICE_ID = "LOCALDEVICEID";
|
||||
const std::string TAG_DEVICE_TYPE = "DEVICETYPE";
|
||||
const std::string TAG_APP_NAME = "APPNAME";
|
||||
const std::string TAG_APP_DESCRIPTION = "APPDESC";
|
||||
const std::string TAG_APP_ICON = "APPICON";
|
||||
const std::string TAG_APP_THUMBNAIL = "APPTHUM";
|
||||
const std::string TAG_INDEX = "INDEX";
|
||||
const std::string TAG_SLICE_NUM = "SLICE";
|
||||
const std::string TAG_THUMBNAIL_SIZE = "THUMSIZE";
|
||||
const std::string TAG_AUTH_TYPE = "AUTHTYPE";
|
||||
const std::string TAG_CRYPTO_SUPPORT = "CRYPTOSUPPORT";
|
||||
const std::string TAG_CRYPTO_NAME = "CRYPTONAME";
|
||||
const std::string TAG_CRYPTO_VERSION = "CRYPTOVERSION";
|
||||
const std::string TAG_VER = "ITF_VER";
|
||||
const std::string TAG_TYPE = "MSG_TYPE";
|
||||
const std::string DM_ITF_VER_1_0 = "1.0";
|
||||
const std::string DM_ITF_VER = "1.1";
|
||||
const std::string TAG = "DM_MSG_CODEC";
|
||||
const std::string APP_NAME_KEY = "appName";
|
||||
const std::string APP_DESCRIPTION_KEY = "appDescription";
|
||||
const std::string APP_ICON_KEY = "appIcon";
|
||||
const std::string APP_THUMBNAIL_KEY = "appThumbnailKey";
|
||||
const std::string APP_THUMBNAIL_LEN = "appThumbnailLen";
|
||||
const std::string APP_THUMBNAIL = "appThumbnail";
|
||||
const std::string CANCEL_DISPLAY_KEY = "cancelPinCodeDisplay";
|
||||
const int32_t MSG_MAX_SIZE = 45 * 1024;
|
||||
const int32_t AUTH_REPLY_ACCEPT = 0;
|
||||
const int32_t ENCRYPT_TAG_LEN = 32;
|
||||
|
||||
// pin
|
||||
const int32_t DISPLAY_OWNER_SYSTEM = 0;
|
||||
const int32_t DISPLAY_OWNER_OTHER = 1;
|
||||
const int32_t BUSINESS_FA_MIRGRATION = 0;
|
||||
const int32_t BUSINESS_RESOURCE_ACCESS = 1;
|
||||
|
||||
// json
|
||||
const std::string AUTH_TYPE = "authType";
|
||||
const std::string TOKEN = "token";
|
||||
const std::string PIN_TOKEN = "pinToken";
|
||||
const std::string PIN_CODE_KEY = "pinCode";
|
||||
const int32_t AUTH_TYPE_PIN = 1;
|
||||
const int32_t AUTH_TYPE_SCAN = 2;
|
||||
const int32_t AUTH_TYPE_TOUCH = 3;
|
||||
const int32_t DEFAULT_PIN_CODE = 0;
|
||||
const int32_t DEFAULT_PIN_TOKEN = 0;
|
||||
|
||||
// Softbus
|
||||
const int32_t SOFTBUS_CHECK_INTERVAL = 100000; // 100ms
|
||||
const uint32_t SOFTBUS_SUBSCRIBE_ID_PREFIX_LEN = 16;
|
||||
const int32_t SOFTBUS_SUBSCRIBE_ID_MASK = 0x0000FFFF;
|
||||
const int32_t SOFTBUS_DISCOVER_DEVICE_INFO_MAX_SIZE = 20;
|
||||
const int32_t AUTH_SESSION_SIDE_SERVER = 0;
|
||||
const int32_t AUTH_SESSION_SIDE_CLIENT = 1;
|
||||
const static char *DM_CAPABILITY_OSD = "osdCapability";
|
||||
|
||||
// HiChain
|
||||
const int32_t DEVICE_UUID_LENGTH = 65;
|
||||
const int32_t GROUP_TYPE_IDENTICAL_ACCOUNT_GROUP = 1;
|
||||
const int32_t GROUP_TYPE_PEER_TO_PEER_GROUP = 256;
|
||||
const int32_t GROUP_VISIBILITY_PUBLIC = -1;
|
||||
const int64_t MIN_REQUEST_ID = 1000000000;
|
||||
const int64_t MAX_REQUEST_ID = 9999999999;
|
||||
const int32_t FIELD_EXPIRE_TIME_VALUE = 7;
|
||||
const int32_t GROUP_VISIBILITY_IS_PUBLIC = -1;
|
||||
const int32_t GROUP_VISIBILITY_IS_PRIVATE = 0;
|
||||
const std::string DEVICE_ID = "DEVICE_ID";
|
||||
const std::string WIFI_IP = "WIFI_IP";
|
||||
const std::string WIFI_PORT = "WIFI_PORT";
|
||||
const std::string BR_MAC = "BR_MAC";
|
||||
const std::string BLE_MAC = "BLE_MAC";
|
||||
const std::string ETH_IP = "ETH_IP";
|
||||
const std::string ETH_PORT = "ETH_PORT";
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -21,35 +21,39 @@ namespace DistributedHardware {
|
||||
#define DEVICE_MANAGER_SERVICE_NAME "dev_mgr_svc"
|
||||
#define MAX_DM_IPC_LEN 2048
|
||||
|
||||
#define DECLARE_IPC_MODEL(className) \
|
||||
public: \
|
||||
className() = default; \
|
||||
virtual ~className() = default; \
|
||||
public: \
|
||||
className(const className&) = delete; \
|
||||
className& operator= (const className&) = delete; \
|
||||
className(className&&) = delete; \
|
||||
className& operator= (className&&) = delete \
|
||||
#define DECLARE_IPC_MODEL(className) \
|
||||
public: \
|
||||
className() = default; \
|
||||
virtual ~className() = default; \
|
||||
\
|
||||
public: \
|
||||
className(const className &) = delete; \
|
||||
className &operator=(const className &) = delete; \
|
||||
className(className &&) = delete; \
|
||||
className &operator=(className &&) = delete
|
||||
|
||||
#define DECLARE_IPC_INTERFACE(className) \
|
||||
DECLARE_IPC_MODEL(className)
|
||||
#define DECLARE_IPC_INTERFACE(className) DECLARE_IPC_MODEL(className)
|
||||
|
||||
enum IpcCmdID {
|
||||
REGISTER_DEVICE_MANAGER_LISTENER = 0,
|
||||
UNREGISTER_DEVICE_MANAGER_LISTENER,
|
||||
GET_TRUST_DEVICE_LIST,
|
||||
GET_LOCAL_DEVICE_INFO,
|
||||
GET_UDID_BY_NETWORK,
|
||||
GET_UUID_BY_NETWORK,
|
||||
START_DEVICE_DISCOVER,
|
||||
STOP_DEVICE_DISCOVER,
|
||||
AUTHENTICATE_DEVICE,
|
||||
CHECK_AUTHENTICATION,
|
||||
UNAUTHENTICATE_DEVICE,
|
||||
VERIFY_AUTHENTICATION,
|
||||
SERVER_DEVICE_STATE_NOTIFY,
|
||||
SERVER_DEVICE_FOUND,
|
||||
SERVER_DISCOVER_FINISH,
|
||||
SERVER_AUTH_RESULT,
|
||||
SERVER_CHECK_AUTH_RESULT,
|
||||
SERVER_GET_AUTHENTCATION_INFO,
|
||||
SERVER_USER_AUTHORIZATION_OPERATION,
|
||||
SERVER_DEVICEMANAGER_FA_NOTIFY,
|
||||
SERVER_VERIFY_AUTH_RESULT,
|
||||
SERVER_GET_DMFA_INFO,
|
||||
SERVER_USER_AUTH_OPERATION,
|
||||
SERVER_DEVICE_FA_NOTIFY,
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,20 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
#ifndef OHOS_DM_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
#define OHOS_DM_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_app_image_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcAuthenticateDeviceReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcAuthenticateDeviceReq);
|
||||
DECLARE_IPC_MODEL(IpcAuthenticateDeviceReq);
|
||||
|
||||
public:
|
||||
const DmDeviceInfo& GetDeviceInfo() const
|
||||
const DmDeviceInfo &GetDeviceInfo() const
|
||||
{
|
||||
return deviceInfo_;
|
||||
}
|
||||
@@ -36,30 +35,31 @@ public:
|
||||
deviceInfo_ = deviceInfo;
|
||||
}
|
||||
|
||||
const DmAppImageInfo& GetAppImageInfo() const
|
||||
int32_t GetAuthType()
|
||||
{
|
||||
return appImageInfo_;
|
||||
return authType_;
|
||||
}
|
||||
|
||||
void SetAppImageInfo(const DmAppImageInfo &appImageInfo)
|
||||
void SetAuthType(int32_t authType)
|
||||
{
|
||||
appImageInfo_ = appImageInfo;
|
||||
authType_ = authType;
|
||||
}
|
||||
|
||||
const std::string& GetExtra() const
|
||||
const std::string &GetExtra() const
|
||||
{
|
||||
return extra_;
|
||||
}
|
||||
|
||||
void SetExtra(std::string &extra)
|
||||
void SetExtra(const std::string &extra)
|
||||
{
|
||||
extra_ = extra;
|
||||
}
|
||||
|
||||
private:
|
||||
DmDeviceInfo deviceInfo_;
|
||||
DmAppImageInfo appImageInfo_;
|
||||
int32_t authType_;
|
||||
std::string extra_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
#endif // OHOS_DM_IPC_AUTHENTICATE_DEVICE_REQ_H
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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_DEVICE_MANAGER_IPC_GET_DM_FA_PARAM_RSP_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_DM_FA_PARAM_RSP_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetDmFaParamRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetDmFaParamRsp);
|
||||
|
||||
public:
|
||||
const DmAuthParam GetDmAuthParam() const
|
||||
{
|
||||
return dmFaParam_;
|
||||
}
|
||||
|
||||
void SetDmAuthParam(const DmAuthParam &dmFaParam)
|
||||
{
|
||||
dmFaParam_ = dmFaParam;
|
||||
}
|
||||
|
||||
private:
|
||||
DmAuthParam dmFaParam_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_DM_FA_PARAM_RSP_H
|
||||
+13
-12
@@ -13,29 +13,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_GET_AUTH_PARAM_RSP_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_AUTH_PARAM_RSP_H
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_REQ_H
|
||||
|
||||
#include "ipc_rsp.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetAuthParamRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetAuthParamRsp);
|
||||
class IpcGetInfoByNetWorkReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcGetInfoByNetWorkReq);
|
||||
|
||||
public:
|
||||
const DmAuthParam& GetAuthParam() const
|
||||
const std::string GetNetWorkId() const
|
||||
{
|
||||
return authParam_;
|
||||
return netWorkId_;
|
||||
}
|
||||
|
||||
void SetAuthParam(DmAuthParam &authParam)
|
||||
void SetNetWorkId(const std::string &netWorkId)
|
||||
{
|
||||
authParam_ = authParam;
|
||||
netWorkId_ = netWorkId;
|
||||
}
|
||||
|
||||
private:
|
||||
DmAuthParam authParam_;
|
||||
std::string netWorkId_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_AUTH_PARAM_RSP_H
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_REQ_H
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_RSP_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_RSP_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ipc_rsp.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetInfoByNetWorkRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetInfoByNetWorkRsp);
|
||||
|
||||
public:
|
||||
const std::string GetUdid() const
|
||||
{
|
||||
return udid_;
|
||||
}
|
||||
|
||||
void SetUdid(const std::string &udid)
|
||||
{
|
||||
udid_ = udid;
|
||||
}
|
||||
const std::string GetUuid() const
|
||||
{
|
||||
return uuid_;
|
||||
}
|
||||
|
||||
void SetUuid(const std::string &uuid)
|
||||
{
|
||||
uuid_ = uuid;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string udid_;
|
||||
std::string uuid_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_INFO_BY_NETWORK_RSP_H
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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_DM_IPC_GET_LOCAL_DEVICE_INFO_RSP_H
|
||||
#define OHOS_DM_IPC_GET_LOCAL_DEVICE_INFO_RSP_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetLocalDeviceInfoRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetLocalDeviceInfoRsp);
|
||||
|
||||
public:
|
||||
const DmDeviceInfo &GetLocalDeviceInfo() const
|
||||
{
|
||||
return localDeviceInfo_;
|
||||
}
|
||||
|
||||
void SetLocalDeviceInfo(const DmDeviceInfo &localDeviceInfo)
|
||||
{
|
||||
localDeviceInfo_ = localDeviceInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
DmDeviceInfo localDeviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_IPC_GET_LOCAL_DEVICE_INFO_RSP_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,28 +13,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
#ifndef OHOS_DM_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
#define OHOS_DM_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetTrustdeviceReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcGetTrustdeviceReq);
|
||||
class IpcGetTrustDeviceReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcGetTrustDeviceReq);
|
||||
|
||||
public:
|
||||
const std::string& GetExtra() const
|
||||
const std::string &GetExtra() const
|
||||
{
|
||||
return extra_;
|
||||
}
|
||||
|
||||
void SetExtra(std::string &extra)
|
||||
void SetExtra(const std::string &extra)
|
||||
{
|
||||
extra_ = extra;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string extra_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
#endif // OHOS_DM_IPC_GET_TRUST_DEVICE_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,32 +13,33 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_GET_TRUSTDEVICE_RSP_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_TRUSTDEVICE_RSP_H
|
||||
#ifndef OHOS_DM_IPC_GET_TRUST_DEVICE_RSP_H
|
||||
#define OHOS_DM_IPC_GET_TRUST_DEVICE_RSP_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "dm_device_info.h"
|
||||
|
||||
#include "ipc_rsp.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetTrustdeviceRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetTrustdeviceRsp);
|
||||
class IpcGetTrustDeviceRsp : public IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcGetTrustDeviceRsp);
|
||||
|
||||
public:
|
||||
std::vector<DmDeviceInfo> GetDeviceVec() const
|
||||
{
|
||||
return deviceVec_;
|
||||
}
|
||||
|
||||
void SetDeviceVec(std::vector<DmDeviceInfo>& deviceVec)
|
||||
void SetDeviceVec(std::vector<DmDeviceInfo> &deviceVec)
|
||||
{
|
||||
deviceVec_ = deviceVec;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<DmDeviceInfo> deviceVec_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_GET_TRUSTDEVICE_RSP_H
|
||||
#endif // OHOS_DM_IPC_GET_TRUST_DEVICE_RSP_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
#ifndef OHOS_DM_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
#define OHOS_DM_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -23,26 +23,27 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyAuthResultReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyAuthResultReq);
|
||||
DECLARE_IPC_MODEL(IpcNotifyAuthResultReq);
|
||||
|
||||
public:
|
||||
std::string GetDeviceId() const
|
||||
{
|
||||
return deviceId_;
|
||||
}
|
||||
|
||||
void SetDeviceId(std::string& deviceId)
|
||||
void SetDeviceId(const std::string &deviceId)
|
||||
{
|
||||
deviceId_ = deviceId;
|
||||
}
|
||||
|
||||
int32_t GetPinToken() const
|
||||
std::string GetPinToken() const
|
||||
{
|
||||
return pinToken_;
|
||||
return token_;
|
||||
}
|
||||
|
||||
void SetPinToken(int32_t pinToken)
|
||||
void SetToken(const std::string &token)
|
||||
{
|
||||
pinToken_ = pinToken;
|
||||
token_ = token;
|
||||
}
|
||||
|
||||
int32_t GetStatus() const
|
||||
@@ -64,12 +65,13 @@ public:
|
||||
{
|
||||
reason_ = reason;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string deviceId_;
|
||||
int32_t pinToken_ {0};
|
||||
int32_t status_ {0};
|
||||
int32_t reason_ {0};
|
||||
std::string token_;
|
||||
int32_t status_ { 0 };
|
||||
int32_t reason_ { 0 };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
#endif // OHOS_DM_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,24 +13,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
#ifndef OHOS_DM_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
#define OHOS_DM_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyDeviceFoundReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyDeviceFoundReq);
|
||||
DECLARE_IPC_MODEL(IpcNotifyDeviceFoundReq);
|
||||
|
||||
public:
|
||||
const DmDeviceInfo& GetDeviceInfo() const
|
||||
const DmDeviceInfo &GetDeviceInfo() const
|
||||
{
|
||||
return dmDeviceInfo_;
|
||||
}
|
||||
|
||||
void SetDeviceInfo(DmDeviceInfo& dmDeviceInfo)
|
||||
void SetDeviceInfo(const DmDeviceInfo &dmDeviceInfo)
|
||||
{
|
||||
dmDeviceInfo_ = dmDeviceInfo;
|
||||
}
|
||||
@@ -44,10 +44,11 @@ public:
|
||||
{
|
||||
subscribeId_ = subscribeId;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t subscribeId_ {0};
|
||||
uint16_t subscribeId_ { 0 };
|
||||
DmDeviceInfo dmDeviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
#endif // OHOS_DM_IPC_NOTIFY_DEVICE_FOUND_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,17 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
#ifndef OHOS_DM_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
#define OHOS_DM_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyDeviceStateReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyDeviceStateReq);
|
||||
DECLARE_IPC_MODEL(IpcNotifyDeviceStateReq);
|
||||
|
||||
public:
|
||||
int32_t GetDeviceState() const
|
||||
{
|
||||
@@ -35,19 +35,20 @@ public:
|
||||
deviceState_ = deviceState;
|
||||
}
|
||||
|
||||
const DmDeviceInfo& GetDeviceInfo() const
|
||||
const DmDeviceInfo &GetDeviceInfo() const
|
||||
{
|
||||
return dmDeviceInfo_;
|
||||
}
|
||||
|
||||
void SetDeviceInfo(DmDeviceInfo& dmDeviceInfo)
|
||||
void SetDeviceInfo(const DmDeviceInfo &dmDeviceInfo)
|
||||
{
|
||||
dmDeviceInfo_ = dmDeviceInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t deviceState_ {0};
|
||||
int32_t deviceState_ { 0 };
|
||||
DmDeviceInfo dmDeviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
#endif // OHOS_DM_IPC_NOTIFY_DEVICE_STATE_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,17 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
|
||||
#include <cstdint>
|
||||
#ifndef OHOS_DM_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
#define OHOS_DM_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyDiscoverResultReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyDiscoverResultReq);
|
||||
DECLARE_IPC_MODEL(IpcNotifyDiscoverResultReq);
|
||||
|
||||
public:
|
||||
uint16_t GetSubscribeId() const
|
||||
{
|
||||
@@ -44,10 +43,11 @@ public:
|
||||
{
|
||||
result_ = result;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t subscribeId_ {0};
|
||||
int32_t result_ {0};
|
||||
uint16_t subscribeId_ { 0 };
|
||||
int32_t result_ { 0 };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
#endif // OHOS_DM_IPC_NOTIFY_DISCOVER_RESULT_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -16,27 +16,27 @@
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_DMFA_RESULT_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_DMFA_RESULT_REQ_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyDMFAResultReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyDMFAResultReq);
|
||||
DECLARE_IPC_MODEL(IpcNotifyDMFAResultReq);
|
||||
|
||||
public:
|
||||
std::string GetJsonParam() const
|
||||
{
|
||||
return JsonParam_;
|
||||
}
|
||||
|
||||
void SetJsonParam(std::string& JsonParam)
|
||||
void SetJsonParam(const std::string &JsonParam)
|
||||
{
|
||||
JsonParam_ = JsonParam;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string JsonParam_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_AUTH_RESULT_REQ_H
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_DMFA_RESULT_REQ_H
|
||||
|
||||
+11
-9
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
#ifndef OHOS_DM_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
#define OHOS_DM_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -22,15 +22,16 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcNotifyCheckAuthResultReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyCheckAuthResultReq);
|
||||
class IpcNotifyVerifyAuthResultReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcNotifyVerifyAuthResultReq);
|
||||
|
||||
public:
|
||||
std::string GetDeviceId() const
|
||||
{
|
||||
return deviceId_;
|
||||
}
|
||||
|
||||
void SetDeviceId(std::string& deviceId)
|
||||
void SetDeviceId(const std::string &deviceId)
|
||||
{
|
||||
deviceId_ = deviceId;
|
||||
}
|
||||
@@ -54,11 +55,12 @@ public:
|
||||
{
|
||||
flag_ = flag;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string deviceId_;
|
||||
int32_t result_ {0};
|
||||
int32_t flag_ {0};
|
||||
int32_t result_ { 0 };
|
||||
int32_t flag_ { 0 };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
#endif // OHOS_DM_IPC_NOTIFY_CHECK_AUTH_RESULT_REQ_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_REGISTER_LISTENER_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_REGISTER_LISTENER_REQ_H
|
||||
#ifndef OHOS_DM_IPC_REGISTER_LISTENER_REQ_H
|
||||
#define OHOS_DM_IPC_REGISTER_LISTENER_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcRegisterListenerReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcRegisterListenerReq);
|
||||
DECLARE_IPC_MODEL(IpcRegisterListenerReq);
|
||||
|
||||
public:
|
||||
#ifdef LITE_DEVICE
|
||||
SvcIdentity GetSvcIdentity() const
|
||||
@@ -59,4 +60,4 @@ private:
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_REGISTER_LISTENER_REQ_H
|
||||
#endif // OHOS_DM_IPC_REGISTER_LISTENER_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_REQ_H
|
||||
#ifndef OHOS_DM_IPC_REQ_H
|
||||
#define OHOS_DM_IPC_REQ_H
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -23,20 +23,22 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcReq);
|
||||
DECLARE_IPC_MODEL(IpcReq);
|
||||
|
||||
public:
|
||||
const std::string& GetPkgName() const
|
||||
const std::string &GetPkgName() const
|
||||
{
|
||||
return pkgName_;
|
||||
}
|
||||
|
||||
void SetPkgName(std::string &pkgName)
|
||||
void SetPkgName(const std::string &pkgName)
|
||||
{
|
||||
pkgName_ = pkgName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string pkgName_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_REQ_H
|
||||
#endif // OHOS_DM_IPC_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_RSP_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_RSP_H
|
||||
#ifndef OHOS_DM_IPC_RSP_H
|
||||
#define OHOS_DM_IPC_RSP_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcRsp {
|
||||
DECLARE_IPC_MODEL(IpcRsp);
|
||||
DECLARE_IPC_MODEL(IpcRsp);
|
||||
|
||||
public:
|
||||
int32_t GetErrCode() const
|
||||
{
|
||||
@@ -34,9 +35,10 @@ public:
|
||||
{
|
||||
errCode_ = errCode;
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t errCode_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_RSP_H
|
||||
#endif // OHOS_DM_IPC_RSP_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,13 +15,15 @@
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_GET_USER_OPERATION_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_GET_USER_OPERATION_REQ_H
|
||||
#include "ipc_req.h"
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcGetOperationReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcGetOperationReq);
|
||||
DECLARE_IPC_MODEL(IpcGetOperationReq);
|
||||
|
||||
public:
|
||||
int32_t GetOperation() const
|
||||
{
|
||||
@@ -34,7 +36,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t action_ {0};
|
||||
int32_t action_ { 0 };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,30 +13,42 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_START_DISCOVERY_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_START_DISCOVERY_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
#ifndef OHOS_DM_IPC_START_DISCOVERY_REQ_H
|
||||
#define OHOS_DM_IPC_START_DISCOVERY_REQ_H
|
||||
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcStartDiscoveryReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcStartDiscoveryReq);
|
||||
DECLARE_IPC_MODEL(IpcStartDiscoveryReq);
|
||||
|
||||
public:
|
||||
const DmSubscribeInfo& GetSubscribeInfo() const
|
||||
const DmSubscribeInfo &GetSubscribeInfo() const
|
||||
{
|
||||
return subscribeInfo_;
|
||||
}
|
||||
|
||||
void SetSubscribeInfo(DmSubscribeInfo &subscribeInfo)
|
||||
void SetSubscribeInfo(const DmSubscribeInfo &subscribeInfo)
|
||||
{
|
||||
subscribeInfo_ = subscribeInfo;
|
||||
}
|
||||
|
||||
const std::string &GetExtra() const
|
||||
{
|
||||
return extra_;
|
||||
}
|
||||
|
||||
void SetExtra(const std::string &extra)
|
||||
{
|
||||
extra_ = extra;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string extra_;
|
||||
DmSubscribeInfo subscribeInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_START_DISCOVERY_REQ_H
|
||||
#endif // OHOS_DM_IPC_START_DISCOVERY_REQ_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_STOP_DISCOVERY_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_STOP_DISCOVERY_REQ_H
|
||||
#ifndef OHOS_DM_IPC_STOP_DISCOVERY_REQ_H
|
||||
#define OHOS_DM_IPC_STOP_DISCOVERY_REQ_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcStopDiscoveryReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcStopDiscoveryReq);
|
||||
DECLARE_IPC_MODEL(IpcStopDiscoveryReq);
|
||||
|
||||
public:
|
||||
uint16_t GetSubscribeId() const
|
||||
{
|
||||
@@ -34,9 +35,10 @@ public:
|
||||
{
|
||||
subscribeId_ = subscribeId;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t subscribeId_ {0};
|
||||
uint16_t subscribeId_ { 0 };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_STOP_DISCOVERY_REQ_H
|
||||
#endif // OHOS_DM_IPC_STOP_DISCOVERY_REQ_H
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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_DM_IPC_UNAUTHENTICATE_DEVICE_REQ_H
|
||||
#define OHOS_DM_IPC_UNAUTHENTICATE_DEVICE_REQ_H
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcUnAuthenticateDeviceReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcUnAuthenticateDeviceReq);
|
||||
|
||||
public:
|
||||
const DmDeviceInfo &GetDeviceInfo() const
|
||||
{
|
||||
return deviceInfo_;
|
||||
}
|
||||
|
||||
void SetDeviceInfo(const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
deviceInfo_ = deviceInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
DmDeviceInfo deviceInfo_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_IPC_UNAUTHENTICATE_DEVICE_REQ_H
|
||||
+10
-8
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,28 +13,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CHECK_AUTHENTICATE_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CHECK_AUTHENTICATE_REQ_H
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_VERIFY_AUTHENTICATE_REQ_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_VERIFY_AUTHENTICATE_REQ_H
|
||||
|
||||
#include "ipc_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcCheckAuthenticateReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcCheckAuthenticateReq);
|
||||
class IpcVerifyAuthenticateReq : public IpcReq {
|
||||
DECLARE_IPC_MODEL(IpcVerifyAuthenticateReq);
|
||||
|
||||
public:
|
||||
const std::string& GetAuthPara() const
|
||||
const std::string &GetAuthPara() const
|
||||
{
|
||||
return authPara_;
|
||||
}
|
||||
|
||||
void SetAuthPara(std::string &authPara)
|
||||
void SetAuthPara(const std::string &authPara)
|
||||
{
|
||||
authPara_ = authPara;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string authPara_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CHECK_AUTHENTICATE_REQ_H
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_VERIFY_AUTHENTICATE_REQ_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,34 +13,34 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_SINGLE_INSTANCE_H
|
||||
#define OHOS_DEVICE_MANAGER_SINGLE_INSTANCE_H
|
||||
#ifndef OHOS_DM_SINGLE_INSTANCE_H
|
||||
#define OHOS_DM_SINGLE_INSTANCE_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
#define DECLARE_SINGLE_INSTANCE_BASE(className) \
|
||||
public: \
|
||||
static className & GetInstance(); \
|
||||
public: \
|
||||
static className &GetInstance(); \
|
||||
\
|
||||
private: \
|
||||
className(const className&) = delete; \
|
||||
className& operator= (const className&) = delete; \
|
||||
className(className&&) = delete; \
|
||||
className& operator= (className&&) = delete; \
|
||||
|
||||
className(const className &) = delete; \
|
||||
className &operator=(const className &) = delete; \
|
||||
className(className &&) = delete; \
|
||||
className &operator=(className &&) = delete;
|
||||
|
||||
#define DECLARE_SINGLE_INSTANCE(className) \
|
||||
DECLARE_SINGLE_INSTANCE_BASE(className) \
|
||||
private: \
|
||||
className() = default; \
|
||||
~className() = default; \
|
||||
~className() = default;
|
||||
|
||||
#define IMPLEMENT_SINGLE_INSTANCE(className) \
|
||||
className & className::GetInstance() \
|
||||
{ \
|
||||
static auto instance = new className(); \
|
||||
return *instance; \
|
||||
}
|
||||
#define IMPLEMENT_SINGLE_INSTANCE(className) \
|
||||
className &className::GetInstance() \
|
||||
{ \
|
||||
static auto instance = new className(); \
|
||||
return *instance; \
|
||||
}
|
||||
}; // namespace DistributedHardware
|
||||
}; // namespace OHOS
|
||||
|
||||
#endif // OHOS_DEVICE_MANAGER_SINGLE_INSTANCE_H
|
||||
#endif // OHOS_DM_SINGLE_INSTANCE_H
|
||||
+8
-4
@@ -11,14 +11,18 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#------------------------device manager------------------------------#
|
||||
devicemanager_path = "//foundation/distributedhardware/devicemanager"
|
||||
|
||||
common_path = "${devicemanager_path}/common"
|
||||
|
||||
utils_path = "${devicemanager_path}/utils"
|
||||
|
||||
services_path = "${devicemanager_path}/services"
|
||||
|
||||
services_path = "${devicemanager_path}/services/devicemanagerservice"
|
||||
innerkits_path = "${devicemanager_path}/interfaces/inner_kits"
|
||||
ext_path = "${devicemanager_path}/ext"
|
||||
|
||||
#--------------------------softbus----------------------------------#
|
||||
|
||||
#---------------------------hichan----------------------------------#
|
||||
|
||||
#----------------------compilation options--------------------------#
|
||||
dm_ldflags = [ "-lpthread" ]
|
||||
|
||||
+56
-56
@@ -1,57 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
apply plugin: 'com.huawei.ohos.app'
|
||||
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url 'https://mirrors.huaweicloud.com/repository/maven/'
|
||||
}
|
||||
maven {
|
||||
url 'https://developer.huawei.com/repo/'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.huawei.ohos:hap:2.4.4.3-RC'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url 'https://mirrors.huaweicloud.com/repository/maven/'
|
||||
}
|
||||
maven {
|
||||
url 'https://developer.huawei.com/repo/'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
apply plugin: 'com.huawei.ohos.app'
|
||||
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url 'https://mirrors.huaweicloud.com/repository/maven/'
|
||||
}
|
||||
maven {
|
||||
url 'https://developer.huawei.com/repo/'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.huawei.ohos:hap:2.4.4.3-RC'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://repo.ark.tools.huawei.com/artifactory/maven-public/'
|
||||
}
|
||||
maven {
|
||||
url 'https://mirrors.huaweicloud.com/repository/maven/'
|
||||
}
|
||||
maven {
|
||||
url 'https://developer.huawei.com/repo/'
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
+42
-42
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.huawei.ohos.hap'
|
||||
apply plugin: 'com.huawei.ohos.decctest'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
testImplementation 'junit:junit:4.13'
|
||||
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
|
||||
}
|
||||
decc {
|
||||
supportType = ['html', 'xml']
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.huawei.ohos.hap'
|
||||
apply plugin: 'com.huawei.ohos.decctest'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion 6
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 6
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
testImplementation 'junit:junit:4.13'
|
||||
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
|
||||
}
|
||||
decc {
|
||||
supportType = ['html', 'xml']
|
||||
}
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.devicemanagerui",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.devicemanagerui",
|
||||
"name": ".MyApplication",
|
||||
"mainAbility": "com.ohos.devicemanagerui.MainAbility",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"tv",
|
||||
"wearable"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"visible": true,
|
||||
"name": "com.ohos.devicemanagerui.MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:mainability_description",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "standard"
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.devicemanagerui",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.devicemanagerui",
|
||||
"name": ".MyApplication",
|
||||
"mainAbility": "com.ohos.devicemanagerui.MainAbility",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"tv",
|
||||
"wearable"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"visible": true,
|
||||
"name": "com.ohos.devicemanagerui.MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:mainability_description",
|
||||
"label": "$string:entry_MainAbility",
|
||||
"type": "page",
|
||||
"launchType": "standard"
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "entry_MainAbility"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Empty Ability"
|
||||
}
|
||||
]
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "entry_MainAbility",
|
||||
"value": "entry_MainAbility"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Empty Ability"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
include ':entry'
|
||||
include ':entry'
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# 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.
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
} else {
|
||||
import("//build/ohos.gni")
|
||||
}
|
||||
|
||||
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
} else {
|
||||
ohos_shared_library("devicemanagerext_pin_auth") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${services_path}/include/adapter",
|
||||
"${ext_path}/pin_auth/include/ability",
|
||||
"${services_path}/include/authentication",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/ability/standard/dm_ability_manager.cpp",
|
||||
"src/pin_auth.cpp",
|
||||
"src/pin_auth_ui.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/want:want",
|
||||
"//foundation/aafwk/standard/services/abilitymgr:abilityms",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"appexecfwk_standard:appexecfwk_base",
|
||||
"appexecfwk_standard:appexecfwk_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"startup_l2:syspara",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"devicemanagerext\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
subsystem_name = "distributedhardware"
|
||||
|
||||
part_name = "device_manager_base"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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_DM_ABILITY_MANAGER_H
|
||||
#define OHOS_DM_ABILITY_MANAGER_H
|
||||
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
enum AbilityRole { ABILITY_ROLE_PASSIVE = 0, ABILITY_ROLE_INITIATIVE = 1, ABILITY_ROLE_UNKNOWN = 2 };
|
||||
|
||||
enum AbilityStatus { ABILITY_STATUS_FAILED = 0, ABILITY_STATUS_SUCCESS = 1, ABILITY_STATUS_START = 2 };
|
||||
|
||||
enum FaAction {
|
||||
USER_OPERATION_TYPE_ALLOW_AUTH = 0,
|
||||
USER_OPERATION_TYPE_CANCEL_AUTH = 1,
|
||||
USER_OPERATION_TYPE_AUTH_CONFIRM_TIMEOUT = 2,
|
||||
USER_OPERATION_TYPE_CANCEL_PINCODE_DISPLAY = 3,
|
||||
USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT = 4
|
||||
};
|
||||
|
||||
class DmAbilityManager {
|
||||
public:
|
||||
AbilityRole GetAbilityRole();
|
||||
AbilityStatus StartAbility(AbilityRole role);
|
||||
void StartAbilityDone();
|
||||
|
||||
private:
|
||||
void waitForTimeout(uint32_t timeout_s);
|
||||
|
||||
private:
|
||||
sem_t mSem_;
|
||||
AbilityStatus mStatus_;
|
||||
AbilityRole mAbilityStatus_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_ABILITY_MANAGER_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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_DM_PIN_AUTH_H
|
||||
#define OHOS_DM_PIN_AUTH_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "authentication.h"
|
||||
#include "dm_ability_manager.h"
|
||||
#include "pin_auth_ui.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class PinAuth : public IAuthentication {
|
||||
public:
|
||||
PinAuth();
|
||||
~PinAuth();
|
||||
int32_t ShowAuthInfo() override;
|
||||
int32_t StartAuth(std::shared_ptr<DmAbilityManager> dmAbilityManager) override;
|
||||
int32_t VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam) override;
|
||||
|
||||
private:
|
||||
int32_t times_ = 0;
|
||||
std::shared_ptr<PinAuthUi> pinAuthUi_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_PIN_AUTH_H
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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_DM_PIN_AUTH_UI_H
|
||||
#define OHOS_DM_PIN_AUTH_UI_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "dm_ability_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class PinAuthUi {
|
||||
public:
|
||||
PinAuthUi();
|
||||
int32_t ShowPinDialog();
|
||||
int32_t InputPinDialog(std::shared_ptr<DmAbilityManager> dmAbilityManager);
|
||||
|
||||
private:
|
||||
int32_t StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager);
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_PIN_AUTH_UI_H
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 "dm_ability_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
AbilityRole DmAbilityManager::GetAbilityRole()
|
||||
{
|
||||
return mAbilityStatus_;
|
||||
}
|
||||
|
||||
AbilityStatus DmAbilityManager::StartAbility(AbilityRole role)
|
||||
{
|
||||
// not support for L1 yet, do nothing. just save status and role
|
||||
mAbilityStatus_ = role;
|
||||
mStatus_ = AbilityStatus::ABILITY_STATUS_SUCCESS;
|
||||
return mStatus_;
|
||||
}
|
||||
|
||||
void DmAbilityManager::waitForTimeout(uint32_t timeout_s)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
ts.tv_sec += timeout_s;
|
||||
sem_timedwait(&mSem_, &ts);
|
||||
}
|
||||
|
||||
void DmAbilityManager::StartAbilityDone()
|
||||
{
|
||||
mStatus_ = AbilityStatus::ABILITY_STATUS_SUCCESS;
|
||||
sem_post(&mSem_);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 "dm_ability_manager.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_record.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "parameter.h"
|
||||
#include "semaphore.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace {
|
||||
const int32_t ABILITY_START_TIMEOUT = 3; // 3 second
|
||||
const std::string bundleUiName = "com.ohos.devicemanagerui";
|
||||
const std::string abilityUiName = "com.ohos.devicemanagerui.MainAbility";
|
||||
} // namespace
|
||||
|
||||
AbilityRole DmAbilityManager::GetAbilityRole()
|
||||
{
|
||||
return mAbilityStatus_;
|
||||
}
|
||||
|
||||
AbilityStatus DmAbilityManager::StartAbility(AbilityRole role)
|
||||
{
|
||||
mAbilityStatus_ = role;
|
||||
char localDeviceId[DEVICE_UUID_LENGTH] = {0};
|
||||
GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH);
|
||||
std::string deviceId = localDeviceId;
|
||||
mStatus_ = ABILITY_STATUS_START;
|
||||
AAFwk::Want want;
|
||||
AppExecFwk::ElementName element(deviceId, bundleUiName, abilityUiName);
|
||||
want.SetElement(element);
|
||||
AAFwk::AbilityManagerClient::GetInstance()->Connect();
|
||||
ErrCode result = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want);
|
||||
if (result != OHOS::ERR_OK) {
|
||||
LOGE("Start Ability faild");
|
||||
mStatus_ = ABILITY_STATUS_FAILED;
|
||||
return mStatus_;
|
||||
}
|
||||
waitForTimeout(ABILITY_START_TIMEOUT);
|
||||
return mStatus_;
|
||||
}
|
||||
|
||||
void DmAbilityManager::waitForTimeout(uint32_t timeout_s)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
ts.tv_sec += timeout_s;
|
||||
sem_timedwait(&mSem_, &ts);
|
||||
}
|
||||
|
||||
void DmAbilityManager::StartAbilityDone()
|
||||
{
|
||||
mStatus_ = ABILITY_STATUS_SUCCESS;
|
||||
sem_post(&mSem_);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 "pin_auth.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
const int32_t MAX_VERIFY_TIMES = 3;
|
||||
PinAuth::PinAuth()
|
||||
{
|
||||
LOGI("PinAuth constructor");
|
||||
}
|
||||
|
||||
PinAuth::~PinAuth()
|
||||
{
|
||||
}
|
||||
|
||||
int32_t PinAuth::ShowAuthInfo()
|
||||
{
|
||||
return pinAuthUi_->ShowPinDialog();
|
||||
}
|
||||
|
||||
int32_t PinAuth::StartAuth(std::shared_ptr<DmAbilityManager> dmAbilityManager)
|
||||
{
|
||||
times_ = 0;
|
||||
return pinAuthUi_->InputPinDialog(dmAbilityManager);
|
||||
}
|
||||
|
||||
int32_t PinAuth::VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam)
|
||||
{
|
||||
times_ += 1;
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(authParam, nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
LOGE("DecodeRequestAuth jsonStr error");
|
||||
return DM_FAILED;
|
||||
}
|
||||
if (!jsonObject.contains(PIN_CODE_KEY) && !jsonObject.contains(PIN_TOKEN)) {
|
||||
LOGE("err json string, first time");
|
||||
return DM_FAILED;
|
||||
}
|
||||
int32_t inputPinCode = jsonObject[PIN_CODE_KEY];
|
||||
int32_t inputPinToken = jsonObject[PIN_TOKEN];
|
||||
if (code == inputPinCode && stoi(pinToken) == inputPinToken) {
|
||||
return DM_OK;
|
||||
} else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) {
|
||||
return DM_AUTH_INPUT_FAILED;
|
||||
} else {
|
||||
return DM_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" IAuthentication *CreatePinAuthObject(void)
|
||||
{
|
||||
return new PinAuth;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 "pin_auth_ui.h"
|
||||
|
||||
#include "dm_ability_manager.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
PinAuthUi::PinAuthUi()
|
||||
{
|
||||
LOGI("AuthUi constructor");
|
||||
}
|
||||
|
||||
int32_t PinAuthUi::ShowPinDialog()
|
||||
{
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t PinAuthUi::InputPinDialog(std::shared_ptr<DmAbilityManager> dmAbilityManager)
|
||||
{
|
||||
if (dmAbilityManager == nullptr) {
|
||||
LOGE("PinAuthUi::dmAbilityManager is null");
|
||||
return DM_FAILED;
|
||||
}
|
||||
return StartFaUiService(dmAbilityManager);
|
||||
}
|
||||
|
||||
int32_t PinAuthUi::StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager)
|
||||
{
|
||||
AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE);
|
||||
if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) {
|
||||
LOGE("PinAuthUi::StartFaService timeout");
|
||||
return DM_FAILED;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,75 @@
|
||||
# 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.
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
} else {
|
||||
import("//build/ohos.gni")
|
||||
}
|
||||
|
||||
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
} else {
|
||||
ohos_shared_library("devicemanagerext_profile") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
"${common_path}/include/ipc/model",
|
||||
"${ext_path}/profile/include",
|
||||
"${services_path}/include",
|
||||
"${services_path}/include/adapter",
|
||||
"${services_path}/include/dependency/softbus",
|
||||
"${services_path}/include/ipc/standard",
|
||||
"${services_path}/include/devicestate",
|
||||
"${utils_path}/include",
|
||||
"${utils_path}/include/ipc/standard",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include/ipc/standard",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/device_profile_adapter.cpp",
|
||||
"src/profile_connector.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${services_path}:devicemanagerservice",
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"device_profile_core:distributed_device_profile_client",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"devicemanagerext\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
subsystem_name = "distributedhardware"
|
||||
|
||||
part_name = "device_manager_base"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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_DM_ADAPTER_DEVICE_PROFILE_H
|
||||
#define OHOS_DM_ADAPTER_DEVICE_PROFILE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "profile_adapter.h"
|
||||
#include "profile_connector.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DeviceProfileAdapter : public IProfileAdapter, public IProfileConnectorCallback {
|
||||
public:
|
||||
DeviceProfileAdapter();
|
||||
~DeviceProfileAdapter();
|
||||
int32_t RegisterProfileListener(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<DmDeviceStateManager> callback);
|
||||
int32_t UnRegisterProfileListener(const std::string &pkgName);
|
||||
int32_t OnProfileClientDeviceReady(const std::string &pkgName, const std::string &deviceId);
|
||||
void OnProfileChanged(const std::string &pkgName, const std::string &deviceId);
|
||||
void OnProfileComplete(const std::string &pkgName, const std::string &deviceId);
|
||||
|
||||
private:
|
||||
std::shared_ptr<DmDeviceStateManager> deviceProfileAdapterCallback_;
|
||||
static std::shared_ptr<ProfileConnector> profileConnector_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_ADAPTER_DEVICE_PROFILE_H
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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_DM_PROFILE_CONNECTOR_H
|
||||
#define OHOS_DM_PROFILE_CONNECTOR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "distributed_device_profile_client.h"
|
||||
#include "profile_connector_callback.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
using namespace OHOS::DeviceProfile;
|
||||
|
||||
class ProfileEventCallback : public IProfileEventCallback {
|
||||
public:
|
||||
void OnSyncCompleted(const SyncResult &syncResults);
|
||||
int32_t RegisterProfileCallback(const std::string &pkgName, std::shared_ptr<IProfileConnectorCallback> callback);
|
||||
int32_t UnRegisterProfileCallback(const std::string &pkgName);
|
||||
|
||||
public:
|
||||
static std::map<std::string, std::shared_ptr<IProfileConnectorCallback>> profileConnectorCallback_;
|
||||
};
|
||||
|
||||
class ProfileConnector : public IProfileEventCallback {
|
||||
public:
|
||||
int32_t RegisterProfileCallback(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<IProfileConnectorCallback> callback);
|
||||
int32_t UnRegisterProfileCallback(const std::string &pkgName);
|
||||
int32_t SubscribeProfileEvents(const std::list<std::string> &serviceIds, const std::string &deviceId);
|
||||
int32_t UnSubscribeProfileEvents();
|
||||
|
||||
private:
|
||||
static std::shared_ptr<ProfileEventCallback> profileEventCallback_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_PROFILE_CONNECTOR_H
|
||||
@@ -13,19 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DM_LOG_H
|
||||
#define OHOS_DM_LOG_H
|
||||
#ifndef OHOS_DM_PROFILE_CONNECTOR_CALLBACK_H
|
||||
#define OHOS_DM_PROFILE_CONNECTOR_CALLBACK_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
typedef enum {
|
||||
DM_LOG_DEBUG,
|
||||
DM_LOG_INFO,
|
||||
DM_LOG_WARN,
|
||||
DM_LOG_ERROR,
|
||||
} DMLogLevel;
|
||||
|
||||
void DMLog(DMLogLevel logLevel, const char *fmt, ...);
|
||||
class IProfileConnectorCallback {
|
||||
public:
|
||||
virtual void OnProfileChanged(const std::string &pkgName, const std::string &deviceId) = 0;
|
||||
virtual void OnProfileComplete(const std::string &pkgName, const std::string &deviceId) = 0;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_LOG_H
|
||||
#endif // OHOS_DM_PROFILE_CONNECTOR_CALLBACK_H
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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_profile_adapter.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_device_state_manager.h"
|
||||
#include "dm_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
std::shared_ptr<ProfileConnector> DeviceProfileAdapter::profileConnector_ = std::make_shared<ProfileConnector>();
|
||||
|
||||
DeviceProfileAdapter::DeviceProfileAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceProfileAdapter::~DeviceProfileAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<DmDeviceStateManager> callback)
|
||||
{
|
||||
LOGI("DeviceProfileAdapter::RegisterProfileListener");
|
||||
deviceProfileAdapterCallback_ = callback;
|
||||
profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr<DeviceProfileAdapter>(this));
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceProfileAdapter::UnRegisterProfileListener(const std::string &pkgName)
|
||||
{
|
||||
LOGI("DeviceProfileAdapter::RegisterProfileListener");
|
||||
deviceProfileAdapterCallback_ = nullptr;
|
||||
profileConnector_->UnRegisterProfileCallback(pkgName);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceProfileAdapter::OnProfileClientDeviceReady(const std::string &pkgName, const std::string &deviceId)
|
||||
{
|
||||
LOGI("DeviceProfileAdapter::OnProfileClientDeviceReady");
|
||||
if (deviceProfileAdapterCallback_ != nullptr) {
|
||||
deviceProfileAdapterCallback_->OnProfileReady(pkgName, deviceId);
|
||||
} else {
|
||||
LOGI("deviceProfileAdapterCallback_ is nullptr");
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::OnProfileChanged(const std::string &pkgName, const std::string &deviceId)
|
||||
{
|
||||
OnProfileClientDeviceReady(pkgName, deviceId);
|
||||
}
|
||||
|
||||
void DeviceProfileAdapter::OnProfileComplete(const std::string &pkgName, const std::string &deviceId)
|
||||
{
|
||||
OnProfileClientDeviceReady(pkgName, deviceId);
|
||||
}
|
||||
|
||||
extern "C" IProfileAdapter *CreateDeviceProfileObject(void)
|
||||
{
|
||||
return new DeviceProfileAdapter;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 "profile_connector.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
std::map<std::string, std::shared_ptr<IProfileConnectorCallback>> ProfileEventCallback::profileConnectorCallback_ = {};
|
||||
std::shared_ptr<ProfileEventCallback> ProfileConnector::profileEventCallback_ =
|
||||
std::make_shared<ProfileEventCallback>();
|
||||
|
||||
int32_t ProfileConnector::RegisterProfileCallback(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<IProfileConnectorCallback> callback)
|
||||
{
|
||||
LOGI("ProfileConnector::RegisterProfileCallback");
|
||||
profileEventCallback_->RegisterProfileCallback(pkgName, callback);
|
||||
SubscribeProfileEvents({ "system", "device", "fakeStorage", "fakeSystem" }, deviceId);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t ProfileConnector::UnRegisterProfileCallback(const std::string &pkgName)
|
||||
{
|
||||
LOGI("ProfileConnector::UnRegisterProfileCallback");
|
||||
profileEventCallback_->UnRegisterProfileCallback(pkgName);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t ProfileConnector::SubscribeProfileEvents(const std::list<std::string> &serviceIds, const std::string &deviceId)
|
||||
{
|
||||
ExtraInfo extraInfo;
|
||||
extraInfo["deviceId"] = deviceId;
|
||||
extraInfo["serviceIds"] = serviceIds;
|
||||
|
||||
std::list<SubscribeInfo> subscribeInfos;
|
||||
|
||||
SubscribeInfo eventSync;
|
||||
eventSync.profileEvent = ProfileEvent::EVENT_SYNC_COMPLETED;
|
||||
subscribeInfos.emplace_back(eventSync);
|
||||
|
||||
std::list<ProfileEvent> failedEvents;
|
||||
u_int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(
|
||||
subscribeInfos, profileEventCallback_, failedEvents);
|
||||
LOGI("ProfileConnector::SubscribeProfileEvents result=%d", errCode);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t ProfileConnector::UnSubscribeProfileEvents()
|
||||
{
|
||||
std::list<ProfileEvent> profileEvents;
|
||||
profileEvents.emplace_back(ProfileEvent::EVENT_PROFILE_CHANGED);
|
||||
profileEvents.emplace_back(ProfileEvent::EVENT_SYNC_COMPLETED);
|
||||
std::list<ProfileEvent> failedEvents;
|
||||
u_int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(
|
||||
profileEvents, profileEventCallback_, failedEvents);
|
||||
LOGI("ProfileConnector::UnSubscribeProfileEvents result=%d", errCode);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t ProfileEventCallback::RegisterProfileCallback(const std::string &pkgName,
|
||||
std::shared_ptr<IProfileConnectorCallback> callback)
|
||||
{
|
||||
LOGI("ProfileEventCallback::RegisterProfileCallback");
|
||||
profileConnectorCallback_.emplace(pkgName, callback);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t ProfileEventCallback::UnRegisterProfileCallback(const std::string &pkgName)
|
||||
{
|
||||
LOGI("ProfileEventCallback::UnRegisterProfileCallback");
|
||||
profileConnectorCallback_.erase(pkgName);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
void ProfileEventCallback::OnSyncCompleted(const SyncResult &syncResults)
|
||||
{
|
||||
std::string deviceId;
|
||||
u_int32_t SyncStatus;
|
||||
for (auto &iterResult : syncResults) {
|
||||
deviceId = iterResult.first;
|
||||
SyncStatus = iterResult.second;
|
||||
}
|
||||
LOGI("ProfileEventCallback::OnSyncCompleted, deviceId = %s", deviceId.c_str());
|
||||
for (auto &iter : profileConnectorCallback_) {
|
||||
iter.second->OnProfileComplete(iter.first, deviceId);
|
||||
}
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -20,68 +20,24 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
shared_library("devicemanagersdk") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/ipc",
|
||||
"include/ipc/lite",
|
||||
"include/notify",
|
||||
"${utils_path}/include/log",
|
||||
"${utils_path}/include/ipc/lite",
|
||||
"${common_path}/include/ipc",
|
||||
"${common_path}/include/ipc/model",
|
||||
"${common_path}/include",
|
||||
]
|
||||
include_dirs += [
|
||||
"//utils/native/lite/include",
|
||||
"//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//foundation/communication/ipc_lite/interfaces/kits",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/device_manager.cpp",
|
||||
"src/device_manager_impl.cpp",
|
||||
"src/ipc/ipc_client_proxy.cpp",
|
||||
"src/ipc/lite/ipc_client_manager.cpp",
|
||||
"src/ipc/lite/ipc_client_server_proxy.cpp",
|
||||
"src/ipc/lite/ipc_client_stub.cpp",
|
||||
"src/ipc/lite/ipc_cmd_parser.cpp",
|
||||
"src/notify/device_manager_notify.cpp",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"LITE_DEVICE",
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"devicemanagerkit\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
|
||||
"//foundation/communication/ipc_lite:liteipc_adapter",
|
||||
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
"//utils/native/lite:utils",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
ohos_shared_library("devicemanagersdk") {
|
||||
include_dirs = [
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"include",
|
||||
"include/ipc/standard",
|
||||
"include/ipc",
|
||||
"include/ipc/standard",
|
||||
"include/notify",
|
||||
"${utils_path}/include/log",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
"${common_path}/include/ipc/model",
|
||||
"${utils_path}/include",
|
||||
"${utils_path}/include/ipc/standard",
|
||||
"${common_path}/include",
|
||||
"//third_party/json/include",
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -97,6 +53,7 @@ if (defined(ohos_lite)) {
|
||||
|
||||
deps = [
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/want:want",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,43 +13,48 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_MANAGER_H
|
||||
#define DEVICE_MANAGER_H
|
||||
#ifndef OHOS_DEVICE_MANAGER_H
|
||||
#define OHOS_DEVICE_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "device_manager_callback.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "dm_app_image_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DeviceManager {
|
||||
public:
|
||||
static DeviceManager &GetInstance();
|
||||
|
||||
public:
|
||||
virtual int32_t InitDeviceManager(std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback) = 0;
|
||||
virtual int32_t UnInitDeviceManager(std::string &pkgName) = 0;
|
||||
virtual int32_t GetTrustedDeviceList(std::string &pkgName, std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList) = 0;
|
||||
virtual int32_t RegisterDevStateCallback(std::string &pkgName, std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback) = 0;
|
||||
virtual int32_t UnRegisterDevStateCallback(std::string &pkgName) = 0;
|
||||
virtual int32_t StartDeviceDiscovery(std::string &pkgName, DmSubscribeInfo &subscribeInfo,
|
||||
std::shared_ptr<DiscoverCallback> callback) = 0;
|
||||
virtual int32_t StopDeviceDiscovery(std::string &pkgName, uint16_t subscribeId) = 0;
|
||||
virtual int32_t AuthenticateDevice(std::string &pkgName, const DmDeviceInfo &deviceInfo,
|
||||
const DmAppImageInfo &imageInfo, std::string &extra, std::shared_ptr<AuthenticateCallback> callback) = 0;
|
||||
virtual int32_t CheckAuthentication(std::string &pkgName, std::string &authPara,
|
||||
std::shared_ptr<CheckAuthCallback> callback) = 0;
|
||||
virtual int32_t GetAuthenticationParam(std::string &pkgName, DmAuthParam &authParam) = 0;
|
||||
virtual int32_t SetUserOperation(std::string &pkgName, int32_t action) = 0;
|
||||
virtual int32_t RegisterDeviceManagerFaCallback(std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback) = 0;
|
||||
virtual int32_t UnRegisterDeviceManagerFaCallback(std::string &pkgName) = 0;
|
||||
virtual int32_t InitDeviceManager(const std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback) = 0;
|
||||
virtual int32_t UnInitDeviceManager(const std::string &pkgName) = 0;
|
||||
virtual int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList) = 0;
|
||||
virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &deviceInfo) = 0;
|
||||
virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback) = 0;
|
||||
virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName) = 0;
|
||||
virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo,
|
||||
const std::string &extra, std::shared_ptr<DiscoveryCallback> callback) = 0;
|
||||
virtual int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) = 0;
|
||||
virtual int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const DmDeviceInfo &deviceInfo,
|
||||
const std::string &extra, std::shared_ptr<AuthenticateCallback> callback) = 0;
|
||||
virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) = 0;
|
||||
virtual int32_t VerifyAuthentication(const std::string &pkgName, const std::string &authPara,
|
||||
std::shared_ptr<VerifyAuthCallback> callback) = 0;
|
||||
virtual int32_t RegisterDeviceManagerFaCallback(const std::string &pkgName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback) = 0;
|
||||
virtual int32_t UnRegisterDeviceManagerFaCallback(const std::string &pkgName) = 0;
|
||||
virtual int32_t GetFaParam(const std::string &pkgName, DmAuthParam &faParam) = 0;
|
||||
virtual int32_t SetUserOperation(const std::string &pkgName, int32_t action) = 0;
|
||||
virtual int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &udid) = 0;
|
||||
virtual int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &uuid) = 0;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_H
|
||||
#endif // DEVICE_MANAGER_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_CALLBACK_H
|
||||
#define OHOS_DEVICE_MANAGER_CALLBACK_H
|
||||
#ifndef OHOS_DM_CALLBACK_H
|
||||
#define OHOS_DM_CALLBACK_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -25,44 +25,56 @@ namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DmInitCallback {
|
||||
public:
|
||||
virtual ~DmInitCallback() {}
|
||||
virtual ~DmInitCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnRemoteDied() = 0;
|
||||
};
|
||||
|
||||
class DeviceStateCallback {
|
||||
public:
|
||||
virtual ~DeviceStateCallback() {}
|
||||
virtual ~DeviceStateCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnDeviceOnline(const DmDeviceInfo &deviceInfo) = 0;
|
||||
virtual void OnDeviceReady(const DmDeviceInfo &deviceInfo) = 0;
|
||||
virtual void OnDeviceOffline(const DmDeviceInfo &deviceInfo) = 0;
|
||||
virtual void OnDeviceChanged(const DmDeviceInfo &deviceInfo) = 0;
|
||||
virtual void OnDeviceReady(const DmDeviceInfo &deviceInfo) = 0;
|
||||
};
|
||||
|
||||
class DiscoverCallback {
|
||||
class DiscoveryCallback {
|
||||
public:
|
||||
virtual ~DiscoverCallback() {}
|
||||
virtual ~DiscoveryCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnDiscoverySuccess(uint16_t subscribeId) = 0;
|
||||
virtual void OnDiscoverFailed(uint16_t subscribeId, int32_t failedReason) = 0;
|
||||
virtual void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) = 0;
|
||||
virtual void OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) = 0;
|
||||
};
|
||||
|
||||
class AuthenticateCallback {
|
||||
public:
|
||||
virtual ~AuthenticateCallback() {}
|
||||
virtual void OnAuthResult(std::string &deviceId, int32_t pinToken, int32_t status, int32_t reason) = 0;
|
||||
virtual ~AuthenticateCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status,
|
||||
int32_t reason) = 0;
|
||||
};
|
||||
|
||||
class CheckAuthCallback {
|
||||
class VerifyAuthCallback {
|
||||
public:
|
||||
virtual ~CheckAuthCallback() {}
|
||||
virtual void OnCheckAuthResult(std::string &deviceId, int32_t resultCode, int32_t flag) = 0;
|
||||
virtual ~VerifyAuthCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnVerifyAuthResult(const std::string &deviceId, int32_t resultCode, int32_t flag) = 0;
|
||||
};
|
||||
|
||||
class DeviceManagerFaCallback {
|
||||
public:
|
||||
virtual ~DeviceManagerFaCallback() {}
|
||||
virtual void OnCall(std::string ¶mJson) = 0;
|
||||
virtual ~DeviceManagerFaCallback()
|
||||
{
|
||||
}
|
||||
virtual void OnCall(const std::string ¶mJson) = 0;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_CALLBACK_H
|
||||
#endif // OHOS_DM_CALLBACK_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -16,41 +16,57 @@
|
||||
#ifndef OHOS_DEVICE_MANAGER_IMPL_H
|
||||
#define OHOS_DEVICE_MANAGER_IMPL_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "device_manager.h"
|
||||
|
||||
#include "ipc_client_proxy.h"
|
||||
#include "ipc_client_manager.h"
|
||||
|
||||
#include "single_instance.h"
|
||||
#include "ipc_client_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DeviceManagerImpl : public DeviceManager {
|
||||
DECLARE_SINGLE_INSTANCE(DeviceManagerImpl);
|
||||
public:
|
||||
virtual int32_t InitDeviceManager(std::string &pkgName,
|
||||
std::shared_ptr<DmInitCallback> dmInitCallback) override;
|
||||
virtual int32_t UnInitDeviceManager(std::string &pkgName) override;
|
||||
virtual int32_t GetTrustedDeviceList(std::string &pkgName, std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList) override;
|
||||
virtual int32_t RegisterDevStateCallback(std::string &pkgName, std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback) override;
|
||||
virtual int32_t UnRegisterDevStateCallback(std::string &pkgName) override;
|
||||
virtual int32_t StartDeviceDiscovery(std::string &pkgName, DmSubscribeInfo &subscribeInfo,
|
||||
std::shared_ptr<DiscoverCallback> callback) override;
|
||||
virtual int32_t StopDeviceDiscovery(std::string &pkgName, uint16_t subscribeId) override;
|
||||
virtual int32_t AuthenticateDevice(std::string &pkgName, const DmDeviceInfo &deviceInfo,
|
||||
const DmAppImageInfo &imageInfo, std::string &extra,
|
||||
std::shared_ptr<AuthenticateCallback> callback) override;
|
||||
virtual int32_t CheckAuthentication(std::string &pkgName, std::string &authPara,
|
||||
std::shared_ptr<CheckAuthCallback> callback) override;
|
||||
virtual int32_t GetAuthenticationParam(std::string &pkgName, DmAuthParam &authParam) override;
|
||||
virtual int32_t SetUserOperation(std::string &pkgName, int32_t action) override;
|
||||
virtual int32_t RegisterDeviceManagerFaCallback(std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback) override;
|
||||
virtual int32_t UnRegisterDeviceManagerFaCallback(std::string &pkgName) override;
|
||||
static DeviceManagerImpl &GetInstance();
|
||||
|
||||
public:
|
||||
virtual int32_t InitDeviceManager(const std::string &pkgName,
|
||||
std::shared_ptr<DmInitCallback> dmInitCallback) override;
|
||||
virtual int32_t UnInitDeviceManager(const std::string &pkgName) override;
|
||||
virtual int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList) override;
|
||||
virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &deviceInfo) override;
|
||||
virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback) override;
|
||||
virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName) override;
|
||||
virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo,
|
||||
const std::string &extra,
|
||||
std::shared_ptr<DiscoveryCallback> callback) override;
|
||||
virtual int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) override;
|
||||
virtual int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const DmDeviceInfo &deviceInfo,
|
||||
const std::string &extra,
|
||||
std::shared_ptr<AuthenticateCallback> callback) override;
|
||||
virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) override;
|
||||
virtual int32_t VerifyAuthentication(const std::string &pkgName, const std::string &authPara,
|
||||
std::shared_ptr<VerifyAuthCallback> callback) override;
|
||||
virtual int32_t RegisterDeviceManagerFaCallback(const std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback) override;
|
||||
virtual int32_t UnRegisterDeviceManagerFaCallback(const std::string &pkgName) override;
|
||||
virtual int32_t GetFaParam(const std::string &pkgName, DmAuthParam &faParam) override;
|
||||
virtual int32_t SetUserOperation(const std::string &pkgName, int32_t action) override;
|
||||
virtual int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
|
||||
std::string &udid) override;
|
||||
virtual int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
|
||||
std::string &uuid) override;
|
||||
|
||||
private:
|
||||
DeviceManagerImpl() = default;
|
||||
~DeviceManagerImpl() = default;
|
||||
DeviceManagerImpl(const DeviceManagerImpl &) = delete;
|
||||
DeviceManagerImpl &operator=(const DeviceManagerImpl &) = delete;
|
||||
DeviceManagerImpl(DeviceManagerImpl &&) = delete;
|
||||
DeviceManagerImpl &operator=(DeviceManagerImpl &&) = delete;
|
||||
|
||||
private:
|
||||
bool isSystemAppCalling(void);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IpcClientProxy> ipcClientProxy_ =
|
||||
std::make_shared<IpcClientProxy>(std::make_shared<IpcClientManager>());
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_APP_IMAGE_INFO_H
|
||||
#define OHOS_DEVICE_MANAGER_APP_IMAGE_INFO_H
|
||||
#ifndef OHOS_DM_APP_IMAGE_INFO_H
|
||||
#define OHOS_DM_APP_IMAGE_INFO_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
appThumbnail = new (std::nothrow) uint8_t[appThumbnailLen_] {0};
|
||||
appThumbnail = new (std::nothrow) uint8_t[appThumbnailLen_] { 0 };
|
||||
if (appThumbnail != nullptr) {
|
||||
appThumbnailLen = appThumbnailLen_;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
int32_t SetThumbnailData(uint8_t *srcBuffer, int32_t srcBufferLen, int32_t copyIndex, int32_t copyLen)
|
||||
{
|
||||
if (srcBuffer == nullptr || srcBufferLen <= 0 || copyLen > srcBufferLen || copyIndex < 0) {
|
||||
if (srcBuffer == nullptr || srcBufferLen <= 0 || copyLen > srcBufferLen || copyIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
DmAppImageInfo& operator=(const DmAppImageInfo &other)
|
||||
DmAppImageInfo &operator=(const DmAppImageInfo &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
SaveData(other.GetAppIcon(), other.GetAppIconLen(), other.GetAppThumbnail(), other.GetAppThumbnailLen());
|
||||
@@ -102,8 +102,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
DmAppImageInfo(DmAppImageInfo&&) = delete;
|
||||
DmAppImageInfo& operator=(DmAppImageInfo&&) = delete;
|
||||
DmAppImageInfo(DmAppImageInfo &&) = delete;
|
||||
DmAppImageInfo &operator=(DmAppImageInfo &&) = delete;
|
||||
|
||||
int32_t GetAppIconLen() const
|
||||
{
|
||||
@@ -124,6 +124,7 @@ public:
|
||||
{
|
||||
return appThumbnail;
|
||||
}
|
||||
|
||||
private:
|
||||
void SaveData(const uint8_t *appIcon_, int32_t appIconLen_, const uint8_t *appThumbnail_, int32_t appThumbnailLen_)
|
||||
{
|
||||
@@ -140,7 +141,7 @@ private:
|
||||
appIcon = nullptr;
|
||||
appIconLen = 0;
|
||||
}
|
||||
appIcon = new (std::nothrow) uint8_t[appIconLen_] {0};
|
||||
appIcon = new (std::nothrow) uint8_t[appIconLen_] { 0 };
|
||||
}
|
||||
if (appIcon != nullptr) {
|
||||
appIconLen = appIconLen_;
|
||||
@@ -160,7 +161,7 @@ private:
|
||||
appThumbnail = nullptr;
|
||||
appThumbnailLen = 0;
|
||||
}
|
||||
appThumbnail = new (std::nothrow) uint8_t[appThumbnailLen_] {0};
|
||||
appThumbnail = new (std::nothrow) uint8_t[appThumbnailLen_] { 0 };
|
||||
}
|
||||
if (appThumbnail != nullptr) {
|
||||
appThumbnailLen = appThumbnailLen_;
|
||||
@@ -170,14 +171,15 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int32_t appIconLen {0};
|
||||
uint8_t *appIcon {nullptr};
|
||||
int32_t appThumbnailLen {0};
|
||||
uint8_t *appThumbnail {nullptr};
|
||||
int32_t appIconLen { 0 };
|
||||
uint8_t *appIcon { nullptr };
|
||||
int32_t appThumbnailLen { 0 };
|
||||
uint8_t *appThumbnail { nullptr } ;
|
||||
const int32_t ICON_MAX_LEN = 32 * 1024;
|
||||
const int32_t THUMB_MAX_LEN = 153 * 1024;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_APP_IMAGE_INFO_H
|
||||
#endif // OHOS_DM_APP_IMAGE_INFO_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_DEVICE_INFO_H
|
||||
#define OHOS_DEVICE_MANAGER_DEVICE_INFO_H
|
||||
#ifndef OHOS_DM_DEVICE_INFO_H
|
||||
#define OHOS_DM_DEVICE_INFO_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -25,31 +25,34 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
typedef enum DMDeviceType {
|
||||
typedef enum DmDeviceType {
|
||||
DEVICE_TYPE_UNKNOWN = 0x00,
|
||||
DEVICE_TYPE_WIFI_CAMERA = 0x08,
|
||||
DEVICE_TYPE_AUDIO = 0x0A,
|
||||
DEVICE_TYPE_PC = 0x0C,
|
||||
DEVICE_TYPE_PHONE = 0x0E,
|
||||
DEVICE_TYPE_PAD = 0x11,
|
||||
DEVICE_TYPE_WATCH = 0x6D,
|
||||
DEVICE_TYPE_CAR = 0x83,
|
||||
DEVICE_TYPE_TV = 0x9C,
|
||||
} DMDeviceType;
|
||||
} DmDeviceType;
|
||||
|
||||
typedef enum DmDeviceState {
|
||||
DEVICE_STATE_UNKNOWN = 0,
|
||||
DEVICE_STATE_ONLINE = 1,
|
||||
DEVICE_STATE_OFFLINE = 2,
|
||||
DEVICE_INFO_CHANGED = 3,
|
||||
DEVICE_INFO_READY = 4,
|
||||
} DmDeviceState;
|
||||
|
||||
typedef struct DmDeviceInfo {
|
||||
char deviceId[DM_MAX_DEVICE_ID_LEN];
|
||||
char deviceName[DM_MAX_DEVICE_NAME_LEN];
|
||||
DMDeviceType deviceTypeId;
|
||||
uint16_t deviceTypeId;
|
||||
} DmDeviceInfo;
|
||||
|
||||
typedef struct DmAuthParam {
|
||||
std::string authToken;
|
||||
std::string packageName;
|
||||
std::string appName;
|
||||
std::string appDescription;
|
||||
@@ -62,4 +65,4 @@ typedef struct DmAuthParam {
|
||||
} DmAuthParam;
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_DEVICE_INFO_H
|
||||
#endif // OHOS_DM_DEVICE_INFO_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_SUBSCRIBE_INFO_H
|
||||
#define OHOS_DEVICE_MANAGER_SUBSCRIBE_INFO_H
|
||||
#ifndef OHOS_DM_SUBSCRIBE_INFO_H
|
||||
#define OHOS_DM_SUBSCRIBE_INFO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef enum DmDiscoverMode {
|
||||
/* Passive */
|
||||
DM_DISCOVER_MODE_PASSIVE = 0x55,
|
||||
/* Proactive */
|
||||
DM_DISCOVER_MODE_ACTIVE = 0xAA
|
||||
DM_DISCOVER_MODE_ACTIVE = 0xAA
|
||||
} DmDiscoverMode;
|
||||
|
||||
typedef enum DmExchangeMedium {
|
||||
@@ -76,4 +76,4 @@ typedef struct DmSubscribeInfo {
|
||||
} DmSubscribeInfo;
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_SUBSCRIBE_INFO_H
|
||||
#endif // OHOS_DM_SUBSCRIBE_INFO_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_H
|
||||
#define OHOS_DM_IPC_CLIENT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
@@ -26,12 +26,13 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcClient {
|
||||
DECLARE_IPC_INTERFACE(IpcClient);
|
||||
DECLARE_IPC_INTERFACE(IpcClient);
|
||||
|
||||
public:
|
||||
virtual int32_t Init(std::string &pkgName) = 0;
|
||||
virtual int32_t UnInit(std::string &pkgName) = 0;
|
||||
virtual int32_t Init(const std::string &pkgName) = 0;
|
||||
virtual int32_t UnInit(const std::string &pkgName) = 0;
|
||||
virtual int32_t SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) = 0;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_PROXY_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_PROXY_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_PROXY_H
|
||||
#define OHOS_DM_IPC_CLIENT_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -26,16 +26,19 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcClientProxy : public IpcClient {
|
||||
DECLARE_IPC_INTERFACE(IpcClientProxy);
|
||||
DECLARE_IPC_INTERFACE(IpcClientProxy);
|
||||
|
||||
public:
|
||||
IpcClientProxy(std::shared_ptr<IpcClient> ipcClientManager) : ipcClientManager_(ipcClientManager) {};
|
||||
|
||||
public:
|
||||
virtual int32_t Init(std::string &pkgName);
|
||||
virtual int32_t UnInit(std::string &pkgName);
|
||||
virtual int32_t Init(const std::string &pkgName);
|
||||
virtual int32_t UnInit(const std::string &pkgName);
|
||||
virtual int32_t SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp);
|
||||
|
||||
private:
|
||||
std::shared_ptr<IpcClient> ipcClientManager_ {nullptr};
|
||||
std::shared_ptr<IpcClient> ipcClientManager_ { nullptr };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_PROXY_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_PROXY_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
#define OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "ipc_client.h"
|
||||
#include "ipc_client_server_proxy.h"
|
||||
@@ -26,17 +26,20 @@
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcClientManager : public IpcClient {
|
||||
DECLARE_IPC_INTERFACE(IpcClientManager);
|
||||
DECLARE_IPC_INTERFACE(IpcClientManager);
|
||||
|
||||
public:
|
||||
virtual int32_t Init(std::string &pkgName) override;
|
||||
virtual int32_t UnInit(std::string &pkgName) override;
|
||||
virtual int32_t Init(const std::string &pkgName) override;
|
||||
virtual int32_t UnInit(const std::string &pkgName) override;
|
||||
virtual int32_t SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) override;
|
||||
|
||||
private:
|
||||
bool IsInit(std::string &pkgName);
|
||||
bool IsInit(const std::string &pkgName);
|
||||
|
||||
private:
|
||||
IpcClientServerProxy serverProxy_;
|
||||
std::set<std::string> packageInitSet_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,33 +13,34 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
#define OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "iproxy_client.h"
|
||||
#include "liteipc_adapter.h"
|
||||
#include "samgr_lite.h"
|
||||
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcClientServerProxy {
|
||||
public:
|
||||
int32_t Init();
|
||||
int32_t SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp);
|
||||
|
||||
private:
|
||||
IClientProxy *GetServerProxy(void);
|
||||
int32_t RegisterServerDeathCb(void);
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
IClientProxy *serviceProxy_ {nullptr};
|
||||
IClientProxy *serviceProxy_ { nullptr };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,31 +13,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_STUB_H
|
||||
#define OHOS_DM_IPC_CLIENT_STUB_H
|
||||
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#include "liteipc_adapter.h"
|
||||
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcClientStub {
|
||||
DECLARE_SINGLE_INSTANCE(IpcClientStub);
|
||||
DECLARE_SINGLE_INSTANCE(IpcClientStub);
|
||||
|
||||
public:
|
||||
int32_t Init();
|
||||
SvcIdentity GetSvcIdentity() const
|
||||
{
|
||||
return clientIdentity_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
bool bInit {false};
|
||||
bool bInit { false };
|
||||
SvcIdentity clientIdentity_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_STUB_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,20 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
#define OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "iremote_object.h"
|
||||
|
||||
#include "ipc_client.h"
|
||||
#include "ipc_client_stub.h"
|
||||
#include "ipc_def.h"
|
||||
#include "ipc_remote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -38,21 +37,24 @@ public:
|
||||
};
|
||||
|
||||
class IpcClientManager : public IpcClient {
|
||||
friend class DmDeathRecipient;
|
||||
DECLARE_IPC_INTERFACE(IpcClientManager);
|
||||
friend class DmDeathRecipient;
|
||||
DECLARE_IPC_INTERFACE(IpcClientManager);
|
||||
|
||||
public:
|
||||
virtual int32_t Init(std::string &pkgName) override;
|
||||
virtual int32_t UnInit(std::string &pkgName) override;
|
||||
virtual int32_t Init(const std::string &pkgName) override;
|
||||
virtual int32_t UnInit(const std::string &pkgName) override;
|
||||
virtual int32_t SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) override;
|
||||
|
||||
private:
|
||||
bool IsInit(std::string &pkgName);
|
||||
bool IsInit(const std::string &pkgName);
|
||||
int32_t ClientInit();
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
std::map<std::string, sptr<IpcClientStub>> dmListener_;
|
||||
sptr<IpcRemoteBroker> dmInterface_ {nullptr};
|
||||
sptr<DmDeathRecipient> dmRecipient_ {nullptr};
|
||||
sptr<IpcRemoteBroker> dmInterface_ { nullptr };
|
||||
sptr<DmDeathRecipient> dmRecipient_ { nullptr };
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_MANAGER_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_MANAGER_H
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,16 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
#define OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "iremote_proxy.h"
|
||||
#include "ipc_remote_broker.h"
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "iremote_proxy.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -31,9 +31,10 @@ public:
|
||||
explicit IpcClientServerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IpcRemoteBroker>(impl) {};
|
||||
~IpcClientServerProxy() {};
|
||||
int32_t SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<IpcClientServerProxy> delegator_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_SERVER_PROXY_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_SERVER_PROXY_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,18 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#ifndef OHOS_DM_IPC_CLIENT_STUB_H
|
||||
#define OHOS_DM_IPC_CLIENT_STUB_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "iremote_stub.h"
|
||||
#include "iremote_broker.h"
|
||||
|
||||
#include "ipc_remote_broker.h"
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -37,4 +36,4 @@ public:
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_CLIENT_STUB_H
|
||||
#endif // OHOS_DM_IPC_CLIENT_STUB_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,26 +13,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_IPC_REMOTE_BROKER_H
|
||||
#define OHOS_DEVICE_MANAGER_IPC_REMOTE_BROKER_H
|
||||
#ifndef OHOS_DM_IPC_REMOTE_BROKER_H
|
||||
#define OHOS_DM_IPC_REMOTE_BROKER_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "iremote_broker.h"
|
||||
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IpcRemoteBroker : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
virtual ~IpcRemoteBroker() {}
|
||||
virtual ~IpcRemoteBroker()
|
||||
{
|
||||
}
|
||||
virtual int32_t SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp) = 0;
|
||||
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.distributedhardware.devicemanager");
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_IPC_REMOTE_BROKER_H
|
||||
#endif // OHOS_DM_IPC_REMOTE_BROKER_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,63 +13,66 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_NOTIFY_H
|
||||
#define OHOS_DEVICE_MANAGER_NOTIFY_H
|
||||
#ifndef OHOS_DM_NOTIFY_H
|
||||
#define OHOS_DM_NOTIFY_H
|
||||
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "device_manager_callback.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "device_manager_callback.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DeviceManagerNotify {
|
||||
DECLARE_SINGLE_INSTANCE(DeviceManagerNotify);
|
||||
DECLARE_SINGLE_INSTANCE(DeviceManagerNotify);
|
||||
|
||||
public:
|
||||
void RegisterDeathRecipientCallback(std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback);
|
||||
void UnRegisterDeathRecipientCallback(std::string &pkgName);
|
||||
void RegisterDeviceStateCallback(std::string &pkgName, std::shared_ptr<DeviceStateCallback> callback);
|
||||
void UnRegisterDeviceStateCallback(std::string &pkgName);
|
||||
void RegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId,
|
||||
std::shared_ptr<DiscoverCallback> callback);
|
||||
void UnRegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId);
|
||||
void RegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId,
|
||||
std::shared_ptr<AuthenticateCallback> callback);
|
||||
void UnRegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId);
|
||||
void UnRegisterPackageCallback(std::string &pkgName);
|
||||
void RegisterCheckAuthenticationCallback(std::string &pkgName, std::string &authPara,
|
||||
std::shared_ptr<CheckAuthCallback> callback);
|
||||
void UnRegisterCheckAuthenticationCallback(std::string &pkgName);
|
||||
void RegisterDeviceManagerFaCallback(std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback);
|
||||
void UnRegisterDeviceManagerFaCallback(std::string &pkgName);
|
||||
void RegisterDeathRecipientCallback(const std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback);
|
||||
void UnRegisterDeathRecipientCallback(const std::string &pkgName);
|
||||
void RegisterDeviceStateCallback(const std::string &pkgName, std::shared_ptr<DeviceStateCallback> callback);
|
||||
void UnRegisterDeviceStateCallback(const std::string &pkgName);
|
||||
void RegisterDiscoveryCallback(const std::string &pkgName, uint16_t subscribeId,
|
||||
std::shared_ptr<DiscoveryCallback> callback);
|
||||
void UnRegisterDiscoveryCallback(const std::string &pkgName, uint16_t subscribeId);
|
||||
void RegisterAuthenticateCallback(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<AuthenticateCallback> callback);
|
||||
void UnRegisterAuthenticateCallback(const std::string &pkgName, const std::string &deviceId);
|
||||
void UnRegisterPackageCallback(const std::string &pkgName);
|
||||
void RegisterVerifyAuthenticationCallback(const std::string &pkgName, const std::string &authPara,
|
||||
std::shared_ptr<VerifyAuthCallback> callback);
|
||||
void UnRegisterVerifyAuthenticationCallback(const std::string &pkgName);
|
||||
void RegisterDeviceManagerFaCallback(const std::string &pkgName, std::shared_ptr<DeviceManagerFaCallback> callback);
|
||||
void UnRegisterDeviceManagerFaCallback(const std::string &pkgName);
|
||||
|
||||
public:
|
||||
void OnRemoteDied();
|
||||
void OnDeviceOnline(std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceOffline(std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceChanged(std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceFound(std::string &pkgName, uint16_t subscribeId, const DmDeviceInfo &deviceInfo);
|
||||
void OnDiscoverFailed(std::string &pkgName, uint16_t subscribeId, int32_t failedReason);
|
||||
void OnDiscoverySuccess(std::string &pkgName, uint16_t subscribeId);
|
||||
void OnAuthResult(std::string &pkgName, std::string &deviceId, int32_t pinToken, uint32_t status,
|
||||
uint32_t reason);
|
||||
void OnCheckAuthResult(std::string &pkgName, std::string &deviceId, int32_t resultCode, int32_t flag);
|
||||
void OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceChanged(const std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceReady(const std::string &pkgName, const DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceFound(const std::string &pkgName, uint16_t subscribeId, const DmDeviceInfo &deviceInfo);
|
||||
void OnDiscoveryFailed(const std::string &pkgName, uint16_t subscribeId, int32_t failedReason);
|
||||
void OnDiscoverySuccess(const std::string &pkgName, uint16_t subscribeId);
|
||||
void OnAuthResult(const std::string &pkgName, const std::string &deviceId, const std::string &token,
|
||||
uint32_t status, uint32_t reason);
|
||||
void OnVerifyAuthResult(const std::string &pkgName, const std::string &deviceId, int32_t resultCode, int32_t flag);
|
||||
void OnFaCall(std::string &pkgName, std::string ¶mJson);
|
||||
|
||||
private:
|
||||
std::mutex lock_;
|
||||
std::map<std::string, std::shared_ptr<DeviceStateCallback>> deviceStateCallback_;
|
||||
std::map<std::string, std::map<uint16_t, std::shared_ptr<DiscoverCallback>>> deviceDiscoverCallbacks_;
|
||||
std::map<std::string, std::map<uint16_t, std::shared_ptr<DiscoveryCallback>>> deviceDiscoveryCallbacks_;
|
||||
std::map<std::string, std::map<std::string, std::shared_ptr<AuthenticateCallback>>> authenticateCallback_;
|
||||
std::map<std::string, std::shared_ptr<CheckAuthCallback>> checkauthcallback_;
|
||||
std::map<std::string, std::shared_ptr<VerifyAuthCallback>> verifyAuthCallback_;
|
||||
std::map<std::string, std::shared_ptr<DmInitCallback>> dmInitCallback_;
|
||||
std::map<std::string, std::shared_ptr<DeviceManagerFaCallback>> dmFaCallback_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DEVICE_MANAGER_NOTIFY_H
|
||||
#endif // OHOS_DM_NOTIFY_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,279 +15,520 @@
|
||||
|
||||
#include "device_manager_impl.h"
|
||||
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_notify.h"
|
||||
#include "constants.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "bundle_info.h"
|
||||
#include "bundle_mgr_client.h"
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#include "device_manager_notify.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_authenticate_device_req.h"
|
||||
#include "ipc_check_authenticate_req.h"
|
||||
#include "ipc_get_dmfaparam_rsp.h"
|
||||
#include "ipc_get_info_by_network_req.h"
|
||||
#include "ipc_get_info_by_network_rsp.h"
|
||||
#include "ipc_get_local_device_info_rsp.h"
|
||||
#include "ipc_get_trustdevice_req.h"
|
||||
#include "ipc_get_trustdevice_rsp.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "ipc_set_useroperation_req.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_start_discovery_req.h"
|
||||
#include "ipc_stop_discovery_req.h"
|
||||
#include "ipc_get_authenticationparam_rsp.h"
|
||||
#include "ipc_set_useroperation_req.h"
|
||||
#include "ipc_unauthenticate_device_req.h"
|
||||
#include "ipc_verify_authenticate_req.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::AppExecFwk::Constants;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
IMPLEMENT_SINGLE_INSTANCE(DeviceManagerImpl);
|
||||
|
||||
int32_t DeviceManagerImpl::InitDeviceManager(std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback)
|
||||
bool DeviceManagerImpl::isSystemAppCalling(void)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str());
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
if (uid < 0) {
|
||||
LOGI("app caller uid is: %d,", uid);
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityManager == nullptr) {
|
||||
LOGE("failed to get system ability mgr.");
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (remoteObject == nullptr) {
|
||||
LOGE("failed to get bundle manager proxy.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGI("get bundle manager proxy success.");
|
||||
sptr<IBundleMgr> iBundleMgr = iface_cast<IBundleMgr>(remoteObject);
|
||||
return iBundleMgr->CheckIsSystemAppByUid(uid);
|
||||
}
|
||||
|
||||
DeviceManagerImpl &DeviceManagerImpl::GetInstance()
|
||||
{
|
||||
static DeviceManagerImpl instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::InitDeviceManager(const std::string &pkgName, std::shared_ptr<DmInitCallback> dmInitCallback)
|
||||
{
|
||||
LOGI("DeviceManager::InitDeviceManager start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
if (pkgName.empty() || dmInitCallback == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManager error: Invalid parameter");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGE("InitDeviceManager error: Invalid parameter");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int32_t ret = ipcClientProxy_->Init(pkgName);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
return ret;
|
||||
if (ret != DM_OK) {
|
||||
LOGE("InitDeviceManager error: proxy init failed ret: %d", ret);
|
||||
return DM_INIT_FAILED;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback);
|
||||
DMLOG(DM_LOG_INFO, "success");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("InitDeviceManager success");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::UnInitDeviceManager(std::string &pkgName)
|
||||
int32_t DeviceManagerImpl::UnInitDeviceManager(const std::string &pkgName)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str());
|
||||
LOGI("DeviceManager::UnInitDeviceManager start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManager error: Invalid parameter");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGE("UnInitDeviceManager error: Invalid parameter");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int32_t ret = ipcClientProxy_->UnInit(pkgName);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
return ret;
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnInitDeviceManager error: proxy unInit failed ret: %d", ret);
|
||||
return DM_UNINIT_FAILED;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnInitDeviceManager completed with errcode %d", ret);
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("UnInitDeviceManager success");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::GetTrustedDeviceList(std::string &pkgName, std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList)
|
||||
int32_t DeviceManagerImpl::GetTrustedDeviceList(const std::string &pkgName, const std::string &extra,
|
||||
std::vector<DmDeviceInfo> &deviceList)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGI("DeviceManager::GetTrustedDeviceList start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcGetTrustdeviceReq> req = std::make_shared<IpcGetTrustdeviceReq>();
|
||||
std::shared_ptr<IpcGetTrustdeviceRsp> rsp = std::make_shared<IpcGetTrustdeviceRsp>();
|
||||
if (pkgName.empty()) {
|
||||
LOGE("GetTrustedDeviceList error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcGetTrustDeviceReq> req = std::make_shared<IpcGetTrustDeviceReq>();
|
||||
std::shared_ptr<IpcGetTrustDeviceRsp> rsp = std::make_shared<IpcGetTrustDeviceRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetExtra(extra);
|
||||
if (ipcClientProxy_->SendRequest(GET_TRUST_DEVICE_LIST, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
int32_t ret = ipcClientProxy_->SendRequest(GET_TRUST_DEVICE_LIST, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("GetTrustedDeviceList error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
if (rsp->GetErrCode() == DEVICEMANAGER_OK) {
|
||||
deviceList = rsp->GetDeviceVec();
|
||||
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGI("GetTrustedDeviceList error: failed ret: %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::GetTrustedDeviceList completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
deviceList = rsp->GetDeviceVec();
|
||||
LOGI("GetTrustedDeviceList completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::RegisterDevStateCallback(std::string &pkgName, std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback)
|
||||
int32_t DeviceManagerImpl::GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &info)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str());
|
||||
LOGI("DeviceManager::GetLocalDeviceInfo start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
|
||||
std::shared_ptr<IpcGetLocalDeviceInfoRsp> rsp = std::make_shared<IpcGetLocalDeviceInfoRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
int32_t ret = ipcClientProxy_->SendRequest(GET_LOCAL_DEVICE_INFO, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("GetLocalDeviceInfo error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGI("GetLocalDeviceInfo error: failed ret: %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
|
||||
info = rsp->GetLocalDeviceInfo();
|
||||
LOGI("GetLocalDeviceInfo completed,pkgname%s", req->GetPkgName().c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::RegisterDevStateCallback(const std::string &pkgName, const std::string &extra,
|
||||
std::shared_ptr<DeviceStateCallback> callback)
|
||||
{
|
||||
LOGI("DeviceManager::RegisterDevStateCallback start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
if (pkgName.empty() || callback == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGE("RegisterDevStateCallback error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::RegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("RegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::UnRegisterDevStateCallback(std::string &pkgName)
|
||||
int32_t DeviceManagerImpl::UnRegisterDevStateCallback(const std::string &pkgName)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str());
|
||||
LOGI("DeviceManager::UnRegisterDevStateCallback start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGE("UnRegisterDevStateCallback error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::StartDeviceDiscovery(std::string &pkgName, DmSubscribeInfo &subscribeInfo,
|
||||
std::shared_ptr<DiscoverCallback> callback)
|
||||
int32_t DeviceManagerImpl::StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo,
|
||||
const std::string &extra, std::shared_ptr<DiscoveryCallback> callback)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty() || callback == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGI("DeviceManager::StartDeviceDiscovery start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str());
|
||||
DeviceManagerNotify::GetInstance().RegisterDiscoverCallback(pkgName, subscribeInfo.subscribeId, callback);
|
||||
if (pkgName.empty() || callback == nullptr) {
|
||||
LOGE("StartDeviceDiscovery error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
LOGI("DeviceManager StartDeviceDiscovery in, pkgName %s", pkgName.c_str());
|
||||
DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeInfo.subscribeId, callback);
|
||||
|
||||
std::shared_ptr<IpcStartDiscoveryReq> req = std::make_shared<IpcStartDiscoveryReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetExtra(extra);
|
||||
req->SetSubscribeInfo(subscribeInfo);
|
||||
if (ipcClientProxy_->SendRequest(START_DEVICE_DISCOVER, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
int32_t ret = ipcClientProxy_->SendRequest(START_DEVICE_DISCOVER, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("StartDeviceDiscovery error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager StartDeviceDiscovery Failed with ret %d", ret);
|
||||
return ret;
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("StartDeviceDiscovery error: Failed with ret %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
LOGI("StartDeviceDiscovery completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::StopDeviceDiscovery(std::string &pkgName, uint16_t subscribeId)
|
||||
int32_t DeviceManagerImpl::StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGI("DeviceManager::StopDeviceDiscovery start , pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
DMLOG(DM_LOG_INFO, "StopDeviceDiscovery in, pkgName %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
LOGE("StopDeviceDiscovery error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
LOGI("StopDeviceDiscovery in, pkgName %s", pkgName.c_str());
|
||||
std::shared_ptr<IpcStopDiscoveryReq> req = std::make_shared<IpcStopDiscoveryReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetSubscribeId(subscribeId);
|
||||
if (ipcClientProxy_->SendRequest(STOP_DEVICE_DISCOVER, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
int32_t ret = ipcClientProxy_->SendRequest(STOP_DEVICE_DISCOVER, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("StopDeviceDiscovery error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "StopDeviceDiscovery Failed with ret %d", ret);
|
||||
return ret;
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("StopDeviceDiscovery error: Failed with ret %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().UnRegisterDiscoverCallback(pkgName, subscribeId);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::StopDeviceDiscovery completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId);
|
||||
LOGI("StopDeviceDiscovery completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::AuthenticateDevice(std::string &pkgName, const DmDeviceInfo &deviceInfo,
|
||||
const DmAppImageInfo &imageInfo, std::string &extra, std::shared_ptr<AuthenticateCallback> callback)
|
||||
int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_t authType,
|
||||
const DmDeviceInfo &deviceInfo, const std::string &extra,
|
||||
std::shared_ptr<AuthenticateCallback> callback)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGI("DeviceManager::AuthenticateDevice start , pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
|
||||
if (pkgName.empty()) {
|
||||
LOGE("AuthenticateDevice error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
DMLOG(DM_LOG_INFO, "AuthenticateDevice in, pkgName %s", pkgName.c_str());
|
||||
std::shared_ptr<IpcAuthenticateDeviceReq> req = std::make_shared<IpcAuthenticateDeviceReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetExtra(extra);
|
||||
req->SetAuthType(authType);
|
||||
req->SetDeviceInfo(deviceInfo);
|
||||
req->SetAppImageInfo(imageInfo);
|
||||
if (ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "AuthenticateDevice Failed with ret %d", ret);
|
||||
return ret;
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("AuthenticateDevice error: Failed with ret %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
|
||||
std::string strDeviceId = deviceInfo.deviceId;
|
||||
DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, strDeviceId, callback);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::CheckAuthentication(std::string &pkgName, std::string &authPara,
|
||||
std::shared_ptr<CheckAuthCallback> callback)
|
||||
int32_t DeviceManagerImpl::UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::CheckAuthentication start , pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGI("DeviceManager::UnAuthenticateDevice start , pkgName: %s, deviceId: %s", pkgName.c_str(), deviceId.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "CheckAuthentication in, pkgName %s", pkgName.c_str());
|
||||
std::shared_ptr<IpcCheckAuthenticateReq> req = std::make_shared<IpcCheckAuthenticateReq>();
|
||||
|
||||
if (deviceId.empty()) {
|
||||
LOGE("UnAuthenticateDevice error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
DmDeviceInfo deviceInfo;
|
||||
strcpy_s(deviceInfo.deviceId, DM_MAX_DEVICE_ID_LEN, deviceId.c_str());
|
||||
std::shared_ptr<IpcUnAuthenticateDeviceReq> req = std::make_shared<IpcUnAuthenticateDeviceReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetDeviceInfo(deviceInfo);
|
||||
int32_t ret = ipcClientProxy_->SendRequest(UNAUTHENTICATE_DEVICE, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnAuthenticateDevice error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnAuthenticateDevice error: Failed with ret %d", ret);
|
||||
return DM_IPC_RESPOND_ERROR;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId);
|
||||
LOGI("UnAuthenticateDevice completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(const std::string &pkgName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback)
|
||||
{
|
||||
LOGI("DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty() || callback == nullptr) {
|
||||
LOGE("RegisterDeviceManagerFaCallback error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, callback);
|
||||
LOGI("DeviceManager::RegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(const std::string &pkgName)
|
||||
{
|
||||
LOGI("DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
LOGE("UnRegisterDeviceManagerFaCallback error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName);
|
||||
LOGI("DeviceManager::UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::VerifyAuthentication(const std::string &pkgName, const std::string &authPara,
|
||||
std::shared_ptr<VerifyAuthCallback> callback)
|
||||
{
|
||||
LOGI("DeviceManager::VerifyAuthentication start, pkgName: %s", pkgName.c_str());
|
||||
if (!isSystemAppCalling()) {
|
||||
LOGI("the caller is not a system app");
|
||||
return DM_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (pkgName.empty()) {
|
||||
LOGE("VerifyAuthentication error: Invalid para");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
DeviceManagerNotify::GetInstance().RegisterVerifyAuthenticationCallback(pkgName, authPara, callback);
|
||||
|
||||
std::shared_ptr<IpcVerifyAuthenticateReq> req = std::make_shared<IpcVerifyAuthenticateReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetAuthPara(authPara);
|
||||
if (ipcClientProxy_->SendRequest(CHECK_AUTHENTICATION, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "CheckAuthentication Failed with ret %d", ret);
|
||||
int32_t ret = ipcClientProxy_->SendRequest(VERIFY_AUTHENTICATION, req, rsp);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("VerifyAuthentication error: Send Request failed ret: %d", ret);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("VerifyAuthentication error: Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().RegisterCheckAuthenticationCallback(pkgName, authPara, callback);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::CheckAuthentication completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
LOGI("VerifyAuthentication completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::GetAuthenticationParam(std::string &pkgName, DmAuthParam &authParam)
|
||||
int32_t DeviceManagerImpl::GetFaParam(const std::string &pkgName, DmAuthParam &dmFaParam)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::GetAuthenticationParam start");
|
||||
std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
|
||||
std::shared_ptr<IpcGetAuthParamRsp> rsp = std::make_shared<IpcGetAuthParamRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
if (ipcClientProxy_->SendRequest(SERVER_GET_AUTHENTCATION_INFO, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
LOGI("DeviceManager::GetFaParam start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
LOGE("VerifyAuthentication failed, pkgName is empty");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
authParam = rsp->GetAuthParam();
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
|
||||
std::shared_ptr<IpcGetDmFaParamRsp> rsp = std::make_shared<IpcGetDmFaParamRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
|
||||
if (ipcClientProxy_->SendRequest(SERVER_GET_DMFA_INFO, req, rsp) != DM_OK) {
|
||||
LOGI("DeviceManagerImpl::GetFaParam start 2");
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
dmFaParam = rsp->GetDmAuthParam();
|
||||
LOGI("GetFaParam completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::SetUserOperation(std::string &pkgName, int32_t action)
|
||||
int32_t DeviceManagerImpl::SetUserOperation(const std::string &pkgName, int32_t action)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::SetUserOperation start");
|
||||
LOGI("DeviceManager::SetUserOperation start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
LOGE("VerifyAuthentication failed, pkgName is empty");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcGetOperationReq> req = std::make_shared<IpcGetOperationReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetOperation(action);
|
||||
|
||||
if (ipcClientProxy_->SendRequest(SERVER_USER_AUTHORIZATION_OPERATION, req, rsp) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
if (ipcClientProxy_->SendRequest(SERVER_USER_AUTH_OPERATION, req, rsp) != DM_OK) {
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "CheckAuthentication Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("CheckAuthentication Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("SetUserOperation completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::RegisterDeviceManagerFaCallback(std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback)
|
||||
int32_t DeviceManagerImpl::GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
|
||||
std::string &udid)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::RegisterDeviceManagerFaCallback start, pkgName: %s", packageName.c_str());
|
||||
if (packageName.empty() || callback == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(packageName, callback);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::RegisterDevStateCallback completed, pkgName: %s", packageName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::UnRegisterDeviceManagerFaCallback(std::string &pkgName)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDeviceManagerFaCallback start, pkgName: %s", pkgName.c_str());
|
||||
if (pkgName.empty()) {
|
||||
DMLOG(DM_LOG_ERROR, "Invalid para");
|
||||
return DEVICEMANAGER_INVALID_VALUE;
|
||||
LOGE("VerifyAuthentication failed, pkgName is empty");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::UnRegisterDevStateCallback completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
|
||||
std::shared_ptr<IpcGetInfoByNetWorkReq> req = std::make_shared<IpcGetInfoByNetWorkReq>();
|
||||
std::shared_ptr<IpcGetInfoByNetWorkRsp> rsp = std::make_shared<IpcGetInfoByNetWorkRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetNetWorkId(netWorkId);
|
||||
|
||||
if (ipcClientProxy_->SendRequest(GET_UDID_BY_NETWORK, req, rsp) != DM_OK) {
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("CheckAuthentication Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
udid = rsp->GetUdid();
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t DeviceManagerImpl::GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId,
|
||||
std::string &uuid)
|
||||
{
|
||||
if (pkgName.empty()) {
|
||||
LOGE("VerifyAuthentication failed, pkgName is empty");
|
||||
return DM_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcGetInfoByNetWorkReq> req = std::make_shared<IpcGetInfoByNetWorkReq>();
|
||||
std::shared_ptr<IpcGetInfoByNetWorkRsp> rsp = std::make_shared<IpcGetInfoByNetWorkRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetNetWorkId(netWorkId);
|
||||
|
||||
if (ipcClientProxy_->SendRequest(GET_UUID_BY_NETWORK, req, rsp) != DM_OK) {
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
int32_t ret = rsp->GetErrCode();
|
||||
if (ret != DM_OK) {
|
||||
LOGE("CheckAuthentication Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
uuid = rsp->GetUuid();
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,23 +15,23 @@
|
||||
|
||||
#include "ipc_client_proxy.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_errno.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
int32_t IpcClientProxy::Init(std::string &pkgName)
|
||||
int32_t IpcClientProxy::Init(const std::string &pkgName)
|
||||
{
|
||||
if (ipcClientManager_ == nullptr) {
|
||||
return DEVICEMANAGER_NULLPTR;
|
||||
return DM_POINT_NULL;
|
||||
}
|
||||
return ipcClientManager_->Init(pkgName);
|
||||
}
|
||||
|
||||
int32_t IpcClientProxy::UnInit(std::string &pkgName)
|
||||
int32_t IpcClientProxy::UnInit(const std::string &pkgName)
|
||||
{
|
||||
if (ipcClientManager_ == nullptr) {
|
||||
return DEVICEMANAGER_NULLPTR;
|
||||
return DM_POINT_NULL;
|
||||
}
|
||||
return ipcClientManager_->UnInit(pkgName);
|
||||
}
|
||||
@@ -39,8 +39,8 @@ int32_t IpcClientProxy::UnInit(std::string &pkgName)
|
||||
int32_t IpcClientProxy::SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
if (req == nullptr || rsp == nullptr || ipcClientManager_ == nullptr) {
|
||||
DMLOG(DM_LOG_INFO, "req,rsp or ipc client is null");
|
||||
return DEVICEMANAGER_NULLPTR;
|
||||
LOGI("req,rsp or ipc client is null");
|
||||
return DM_POINT_NULL;
|
||||
}
|
||||
return ipcClientManager_->SendRequest(cmdCode, req, rsp);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,27 +15,26 @@
|
||||
|
||||
#include "ipc_client_manager.h"
|
||||
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_client_stub.h"
|
||||
#include "ipc_register_listener_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
int32_t IpcClientManager::Init(std::string &pkgName)
|
||||
int32_t IpcClientManager::Init(const std::string &pkgName)
|
||||
{
|
||||
if (IsInit(pkgName)) {
|
||||
DMLOG(DM_LOG_INFO, "already init");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("already init");
|
||||
return DM_OK;
|
||||
}
|
||||
if (serverProxy_.Init() != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "server proxy init failed.");
|
||||
return DEVICEMANAGER_INIT_FAILED;
|
||||
if (serverProxy_.Init() != DM_OK) {
|
||||
LOGE("server proxy init failed.");
|
||||
return DM_INIT_FAILED;
|
||||
}
|
||||
if (IpcClientStub::GetInstance().Init() != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "ipcclientstub init failed.");
|
||||
return DEVICEMANAGER_INIT_FAILED;
|
||||
if (IpcClientStub::GetInstance().Init() != DM_OK) {
|
||||
LOGE("ipcclientstub init failed.");
|
||||
return DM_INIT_FAILED;
|
||||
}
|
||||
|
||||
std::shared_ptr<IpcRegisterListenerReq> req = std::make_shared<IpcRegisterListenerReq>();
|
||||
@@ -43,48 +42,48 @@ int32_t IpcClientManager::Init(std::string &pkgName)
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetSvcIdentity(IpcClientStub::GetInstance().GetSvcIdentity());
|
||||
int32_t ret = serverProxy_.SendCmd(REGISTER_DEVICE_MANAGER_LISTENER, req, rsp);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManager: RegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("InitDeviceManager: RegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager::InitDeviceManager completed, pkgName: %s, ret=%d", pkgName.c_str(), ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("DeviceManager::InitDeviceManager completed, pkgName: %s, ret=%d", pkgName.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
packageInitSet_.emplace(pkgName);
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::UnInit(std::string &pkgName)
|
||||
int32_t IpcClientManager::UnInit(const std::string &pkgName)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "UnInitDeviceManager in, pkgName %s", pkgName.c_str());
|
||||
LOGI("UnInitDeviceManager in, pkgName %s", pkgName.c_str());
|
||||
if (!IsInit(pkgName)) {
|
||||
return DEVICEMANAGER_FAILED;
|
||||
return DM_FAILED;
|
||||
}
|
||||
std::shared_ptr<IpcReq> req = std::make_shared<IpcReq>();
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
int32_t ret = serverProxy_.SendCmd(UNREGISTER_DEVICE_MANAGER_LISTENER, req, rsp);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "UnRegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnRegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
packageInitSet_.erase(pkgName);
|
||||
DMLOG(DM_LOG_INFO, "UnInitDeviceManager SUCCESS");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("UnInitDeviceManager SUCCESS");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
std::string pkgName = req->GetPkgName();
|
||||
if (!IsInit(pkgName)) {
|
||||
return DEVICEMANAGER_SERVICE_NOT_READY;
|
||||
return DM_SERVICE_NOT_READY;
|
||||
}
|
||||
return serverProxy_.SendCmd(cmdCode, req, rsp);
|
||||
}
|
||||
|
||||
bool IpcClientManager::IsInit(std::string &pkgName)
|
||||
bool IpcClientManager::IsInit(const std::string &pkgName)
|
||||
{
|
||||
return (packageInitSet_.count(pkgName) > 0);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,21 +15,18 @@
|
||||
|
||||
#include "ipc_client_server_proxy.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "ipc_def.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace {
|
||||
const int32_t INVALID_CB_ID = 0xFF;
|
||||
}
|
||||
static uint32_t g_deathCbId = INVALID_CB_ID;
|
||||
static SvcIdentity g_svcIdentity;
|
||||
static std::shared_ptr<IpcRsp> pCurRsp;
|
||||
const int32_t INVALID_CB_ID = 0xFF;
|
||||
|
||||
void __attribute__((weak)) HOS_SystemInit(void)
|
||||
{
|
||||
@@ -37,29 +34,29 @@ void __attribute__((weak)) HOS_SystemInit(void)
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t DMDeathCallback(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void *arg)
|
||||
int32_t DmDeathCallback(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void *arg)
|
||||
{
|
||||
(void)ctx;
|
||||
(void)ipcMsg;
|
||||
(void)data;
|
||||
(void)arg;
|
||||
DMLOG(DM_LOG_INFO, "ATTENTION SERVICE (%s) DEAD !!!\n", DEVICE_MANAGER_SERVICE_NAME);
|
||||
LOGI("ATTENTION SERVICE (%s) DEAD !!!\n", DEVICE_MANAGER_SERVICE_NAME);
|
||||
UnregisterDeathCallback(g_svcIdentity, g_deathCbId);
|
||||
g_deathCbId = INVALID_CB_ID;
|
||||
g_svcIdentity.handle = 0;
|
||||
g_svcIdentity.token = 0;
|
||||
g_svcIdentity.cookie = 0;
|
||||
DeviceManagerNotify::GetInstance().OnRemoteDied();
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
static int32_t SendCmdResultCb(IOwner owner, int32_t code, IpcIo *reply)
|
||||
{
|
||||
(void)code;
|
||||
int32_t cmdCode = *(int32_t *)owner;
|
||||
DMLOG(DM_LOG_INFO, "SendCmdResultCb code:%d", cmdCode);
|
||||
LOGI("SendCmdResultCb code:%d", cmdCode);
|
||||
(void)IpcCmdRegister::GetInstance().ReadResponse(cmdCode, *reply, pCurRsp);
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
IClientProxy *IpcClientServerProxy::GetServerProxy(void)
|
||||
@@ -67,14 +64,14 @@ IClientProxy *IpcClientServerProxy::GetServerProxy(void)
|
||||
IClientProxy *clientProxy = nullptr;
|
||||
IUnknown *iUnknown = nullptr;
|
||||
|
||||
DMLOG(DM_LOG_INFO, "start get client proxy");
|
||||
LOGI("start get client proxy");
|
||||
iUnknown = SAMGR_GetInstance()->GetDefaultFeatureApi(DEVICE_MANAGER_SERVICE_NAME);
|
||||
if (iUnknown == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (iUnknown->QueryInterface(iUnknown, CLIENT_PROXY_VER, (void **)&clientProxy) != DEVICEMANAGER_OK ||
|
||||
if (iUnknown->QueryInterface(iUnknown, CLIENT_PROXY_VER, (void **)&clientProxy) != DM_OK ||
|
||||
clientProxy == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "QueryInterface failed");
|
||||
LOGE("QueryInterface failed");
|
||||
}
|
||||
return clientProxy;
|
||||
}
|
||||
@@ -83,53 +80,53 @@ int IpcClientServerProxy::RegisterServerDeathCb(void)
|
||||
{
|
||||
g_svcIdentity = SAMGR_GetRemoteIdentity(DEVICE_MANAGER_SERVICE_NAME, nullptr);
|
||||
g_deathCbId = INVALID_CB_ID;
|
||||
if (RegisterDeathCallback(nullptr, g_svcIdentity, DMDeathCallback, nullptr, &g_deathCbId) != EC_SUCCESS) {
|
||||
DMLOG(DM_LOG_ERROR, "reg death callback failed");
|
||||
return DEVICEMANAGER_FAILED;
|
||||
if (RegisterDeathCallback(nullptr, g_svcIdentity, DmDeathCallback, nullptr, &g_deathCbId) != EC_SUCCESS) {
|
||||
LOGE("reg death callback failed");
|
||||
return DM_FAILED;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "SendCmd:%d", cmdCode);
|
||||
LOGI("SendCmd:%d", cmdCode);
|
||||
uint8_t data[MAX_DM_IPC_LEN] = {0};
|
||||
IpcIo request;
|
||||
|
||||
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_FAILED;
|
||||
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DM_OK) {
|
||||
return DM_FAILED;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
pCurRsp = rsp;
|
||||
if (serviceProxy_ != nullptr &&
|
||||
serviceProxy_->Invoke(serviceProxy_, cmdCode, &request, &cmdCode, SendCmdResultCb) != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "serviceProxy_ invoke failed.");
|
||||
return DEVICEMANAGER_FAILED;
|
||||
LOGE("serviceProxy_ invoke failed.");
|
||||
return DM_FAILED;
|
||||
}
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "SendCmd:%d end", cmdCode);
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("SendCmd:%d end", cmdCode);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientServerProxy::Init(void)
|
||||
{
|
||||
if (serviceProxy_ != nullptr) {
|
||||
DMLOG(DM_LOG_INFO, "ServerProxy already Init");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("ServerProxy already Init");
|
||||
return DM_OK;
|
||||
}
|
||||
HOS_SystemInit();
|
||||
serviceProxy_ = GetServerProxy();
|
||||
if (serviceProxy_ == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "get ipc client proxy failed");
|
||||
return DEVICEMANAGER_FAILED;
|
||||
LOGE("get ipc client proxy failed");
|
||||
return DM_FAILED;
|
||||
}
|
||||
if (RegisterServerDeathCb() != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "register server death cb failed");
|
||||
return DEVICEMANAGER_FAILED;
|
||||
if (RegisterServerDeathCb() != DM_OK) {
|
||||
LOGE("register server death cb failed");
|
||||
return DM_FAILED;
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "ServerProxyInit ok");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("ServerProxyInit ok");
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,12 +15,11 @@
|
||||
|
||||
#include "ipc_client_stub.h"
|
||||
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "ipc_def.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -30,16 +29,16 @@ static int32_t ClientIpcInterfaceMsgHandle(const IpcContext *ctx, void *ipcMsg,
|
||||
{
|
||||
(void)arg;
|
||||
if (ipcMsg == nullptr || io == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "invalid param");
|
||||
return DEVICEMANAGER_INVALID_PARAM;
|
||||
LOGE("invalid param");
|
||||
return DM_INPUT_PARA_EMPTY;
|
||||
}
|
||||
|
||||
uint32_t code = 0;
|
||||
GetCode(ipcMsg, &code);
|
||||
int32_t errCode = DEVICEMANAGER_OK;
|
||||
int32_t errCode = DM_OK;
|
||||
|
||||
errCode = IpcCmdRegister::GetInstance().OnIpcCmd(code, *io);
|
||||
DMLOG(DM_LOG_INFO, "receive ipc transact code:%u, retCode=%d", code, errCode);
|
||||
LOGI("receive ipc transact code:%u, retCode=%d", code, errCode);
|
||||
FreeBuffer(ctx, ipcMsg);
|
||||
return errCode;
|
||||
}
|
||||
@@ -48,14 +47,14 @@ int32_t IpcClientStub::Init()
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (bInit) {
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
if (RegisterIpcCallback(ClientIpcInterfaceMsgHandle, 0, IPC_WAIT_FOREVER, &clientIdentity_, nullptr) != 0) {
|
||||
DMLOG(DM_LOG_ERROR, "register ipc cb failed");
|
||||
return DEVICEMANAGER_FAILED;
|
||||
LOGE("register ipc cb failed");
|
||||
return DM_FAILED;
|
||||
}
|
||||
bInit = true;
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,32 +13,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "device_manager_notify.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_log.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "ipc_authenticate_device_req.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_def.h"
|
||||
|
||||
#include "securec.h"
|
||||
#include "constants.h"
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
|
||||
#include "ipc_get_local_device_info_rsp.h"
|
||||
#include "ipc_get_trustdevice_req.h"
|
||||
#include "ipc_get_trustdevice_rsp.h"
|
||||
#include "ipc_register_listener_req.h"
|
||||
#include "ipc_start_discovery_req.h"
|
||||
#include "ipc_stop_discovery_req.h"
|
||||
#include "ipc_get_trustdevice_req.h"
|
||||
#include "ipc_get_trustdevice_rsp.h"
|
||||
#include "ipc_authenticate_device_req.h"
|
||||
#include "ipc_check_authenticate_req.h"
|
||||
#include "ipc_get_authenticationparam_rsp.h"
|
||||
#include "ipc_set_useroperation_req.h"
|
||||
#include "ipc_verify_authenticate_req.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcRegisterListenerReq> pReq = std::static_pointer_cast<IpcRegisterListenerReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
@@ -47,47 +42,47 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBa
|
||||
IpcIoInit(&request, buffer, buffLen, 1);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushSvc(&request, &svcIdentity);
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
{
|
||||
std::string pkgName = pBaseReq->GetPkgName();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(UNREGISTER_DEVICE_MANAGER_LISTENER, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcGetTrustdeviceReq> pReq = std::static_pointer_cast<IpcGetTrustdeviceReq>(pBaseReq);
|
||||
std::shared_ptr<IpcGetTrustDeviceReq> pReq = std::static_pointer_cast<IpcGetTrustDeviceReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string extra = pReq->GetExtra();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushString(&request, extra.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetTrustdeviceRsp> pRsp = std::static_pointer_cast<IpcGetTrustdeviceRsp>(pBaseRsp);
|
||||
std::shared_ptr<IpcGetTrustDeviceRsp> pRsp = std::static_pointer_cast<IpcGetTrustDeviceRsp>(pBaseRsp);
|
||||
int32_t deviceNum = IpcIoPopInt32(&reply);
|
||||
uint32_t deviceTotalSize = deviceNum * (int32_t)sizeof(DmDeviceInfo);
|
||||
|
||||
@@ -95,9 +90,9 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptr<IpcRsp
|
||||
std::vector<DmDeviceInfo> deviceInfoVec;
|
||||
DmDeviceInfo *pDmDeviceinfo = (DmDeviceInfo *)IpcIoPopFlatObj(&reply, &deviceTotalSize);
|
||||
if (pDmDeviceinfo == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "GetTrustedDeviceList read node info failed!");
|
||||
pRsp->SetErrCode(DEVICEMANAGER_IPC_TRANSACTION_FAILED);
|
||||
return DEVICEMANAGER_IPC_TRANSACTION_FAILED;
|
||||
LOGE("GetTrustedDeviceList read node info failed!");
|
||||
pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED);
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
for (int32_t i = 0; i < deviceNum; ++i) {
|
||||
pDmDeviceinfo = pDmDeviceinfo + i;
|
||||
@@ -106,30 +101,52 @@ ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, IpcIo &reply, std::shared_ptr<IpcRsp
|
||||
pRsp->SetDeviceVec(deviceInfoVec);
|
||||
}
|
||||
pRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(GET_LOCAL_DEVICE_INFO, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetLocalDeviceInfoRsp> pRsp = std::static_pointer_cast<IpcGetLocalDeviceInfoRsp>(pBaseRsp);
|
||||
|
||||
uint32_t size = 0;
|
||||
DmDeviceInfo *dmDeviceInfo = (DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
|
||||
if (dmDeviceInfo != nullptr) {
|
||||
pRsp->SetLocalDeviceInfo(*dmDeviceInfo);
|
||||
}
|
||||
pRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcStartDiscoveryReq> pReq = std::static_pointer_cast<IpcStartDiscoveryReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string extra = pReq->GetExtra();
|
||||
const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushString(&request, extra.c_str());
|
||||
IpcIoPushFlatObj(&request, &dmSubscribeInfo, sizeof(DmSubscribeInfo));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(START_DEVICE_DISCOVER, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcStopDiscoveryReq> pReq = std::static_pointer_cast<IpcStopDiscoveryReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
@@ -138,21 +155,21 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, IpcIo
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushUint16(&request, subscribeId);
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcAuthenticateDeviceReq> pReq = std::static_pointer_cast<IpcAuthenticateDeviceReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string extra = pReq->GetExtra();
|
||||
std::string extra = pReq->GetExtra();
|
||||
DmDeviceInfo deviceInfo = pReq->GetDeviceInfo();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
@@ -160,30 +177,49 @@ ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr<IpcReq> pBaseReq, IpcIo
|
||||
IpcIoPushString(&request, extra.c_str());
|
||||
IpcIoPushFlatObj(&request, &deviceInfo, sizeof(DmDeviceInfo));
|
||||
// L1 暂时没有考虑appimage校验(8k限制)
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(AUTHENTICATE_DEVICE, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(CHECK_AUTHENTICATION, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcCheckAuthenticateReq> pReq = std::static_pointer_cast<IpcCheckAuthenticateReq>(pBaseReq);
|
||||
std::shared_ptr<IpcVerifyAuthenticateReq> pReq = std::static_pointer_cast<IpcVerifyAuthenticateReq>(pBaseReq);
|
||||
std::string authPara = pReq->GetAuthPara();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, authPara.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(CHECK_AUTHENTICATION, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
ON_IPC_READ_RESPONSE(VERIFY_AUTHENTICATION, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr<IpcReq> pBaseReq, IpcIo &request, uint8_t *buffer,
|
||||
size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcGetOperationReq> pReq = std::static_pointer_cast<IpcGetOperationReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
int32_t action = pReq->GetOperation();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushInt32(&request, action);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_USER_AUTH_OPERATION, IpcIo &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply)
|
||||
@@ -192,9 +228,9 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply)
|
||||
std::string pkgName = (const char *)IpcIoPopString(&reply, &len);
|
||||
DmDeviceState deviceState = static_cast<DmDeviceState>(IpcIoPopInt32(&reply));
|
||||
uint32_t size;
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo*)IpcIoPopFlatObj(&reply, &size);
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
|
||||
if (pkgName == "" || len == 0 || deviceInfo == NULL) {
|
||||
DMLOG(DM_LOG_ERROR, "OnDeviceOnline, get para failed");
|
||||
LOGE("OnDeviceOnline, get para failed");
|
||||
return;
|
||||
}
|
||||
switch (deviceState) {
|
||||
@@ -208,7 +244,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply)
|
||||
DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, *deviceInfo);
|
||||
break;
|
||||
default:
|
||||
DMLOG(DM_LOG_ERROR, "unknown device state:%d", deviceState);
|
||||
LOGE("unknown device state:%d", deviceState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -219,9 +255,9 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, IpcIo &reply)
|
||||
std::string pkgName = (const char *)IpcIoPopString(&reply, &len);
|
||||
uint16_t subscribeId = IpcIoPopUint16(&reply);
|
||||
uint32_t size;
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo*)IpcIoPopFlatObj(&reply, &size);
|
||||
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
|
||||
if (pkgName == "" || len == 0 || deviceInfo == NULL) {
|
||||
DMLOG(DM_LOG_ERROR, "OnDeviceChanged, get para failed");
|
||||
LOGE("OnDeviceChanged, get para failed");
|
||||
return;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, *deviceInfo);
|
||||
@@ -235,13 +271,13 @@ ON_IPC_CMD(SERVER_DISCOVER_FINISH, IpcIo &reply)
|
||||
int32_t failedReason = IpcIoPopInt32(&reply);
|
||||
|
||||
if (pkgName == "" || len == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "OnDiscoverySuccess, get para failed");
|
||||
LOGE("OnDiscoverySuccess, get para failed");
|
||||
return;
|
||||
}
|
||||
if (failedReason == DEVICEMANAGER_OK) {
|
||||
if (failedReason == DM_OK) {
|
||||
DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId);
|
||||
} else {
|
||||
DeviceManagerNotify::GetInstance().OnDiscoverFailed(pkgName, subscribeId, failedReason);
|
||||
DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,18 +287,17 @@ ON_IPC_CMD(SERVER_AUTH_RESULT, IpcIo &reply)
|
||||
std::string pkgName = (const char *)IpcIoPopString(&reply, &len);
|
||||
size_t devIdLen = 0;
|
||||
std::string deviceId = (const char *)IpcIoPopString(&reply, &devIdLen);
|
||||
int32_t pinToken = IpcIoPopInt32(&reply);
|
||||
int32_t status = IpcIoPopInt32(&reply);
|
||||
int32_t reason = IpcIoPopInt32(&reply);
|
||||
|
||||
if (pkgName == "" || len == 0 || deviceId == "" || devIdLen == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "OnAuthResult, get para failed");
|
||||
LOGE("OnAuthResult, get para failed");
|
||||
return;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, pinToken, status, reason);
|
||||
DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, nullptr, status, reason);
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_CHECK_AUTH_RESULT, IpcIo &reply)
|
||||
ON_IPC_CMD(SERVER_VERIFY_AUTH_RESULT, IpcIo &reply)
|
||||
{
|
||||
size_t len = 0;
|
||||
std::string pkgName = (const char *)IpcIoPopString(&reply, &len);
|
||||
@@ -272,80 +307,13 @@ ON_IPC_CMD(SERVER_CHECK_AUTH_RESULT, IpcIo &reply)
|
||||
int32_t flag = IpcIoPopInt32(&reply);
|
||||
|
||||
if (pkgName == "" || len == 0 || deviceId == "" || devIdLen == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "OnAuthResult, get para failed");
|
||||
LOGE("OnAuthResult, get para failed");
|
||||
return;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().OnCheckAuthResult(pkgName, deviceId, resultCode, flag);
|
||||
DeviceManagerNotify::GetInstance().OnVerifyAuthResult(pkgName, deviceId, resultCode, flag);
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_GET_AUTHENTCATION_INFO, std::shared_ptr<IpcReq> pBaseReq, IpcIo& request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcReq> pReq = std::static_pointer_cast<IpcReq>(pBaseReq);
|
||||
std::string packagename = pReq->GetPkgName();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, packagename.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_GET_AUTHENTCATION_INFO, IpcIo& reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetAuthParamRsp> pRsp = std::static_pointer_cast<IpcGetAuthParamRsp>(pBaseRsp);
|
||||
DmAuthParam authParam = {0};
|
||||
authParam.direction = IpcIoPopInt32(&reply);
|
||||
authParam.authType = IpcIoPopInt32(&reply);
|
||||
if (authParam.direction == AUTH_SESSION_SIDE_CLIENT) {
|
||||
authParam.pinToken = IpcIoPopInt32(&reply);
|
||||
pRsp->SetAuthParam(authParam);
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
size_t PackagerNamelen = 0;
|
||||
authParam.packageName = strdup((const char *)IpcIoPopString(&reply, &PackagerNamelen));
|
||||
size_t appNameLen = 0;
|
||||
authParam.appName = strdup((const char *)IpcIoPopString(&reply, &appNameLen));
|
||||
size_t appDesLen = 0;
|
||||
authParam.appDescription = strdup((const char *)IpcIoPopString(&reply, &appDesLen));
|
||||
authParam.business = IpcIoPopInt32(&reply);
|
||||
authParam.pincode = IpcIoPopInt32(&reply);
|
||||
|
||||
uint32_t appIconLen = IpcIoPopInt32(&reply);
|
||||
uint8_t *appIconBuffer = nullptr;
|
||||
uint32_t appThumbnailLen = IpcIoPopInt32(&reply);
|
||||
uint8_t *appThumbBuffer = nullptr;
|
||||
|
||||
if (appIconLen > 0) {
|
||||
appIconBuffer = (uint8_t *)IpcIoPopFlatObj(&reply, &appIconLen);
|
||||
}
|
||||
if (appThumbnailLen > 0) {
|
||||
appThumbBuffer = (uint8_t *)IpcIoPopFlatObj(&reply, &appThumbnailLen);
|
||||
}
|
||||
|
||||
authParam.imageinfo.Reset(appIconBuffer, appIconLen, appThumbBuffer, appThumbnailLen);
|
||||
pRsp->SetAuthParam(authParam);
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_USER_AUTHORIZATION_OPERATION, std::shared_ptr<IpcReq> pBaseReq, IpcIo& request,
|
||||
uint8_t *buffer, size_t buffLen)
|
||||
{
|
||||
std::shared_ptr<IpcGetOperationReq> pReq = std::static_pointer_cast<IpcGetOperationReq>(pBaseReq);
|
||||
std::string pkgName= pReq->GetPkgName();
|
||||
int32_t action = pReq->GetOperation();
|
||||
|
||||
IpcIoInit(&request, buffer, buffLen, 0);
|
||||
IpcIoPushString(&request, pkgName.c_str());
|
||||
IpcIoPushInt32(&request, action);
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_USER_AUTHORIZATION_OPERATION, IpcIo& reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(IpcIoPopInt32(&reply));
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DEVICEMANAGER_FA_NOTIFY, IpcIo &reply)
|
||||
ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, IpcIo &reply)
|
||||
{
|
||||
size_t len = 0;
|
||||
std::string packagename = (const char *)IpcIoPopString(&reply, &len);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,68 +15,67 @@
|
||||
|
||||
#include "ipc_client_manager.h"
|
||||
|
||||
#include "device_manager_notify.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_client_stub.h"
|
||||
#include "ipc_register_listener_req.h"
|
||||
#include "ipc_remote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "ipc_register_listener_req.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DmDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
(void)remote;
|
||||
DMLOG(DM_LOG_WARN, "DmDeathRecipient : OnRemoteDied");
|
||||
LOGW("DmDeathRecipient : OnRemoteDied");
|
||||
DeviceManagerNotify::GetInstance().OnRemoteDied();
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::ClientInit()
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "InitDeviceManagerService start");
|
||||
LOGI("InitDeviceManagerService start");
|
||||
if (dmInterface_ != nullptr) {
|
||||
DMLOG(DM_LOG_INFO, "DeviceManagerService Already Init");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("DeviceManagerService Already Init");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgr == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "Get SystemAbilityManager Failed");
|
||||
return DEVICEMANAGER_SERVICE_NOT_READY;
|
||||
LOGE("Get SystemAbilityManager Failed");
|
||||
return DM_SERVICE_NOT_READY;
|
||||
}
|
||||
|
||||
auto object = samgr->CheckSystemAbility(DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID);
|
||||
if (object == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "Get DeviceManager SystemAbility Failed");
|
||||
return DEVICEMANAGER_SERVICE_NOT_READY;
|
||||
LOGE("Get DeviceManager SystemAbility Failed");
|
||||
return DM_SERVICE_NOT_READY;
|
||||
}
|
||||
|
||||
if (dmRecipient_ == nullptr) {
|
||||
dmRecipient_ = sptr<DmDeathRecipient>(new DmDeathRecipient());
|
||||
}
|
||||
if (!object->AddDeathRecipient(dmRecipient_)) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManagerService: AddDeathRecipient Failed");
|
||||
LOGE("InitDeviceManagerService: AddDeathRecipient Failed");
|
||||
}
|
||||
dmInterface_ = iface_cast<IpcRemoteBroker>(object);
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager::InitDeviceManagerService completed");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("DeviceManager::InitDeviceManagerService completed");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::Init(std::string &pkgName)
|
||||
int32_t IpcClientManager::Init(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
int32_t ret = ClientInit();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManager Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("InitDeviceManager Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
if (dmListener_.count(pkgName) > 0) {
|
||||
DMLOG(DM_LOG_INFO, "dmListener_ Already Init");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("dmListener_ Already Init");
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
sptr<IpcClientStub> listener = sptr<IpcClientStub>(new IpcClientStub());
|
||||
@@ -85,25 +84,25 @@ int32_t IpcClientManager::Init(std::string &pkgName)
|
||||
req->SetPkgName(pkgName);
|
||||
req->SetListener(listener);
|
||||
ret = dmInterface_->SendCmd(REGISTER_DEVICE_MANAGER_LISTENER, req, rsp);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "InitDeviceManager: RegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("InitDeviceManager: RegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = rsp->GetErrCode();
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
if (ret != DM_OK) {
|
||||
return ret;
|
||||
}
|
||||
dmListener_[pkgName] = listener;
|
||||
DMLOG(DM_LOG_INFO, "completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::UnInit(std::string &pkgName)
|
||||
int32_t IpcClientManager::UnInit(const std::string &pkgName)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "in, pkgName %s", pkgName.c_str());
|
||||
LOGI("in, pkgName %s", pkgName.c_str());
|
||||
if (dmInterface_ == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager not Init");
|
||||
return DEVICEMANAGER_SERVICE_NOT_READY;
|
||||
LOGE("DeviceManager not Init");
|
||||
return DM_SERVICE_NOT_READY;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
@@ -112,8 +111,8 @@ int32_t IpcClientManager::UnInit(std::string &pkgName)
|
||||
std::shared_ptr<IpcRsp> rsp = std::make_shared<IpcRsp>();
|
||||
req->SetPkgName(pkgName);
|
||||
int32_t ret = dmInterface_->SendCmd(UNREGISTER_DEVICE_MANAGER_LISTENER, req, rsp);
|
||||
if (ret != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "UnRegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
if (ret != DM_OK) {
|
||||
LOGE("UnRegisterDeviceManagerListener Failed with ret %d", ret);
|
||||
return ret;
|
||||
}
|
||||
dmListener_.erase(pkgName);
|
||||
@@ -122,28 +121,30 @@ int32_t IpcClientManager::UnInit(std::string &pkgName)
|
||||
dmInterface_ = nullptr;
|
||||
dmRecipient_ = nullptr;
|
||||
}
|
||||
DMLOG(DM_LOG_INFO, "completed, pkgName: %s", pkgName.c_str());
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("completed, pkgName: %s", pkgName.c_str());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
LOGI("IpcClientManager::SendRequest in");
|
||||
std::string pkgName = req->GetPkgName();
|
||||
if (!IsInit(pkgName)) {
|
||||
return DEVICEMANAGER_SERVICE_NOT_READY;
|
||||
LOGE("IpcClientManager::SendRequest DM_SERVICE_NOT_READY");
|
||||
return DM_SERVICE_NOT_READY;
|
||||
}
|
||||
return dmInterface_->SendCmd(cmdCode, req, rsp);
|
||||
}
|
||||
|
||||
bool IpcClientManager::IsInit(std::string &pkgName)
|
||||
bool IpcClientManager::IsInit(const std::string &pkgName)
|
||||
{
|
||||
if (dmInterface_ == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager not Init");
|
||||
LOGE("DeviceManager not Init");
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (dmListener_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "dmListener_ not Init for %s", pkgName.c_str());
|
||||
LOGE("dmListener_ not Init for %s", pkgName.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,31 +15,30 @@
|
||||
|
||||
#include "ipc_client_server_proxy.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_types.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_errno.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "remote service null");
|
||||
return DEVICEMANAGER_NULLPTR;
|
||||
LOGE("remote service null");
|
||||
return DM_POINT_NULL;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_FAILED;
|
||||
if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) {
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(cmdCode, data, reply, option) != DEVICEMANAGER_OK) {
|
||||
DMLOG(DM_LOG_ERROR, "SendRequest fail, cmd:%d", cmdCode);
|
||||
return DEVICEMANAGER_IPC_FAILED;
|
||||
if (remote->SendRequest(cmdCode, data, reply, option) != DM_OK) {
|
||||
LOGE("SendRequest fail, cmd:%d", cmdCode);
|
||||
return DM_IPC_SEND_REQUEST_FAILED;
|
||||
}
|
||||
return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,31 +15,28 @@
|
||||
|
||||
#include "ipc_client_stub.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
|
||||
#include "ipc_cmd_register.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_errno.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "code = %d, flags= %d.", code, option.GetFlags());
|
||||
if (IpcCmdRegister::GetInstance().OnIpcCmd(code, data, reply) == DEVICEMANAGER_OK) {
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGI("code = %d, flags= %d.", code, option.GetFlags());
|
||||
if (IpcCmdRegister::GetInstance().OnIpcCmd(code, data, reply) == DM_OK) {
|
||||
return DM_OK;
|
||||
}
|
||||
DMLOG(DM_LOG_WARN, "unsupport code: %d", code);
|
||||
LOGW("unsupport code: %d", code);
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr<IpcReq> req, std::shared_ptr<IpcRsp> rsp)
|
||||
{
|
||||
DMLOG(DM_LOG_ERROR, "error");
|
||||
return DEVICEMANAGER_OK;
|
||||
LOGE("error");
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,24 +13,28 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ipc_cmd_register.h"
|
||||
|
||||
#include "securec.h"
|
||||
#include "constants.h"
|
||||
#include "device_manager_errno.h"
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "dm_constants.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_log.h"
|
||||
#include "ipc_authenticate_device_req.h"
|
||||
#include "ipc_cmd_register.h"
|
||||
#include "ipc_def.h"
|
||||
#include "ipc_register_listener_req.h"
|
||||
#include "ipc_start_discovery_req.h"
|
||||
#include "ipc_stop_discovery_req.h"
|
||||
#include "ipc_get_dmfaparam_rsp.h"
|
||||
#include "ipc_get_info_by_network_req.h"
|
||||
#include "ipc_get_info_by_network_rsp.h"
|
||||
#include "ipc_get_local_device_info_rsp.h"
|
||||
#include "ipc_get_trustdevice_req.h"
|
||||
#include "ipc_get_trustdevice_rsp.h"
|
||||
#include "ipc_authenticate_device_req.h"
|
||||
#include "ipc_check_authenticate_req.h"
|
||||
#include "ipc_get_authenticationparam_rsp.h"
|
||||
#include "ipc_register_listener_req.h"
|
||||
#include "ipc_req.h"
|
||||
#include "ipc_rsp.h"
|
||||
#include "ipc_set_useroperation_req.h"
|
||||
#include "ipc_start_discovery_req.h"
|
||||
#include "ipc_stop_discovery_req.h"
|
||||
#include "ipc_unauthenticate_device_req.h"
|
||||
#include "ipc_verify_authenticate_req.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -40,75 +44,141 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBa
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
sptr<IRemoteObject> listener = pReq->GetListener();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
if (!data.WriteRemoteObject(listener)) {
|
||||
DMLOG(DM_LOG_ERROR, "write listener failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write listener failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(UNREGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::string pkgName = pBaseReq->GetPkgName();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write papam failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write papam failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(UNREGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(GET_TRUST_DEVICE_LIST, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcGetTrustdeviceReq> pReq = std::static_pointer_cast<IpcGetTrustdeviceReq>(pBaseReq);
|
||||
std::shared_ptr<IpcGetTrustDeviceReq> pReq = std::static_pointer_cast<IpcGetTrustDeviceReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string extra = pReq->GetExtra();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkg failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write pkg failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
if (!data.WriteString(extra)) {
|
||||
DMLOG(DM_LOG_ERROR, "write extra failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write extra failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_TRUST_DEVICE_LIST, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetTrustdeviceRsp> pRsp = std::static_pointer_cast<IpcGetTrustdeviceRsp>(pBaseRsp);
|
||||
std::shared_ptr<IpcGetTrustDeviceRsp> pRsp = std::static_pointer_cast<IpcGetTrustDeviceRsp>(pBaseRsp);
|
||||
int32_t deviceNum = reply.ReadInt32();
|
||||
int32_t deviceTotalSize = deviceNum * (int32_t)sizeof(DmDeviceInfo);
|
||||
if (deviceTotalSize > 0) {
|
||||
if (deviceNum > 0) {
|
||||
std::vector<DmDeviceInfo> deviceInfoVec;
|
||||
DmDeviceInfo *pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData(deviceTotalSize);
|
||||
if (pDmDeviceinfo == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "GetTrustedDeviceList read node info failed!");
|
||||
pRsp->SetErrCode(DEVICEMANAGER_IPC_TRANSACTION_FAILED);
|
||||
return DEVICEMANAGER_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
DmDeviceInfo *pDmDeviceinfo = nullptr;
|
||||
for (int32_t i = 0; i < deviceNum; ++i) {
|
||||
pDmDeviceinfo = pDmDeviceinfo + i;
|
||||
pDmDeviceinfo = nullptr;
|
||||
pDmDeviceinfo = (DmDeviceInfo *)reply.ReadRawData((int32_t)sizeof(DmDeviceInfo));
|
||||
if (pDmDeviceinfo == nullptr) {
|
||||
LOGE("GetTrustedDeviceList read node info failed!");
|
||||
pRsp->SetErrCode(DM_IPC_TRANSACTION_FAILED);
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
deviceInfoVec.emplace_back(*pDmDeviceinfo);
|
||||
}
|
||||
pRsp->SetDeviceVec(deviceInfoVec);
|
||||
}
|
||||
pRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(GET_LOCAL_DEVICE_INFO, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcReq> pReq = std::static_pointer_cast<IpcReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
return DM_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetLocalDeviceInfoRsp> pRsp = std::static_pointer_cast<IpcGetLocalDeviceInfoRsp>(pBaseRsp);
|
||||
DmDeviceInfo *localDeviceInfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo));
|
||||
if (localDeviceInfo == nullptr) {
|
||||
LOGE("write subscribe info failed");
|
||||
}
|
||||
pRsp->SetLocalDeviceInfo(*localDeviceInfo);
|
||||
pRsp->SetErrCode(reply.ReadInt32());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(GET_UDID_BY_NETWORK, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcGetInfoByNetWorkReq> pReq = std::static_pointer_cast<IpcGetInfoByNetWorkReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string netWorkId = pReq->GetNetWorkId();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
return DM_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteString(netWorkId)) {
|
||||
return DM_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_UDID_BY_NETWORK, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetInfoByNetWorkRsp> pRsp = std::static_pointer_cast<IpcGetInfoByNetWorkRsp>(pBaseRsp);
|
||||
pRsp->SetErrCode(reply.ReadInt32());
|
||||
pRsp->SetUdid(reply.ReadString());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(GET_UUID_BY_NETWORK, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcGetInfoByNetWorkReq> pReq = std::static_pointer_cast<IpcGetInfoByNetWorkReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string netWorkId = pReq->GetNetWorkId();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
return DM_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteString(netWorkId)) {
|
||||
return DM_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(GET_UUID_BY_NETWORK, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetInfoByNetWorkRsp> pRsp = std::static_pointer_cast<IpcGetInfoByNetWorkRsp>(pBaseRsp);
|
||||
pRsp->SetErrCode(reply.ReadInt32());
|
||||
pRsp->SetUuid(reply.ReadString());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
@@ -117,20 +187,20 @@ ON_IPC_SET_REQUEST(START_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, Mess
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
const DmSubscribeInfo dmSubscribeInfo = pReq->GetSubscribeInfo();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteRawData(&dmSubscribeInfo, sizeof(DmSubscribeInfo))) {
|
||||
DMLOG(DM_LOG_ERROR, "write subscribe info failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write subscribe info failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(START_DEVICE_DISCOVER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
@@ -139,83 +209,144 @@ ON_IPC_SET_REQUEST(STOP_DEVICE_DISCOVER, std::shared_ptr<IpcReq> pBaseReq, Messa
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
uint16_t subscribeId = pReq->GetSubscribeId();
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt16(subscribeId)) {
|
||||
DMLOG(DM_LOG_ERROR, "write subscribeId failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write subscribeId failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcAuthenticateDeviceReq> pReq = std::static_pointer_cast<IpcAuthenticateDeviceReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
std::string extra = pReq->GetExtra();
|
||||
std::string extra = pReq->GetExtra();
|
||||
int32_t authType = pReq->GetAuthType();
|
||||
DmDeviceInfo deviceInfo = pReq->GetDeviceInfo();
|
||||
DmAppImageInfo imageInfo = pReq->GetAppImageInfo();
|
||||
std::string deviceId = deviceInfo.deviceId;
|
||||
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteString(extra)) {
|
||||
DMLOG(DM_LOG_ERROR, "write extra failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
LOGE("write extra failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteRawData(&deviceInfo, sizeof(DmDeviceInfo))) {
|
||||
DMLOG(DM_LOG_ERROR, "write deviceInfo failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
if (!data.WriteString(deviceId)) {
|
||||
LOGE("write extra failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
int32_t appIconLen = imageInfo.GetAppIconLen();
|
||||
int32_t appThumbnailLen = imageInfo.GetAppThumbnailLen();
|
||||
if (!data.WriteInt32(appIconLen)) {
|
||||
DMLOG(DM_LOG_ERROR, "write imageinfo appicon len failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
if (!data.WriteInt32(authType)) {
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(appThumbnailLen)) {
|
||||
DMLOG(DM_LOG_ERROR, "write imageinfo appThumbnailLen failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
if (appIconLen > 0 && !data.WriteRawData(imageInfo.GetAppIcon(), appIconLen)) {
|
||||
DMLOG(DM_LOG_ERROR, "write imageinfo appIcon failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
if (appThumbnailLen > 0 && !data.WriteRawData(imageInfo.GetAppThumbnail(), appThumbnailLen)) {
|
||||
DMLOG(DM_LOG_ERROR, "write imageinfo appThumbnail failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(AUTHENTICATE_DEVICE, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(CHECK_AUTHENTICATION, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
ON_IPC_SET_REQUEST(UNAUTHENTICATE_DEVICE, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcCheckAuthenticateReq> pReq = std::static_pointer_cast<IpcCheckAuthenticateReq>(pBaseReq);
|
||||
std::string authPara = pReq->GetAuthPara();
|
||||
if (!data.WriteString(authPara)) {
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
std::shared_ptr<IpcUnAuthenticateDeviceReq> pReq = std::static_pointer_cast<IpcUnAuthenticateDeviceReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
DmDeviceInfo deviceInfo = pReq->GetDeviceInfo();
|
||||
std::string deviceId = deviceInfo.deviceId;
|
||||
if (!data.WriteString(pkgName)) {
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
if (!data.WriteString(deviceId)) {
|
||||
LOGE("write extra failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(CHECK_AUTHENTICATION, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
ON_IPC_READ_RESPONSE(UNAUTHENTICATE_DEVICE, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(VERIFY_AUTHENTICATION, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcVerifyAuthenticateReq> pReq = std::static_pointer_cast<IpcVerifyAuthenticateReq>(pBaseReq);
|
||||
std::string authPara = pReq->GetAuthPara();
|
||||
if (!data.WriteString(authPara)) {
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(VERIFY_AUTHENTICATION, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_GET_DMFA_INFO, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcReq> pReq = std::static_pointer_cast<IpcReq>(pBaseReq);
|
||||
std::string packagename = pReq->GetPkgName();
|
||||
if (!data.WriteString(packagename)) {
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_FLATTEN_OBJECT;
|
||||
}
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_GET_DMFA_INFO, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetDmFaParamRsp> pRsp = std::static_pointer_cast<IpcGetDmFaParamRsp>(pBaseRsp);
|
||||
DmAuthParam authParam;
|
||||
authParam.direction = reply.ReadInt32();
|
||||
authParam.authType = reply.ReadInt32();
|
||||
authParam.authToken = reply.ReadString();
|
||||
authParam.packageName = reply.ReadString();
|
||||
authParam.appName = reply.ReadString();
|
||||
authParam.appDescription = reply.ReadString();
|
||||
authParam.business = reply.ReadInt32();
|
||||
authParam.pincode = reply.ReadInt32();
|
||||
pRsp->SetDmAuthParam(authParam);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_USER_AUTH_OPERATION, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcGetOperationReq> pReq = std::static_pointer_cast<IpcGetOperationReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
int32_t action = pReq->GetOperation();
|
||||
|
||||
if (!data.WriteString(pkgName)) {
|
||||
LOGE("write pkgName failed");
|
||||
return DM_IPC_TRANSACTION_FAILED;
|
||||
}
|
||||
if (!data.WriteInt32(action)) {
|
||||
LOGE("write action failed");
|
||||
return DM_WRITE_FAILED;
|
||||
}
|
||||
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_USER_AUTH_OPERATION, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply)
|
||||
@@ -226,8 +357,8 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply
|
||||
size_t deviceSize = sizeof(DmDeviceInfo);
|
||||
void *deviceInfo = (void *)data.ReadRawData(deviceSize);
|
||||
if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) {
|
||||
reply.WriteInt32(DEVICEMANAGER_COPY_FAILED);
|
||||
return DEVICEMANAGER_OK;
|
||||
reply.WriteInt32(DM_IPC_COPY_FAILED);
|
||||
return DM_OK;
|
||||
}
|
||||
switch (deviceState) {
|
||||
case DEVICE_STATE_ONLINE:
|
||||
@@ -239,12 +370,15 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply
|
||||
case DEVICE_INFO_CHANGED:
|
||||
DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, dmDeviceInfo);
|
||||
break;
|
||||
case DEVICE_INFO_READY:
|
||||
DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, dmDeviceInfo);
|
||||
break;
|
||||
default:
|
||||
DMLOG(DM_LOG_ERROR, "unknown device state:%d", deviceState);
|
||||
LOGE("unknown device state:%d", deviceState);
|
||||
break;
|
||||
}
|
||||
reply.WriteInt32(DEVICEMANAGER_OK);
|
||||
return DEVICEMANAGER_OK;
|
||||
reply.WriteInt32(DM_OK);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply)
|
||||
@@ -255,12 +389,12 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply)
|
||||
size_t deviceSize = sizeof(DmDeviceInfo);
|
||||
void *deviceInfo = (void *)data.ReadRawData(deviceSize);
|
||||
if (deviceInfo != nullptr && memcpy_s(&dmDeviceInfo, deviceSize, deviceInfo, deviceSize) != 0) {
|
||||
reply.WriteInt32(DEVICEMANAGER_COPY_FAILED);
|
||||
return DEVICEMANAGER_OK;
|
||||
reply.WriteInt32(DM_IPC_COPY_FAILED);
|
||||
return DM_IPC_COPY_FAILED;
|
||||
}
|
||||
DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo);
|
||||
reply.WriteInt32(DEVICEMANAGER_OK);
|
||||
return DEVICEMANAGER_OK;
|
||||
reply.WriteInt32(DM_OK);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DISCOVER_FINISH, MessageParcel &data, MessageParcel &reply)
|
||||
@@ -269,122 +403,48 @@ ON_IPC_CMD(SERVER_DISCOVER_FINISH, MessageParcel &data, MessageParcel &reply)
|
||||
uint16_t subscribeId = data.ReadInt16();
|
||||
int32_t failedReason = data.ReadInt32();
|
||||
|
||||
if (failedReason == DEVICEMANAGER_OK) {
|
||||
if (failedReason == DM_OK) {
|
||||
DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId);
|
||||
} else {
|
||||
DeviceManagerNotify::GetInstance().OnDiscoverFailed(pkgName, subscribeId, failedReason);
|
||||
DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason);
|
||||
}
|
||||
reply.WriteInt32(DEVICEMANAGER_OK);
|
||||
return DEVICEMANAGER_OK;
|
||||
reply.WriteInt32(DM_OK);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_AUTH_RESULT, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string pkgName = data.ReadString();
|
||||
std::string deviceId = data.ReadString();
|
||||
int32_t pinToken = data.ReadInt32();
|
||||
std::string token = data.ReadString();
|
||||
int32_t status = data.ReadInt32();
|
||||
int32_t reason = data.ReadInt32();
|
||||
|
||||
DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, pinToken, status, reason);
|
||||
reply.WriteInt32(DEVICEMANAGER_OK);
|
||||
return DEVICEMANAGER_OK;
|
||||
DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason);
|
||||
reply.WriteInt32(DM_OK);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_CHECK_AUTH_RESULT, MessageParcel &data, MessageParcel &reply)
|
||||
ON_IPC_CMD(SERVER_VERIFY_AUTH_RESULT, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string pkgName = data.ReadString();
|
||||
std::string deviceId = data.ReadString();
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
int32_t flag = data.ReadInt32();
|
||||
|
||||
DeviceManagerNotify::GetInstance().OnCheckAuthResult(pkgName, deviceId, resultCode, flag);
|
||||
reply.WriteInt32(DEVICEMANAGER_OK);
|
||||
return DEVICEMANAGER_OK;
|
||||
DeviceManagerNotify::GetInstance().OnVerifyAuthResult(pkgName, deviceId, resultCode, flag);
|
||||
reply.WriteInt32(DM_OK);
|
||||
return DM_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_GET_AUTHENTCATION_INFO, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::shared_ptr<IpcReq> pReq = std::static_pointer_cast<IpcReq>(pBaseReq);
|
||||
std::string packagename = pReq->GetPkgName();
|
||||
if (!data.WriteString(packagename)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_GET_AUTHENTCATION_INFO, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
std::shared_ptr<IpcGetAuthParamRsp> pRsp = std::static_pointer_cast<IpcGetAuthParamRsp>(pBaseRsp);
|
||||
DmAuthParam authParam;
|
||||
authParam.direction = reply.ReadInt32();
|
||||
authParam.authType = reply.ReadInt32();
|
||||
if (authParam.direction == AUTH_SESSION_SIDE_CLIENT) {
|
||||
authParam.pinToken = reply.ReadInt32();
|
||||
pRsp->SetAuthParam(authParam);
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
authParam.packageName = reply.ReadString();
|
||||
authParam.appName = reply.ReadString();
|
||||
authParam.appDescription = reply.ReadString();
|
||||
authParam.business = reply.ReadInt32();
|
||||
authParam.pincode = reply.ReadInt32();
|
||||
|
||||
int32_t appIconLen = reply.ReadInt32();
|
||||
uint8_t *appIconBuffer = nullptr;
|
||||
int32_t appThumbnailLen = reply.ReadInt32();
|
||||
uint8_t *appThumbBuffer = nullptr;
|
||||
if (appIconLen > 0) {
|
||||
appIconBuffer = (uint8_t *)reply.ReadRawData(appIconLen);
|
||||
}
|
||||
if (appThumbnailLen > 0) {
|
||||
appThumbBuffer = (uint8_t *)reply.ReadRawData(appThumbnailLen);
|
||||
}
|
||||
authParam.imageinfo.Reset(appIconBuffer, appIconLen, appThumbBuffer, appThumbnailLen);
|
||||
pRsp->SetAuthParam(authParam);
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_SET_REQUEST(SERVER_USER_AUTHORIZATION_OPERATION, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
|
||||
{
|
||||
std::shared_ptr<IpcGetOperationReq> pReq = std::static_pointer_cast<IpcGetOperationReq>(pBaseReq);
|
||||
std::string pkgName = pReq->GetPkgName();
|
||||
int32_t action = pReq->GetOperation();
|
||||
|
||||
if (!data.WriteString(pkgName)) {
|
||||
DMLOG(DM_LOG_ERROR, "write pkgName failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(action)) {
|
||||
DMLOG(DM_LOG_ERROR, "write extra failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_READ_RESPONSE(SERVER_USER_AUTHORIZATION_OPERATION, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
|
||||
{
|
||||
pBaseRsp->SetErrCode(reply.ReadInt32());
|
||||
return DEVICEMANAGER_OK;
|
||||
}
|
||||
|
||||
ON_IPC_CMD(SERVER_DEVICEMANAGER_FA_NOTIFY, MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "OnFaCallBack");
|
||||
std::string packagename = data.ReadString();
|
||||
std::string paramJson = data.ReadString();
|
||||
DMLOG(DM_LOG_INFO, "OnFaCallBack Packagename is %s", packagename.c_str());
|
||||
DMLOG(DM_LOG_INFO, "OnFaCallBack Json is %s", paramJson.c_str());
|
||||
DeviceManagerNotify::GetInstance().OnFaCall(packagename, paramJson);
|
||||
|
||||
if (!reply.WriteInt32(DEVICEMANAGER_OK)) {
|
||||
DMLOG(DM_LOG_ERROR, "write return failed");
|
||||
return DEVICEMANAGER_FLATTEN_OBJECT;
|
||||
if (!reply.WriteInt32(DM_OK)) {
|
||||
LOGE("write return failed");
|
||||
return DM_WRITE_FAILED;
|
||||
}
|
||||
return DEVICEMANAGER_OK;
|
||||
return DM_OK;
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,65 +15,64 @@
|
||||
|
||||
#include "device_manager_notify.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "device_manager_errno.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "constants.h"
|
||||
#include "device_manager.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_log.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
IMPLEMENT_SINGLE_INSTANCE(DeviceManagerNotify);
|
||||
|
||||
void DeviceManagerNotify::RegisterDeathRecipientCallback(std::string &pkgName,
|
||||
std::shared_ptr<DmInitCallback> dmInitCallback)
|
||||
void DeviceManagerNotify::RegisterDeathRecipientCallback(const std::string &pkgName,
|
||||
std::shared_ptr<DmInitCallback> dmInitCallback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
dmInitCallback_[pkgName] = dmInitCallback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterDeathRecipientCallback(std::string &pkgName)
|
||||
void DeviceManagerNotify::UnRegisterDeathRecipientCallback(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
dmInitCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::RegisterDeviceStateCallback(std::string &pkgName,
|
||||
std::shared_ptr<DeviceStateCallback> callback)
|
||||
void DeviceManagerNotify::RegisterDeviceStateCallback(const std::string &pkgName,
|
||||
std::shared_ptr<DeviceStateCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
deviceStateCallback_[pkgName] = callback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterDeviceStateCallback(std::string &pkgName)
|
||||
void DeviceManagerNotify::UnRegisterDeviceStateCallback(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
deviceStateCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::RegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId,
|
||||
std::shared_ptr<DiscoverCallback> callback)
|
||||
void DeviceManagerNotify::RegisterDiscoveryCallback(const std::string &pkgName, uint16_t subscribeId,
|
||||
std::shared_ptr<DiscoveryCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoverCallbacks_.count(pkgName) == 0) {
|
||||
deviceDiscoverCallbacks_[pkgName] = std::map<uint16_t, std::shared_ptr<DiscoverCallback>>();
|
||||
if (deviceDiscoveryCallbacks_.count(pkgName) == 0) {
|
||||
deviceDiscoveryCallbacks_[pkgName] = std::map<uint16_t, std::shared_ptr<DiscoveryCallback>>();
|
||||
}
|
||||
deviceDiscoverCallbacks_[pkgName][subscribeId] = callback;
|
||||
deviceDiscoveryCallbacks_[pkgName][subscribeId] = callback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterDiscoverCallback(std::string &pkgName, uint16_t subscribeId)
|
||||
void DeviceManagerNotify::UnRegisterDiscoveryCallback(const std::string &pkgName, uint16_t subscribeId)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoverCallbacks_.count(pkgName) > 0) {
|
||||
deviceDiscoverCallbacks_[pkgName].erase(subscribeId);
|
||||
if (deviceDiscoverCallbacks_[pkgName].empty()) {
|
||||
deviceDiscoverCallbacks_.erase(pkgName);
|
||||
if (deviceDiscoveryCallbacks_.count(pkgName) > 0) {
|
||||
deviceDiscoveryCallbacks_[pkgName].erase(subscribeId);
|
||||
if (deviceDiscoveryCallbacks_[pkgName].empty()) {
|
||||
deviceDiscoveryCallbacks_.erase(pkgName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::RegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId,
|
||||
std::shared_ptr<AuthenticateCallback> callback)
|
||||
void DeviceManagerNotify::RegisterAuthenticateCallback(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<AuthenticateCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (authenticateCallback_.count(pkgName) == 0) {
|
||||
@@ -82,7 +81,7 @@ void DeviceManagerNotify::RegisterAuthenticateCallback(std::string &pkgName, std
|
||||
authenticateCallback_[pkgName][deviceId] = callback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterAuthenticateCallback(std::string &pkgName, std::string &deviceId)
|
||||
void DeviceManagerNotify::UnRegisterAuthenticateCallback(const std::string &pkgName, const std::string &deviceId)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (authenticateCallback_.count(pkgName) > 0) {
|
||||
@@ -93,185 +92,192 @@ void DeviceManagerNotify::UnRegisterAuthenticateCallback(std::string &pkgName, s
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterPackageCallback(std::string &pkgName)
|
||||
void DeviceManagerNotify::UnRegisterPackageCallback(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
deviceStateCallback_.erase(pkgName);
|
||||
deviceDiscoverCallbacks_.erase(pkgName);
|
||||
deviceDiscoveryCallbacks_.erase(pkgName);
|
||||
authenticateCallback_.erase(pkgName);
|
||||
dmInitCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::RegisterCheckAuthenticationCallback(std::string &pkgName, std::string &authPara,
|
||||
std::shared_ptr<CheckAuthCallback> callback)
|
||||
void DeviceManagerNotify::RegisterVerifyAuthenticationCallback(const std::string &pkgName, const std::string &authPara,
|
||||
std::shared_ptr<VerifyAuthCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
checkauthcallback_[pkgName] = callback;
|
||||
verifyAuthCallback_[pkgName] = callback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterCheckAuthenticationCallback(std::string &pkgName)
|
||||
void DeviceManagerNotify::UnRegisterVerifyAuthenticationCallback(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
checkauthcallback_.erase(pkgName);
|
||||
verifyAuthCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::RegisterDeviceManagerFaCallback(std::string &packageName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback)
|
||||
void DeviceManagerNotify::RegisterDeviceManagerFaCallback(const std::string &pkgName,
|
||||
std::shared_ptr<DeviceManagerFaCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
dmFaCallback_[packageName] = callback;
|
||||
dmFaCallback_[pkgName] = callback;
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::UnRegisterDeviceManagerFaCallback(std::string &pkgName)
|
||||
void DeviceManagerNotify::UnRegisterDeviceManagerFaCallback(const std::string &pkgName)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (dmFaCallback_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager UnRegisterDeviceManagerFaCallback not register");
|
||||
return;
|
||||
}
|
||||
dmFaCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
|
||||
void DeviceManagerNotify::OnRemoteDied()
|
||||
{
|
||||
DMLOG(DM_LOG_WARN, "DeviceManager : OnRemoteDied");
|
||||
LOGW("DeviceManager : OnRemoteDied");
|
||||
for (auto iter : dmInitCallback_) {
|
||||
iter.second->OnRemoteDied();
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDeviceOnline(std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
void DeviceManagerNotify::OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceOnline pkgName:%s", pkgName.c_str());
|
||||
LOGI("DeviceManager OnDeviceOnline pkgName:%s", pkgName.c_str());
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceStateCallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceOnlinecallback not register");
|
||||
LOGE("DeviceManager OnDeviceOnlinecallback not register");
|
||||
return;
|
||||
}
|
||||
deviceStateCallback_[pkgName]->OnDeviceOnline(deviceInfo);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDeviceOffline(std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
void DeviceManagerNotify::OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceOffline pkgName:%s", pkgName.c_str());
|
||||
LOGI("DeviceManager OnDeviceOffline pkgName:%s", pkgName.c_str());
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceStateCallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceOfflinecallback not register");
|
||||
LOGE("DeviceManager OnDeviceOfflinecallback not register");
|
||||
return;
|
||||
}
|
||||
deviceStateCallback_[pkgName]->OnDeviceOffline(deviceInfo);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDeviceChanged(std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
void DeviceManagerNotify::OnDeviceChanged(const std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceChanged pkgName:%s", pkgName.c_str());
|
||||
LOGI("DeviceManager OnDeviceChanged pkgName:%s", pkgName.c_str());
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceStateCallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceChangedcallback not register");
|
||||
LOGE("DeviceManager OnDeviceChangedcallback not register");
|
||||
return;
|
||||
}
|
||||
deviceStateCallback_[pkgName]->OnDeviceChanged(deviceInfo);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDeviceFound(std::string &pkgName, uint16_t subscribeId,
|
||||
const DmDeviceInfo &deviceInfo)
|
||||
void DeviceManagerNotify::OnDeviceReady(const std::string &pkgName, const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDeviceFound pkgName:%s, subscribeId:%d.", pkgName.c_str(),
|
||||
(int32_t)subscribeId);
|
||||
LOGI("DeviceManager OnDeviceReady pkgName:%s", pkgName.c_str());
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoverCallbacks_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceFound: no register discoverCallback for this package");
|
||||
if (deviceStateCallback_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnDeviceReadycallback not register");
|
||||
return;
|
||||
}
|
||||
std::map<uint16_t, std::shared_ptr<DiscoverCallback>> &discoverCallMap = deviceDiscoverCallbacks_[pkgName];
|
||||
deviceStateCallback_[pkgName]->OnDeviceReady(deviceInfo);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDeviceFound(const std::string &pkgName, uint16_t subscribeId,
|
||||
const DmDeviceInfo &deviceInfo)
|
||||
{
|
||||
LOGI("DeviceManager OnDeviceFound pkgName:%s, subscribeId:%d.", pkgName.c_str(), (int32_t)subscribeId);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoveryCallbacks_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnDeviceFound: no register DiscoveryCallback for this package");
|
||||
return;
|
||||
}
|
||||
std::map<uint16_t, std::shared_ptr<DiscoveryCallback>> &discoverCallMap = deviceDiscoveryCallbacks_[pkgName];
|
||||
auto iter = discoverCallMap.find(subscribeId);
|
||||
if (iter == discoverCallMap.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDeviceFound: no register discoverCallback for subscribeId %d",
|
||||
subscribeId);
|
||||
LOGE("DeviceManager OnDeviceFound: no register DiscoveryCallback for subscribeId %d", subscribeId);
|
||||
return;
|
||||
}
|
||||
iter->second->OnDeviceFound(subscribeId, deviceInfo);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDiscoverFailed(std::string &pkgName, uint16_t subscribeId, int32_t failedReason)
|
||||
void DeviceManagerNotify::OnDiscoveryFailed(const std::string &pkgName, uint16_t subscribeId, int32_t failedReason)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDiscoverFailed pkgName:%s, subscribeId %d, reason %d",
|
||||
pkgName.c_str(), subscribeId, failedReason);
|
||||
LOGI("DeviceManager OnDiscoveryFailed pkgName:%s, subscribeId %d, reason %d", pkgName.c_str(), subscribeId,
|
||||
failedReason);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoverCallbacks_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverFailed: no register discoverCallback for this package");
|
||||
if (deviceDiscoveryCallbacks_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnDiscoveryFailed: no register DiscoveryCallback for this package");
|
||||
return;
|
||||
}
|
||||
std::map<uint16_t, std::shared_ptr<DiscoverCallback>> &discoverCallMap = deviceDiscoverCallbacks_[pkgName];
|
||||
std::map<uint16_t, std::shared_ptr<DiscoveryCallback>> &discoverCallMap = deviceDiscoveryCallbacks_[pkgName];
|
||||
auto iter = discoverCallMap.find(subscribeId);
|
||||
if (iter == discoverCallMap.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverFailed: no register discoverCallback for subscribeId %d",
|
||||
subscribeId);
|
||||
LOGE("DeviceManager OnDiscoveryFailed: no register DiscoveryCallback for subscribeId %d", subscribeId);
|
||||
return;
|
||||
}
|
||||
iter->second->OnDiscoverFailed(subscribeId, failedReason);
|
||||
iter->second->OnDiscoveryFailed(subscribeId, failedReason);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnDiscoverySuccess(std::string &pkgName, uint16_t subscribeId)
|
||||
void DeviceManagerNotify::OnDiscoverySuccess(const std::string &pkgName, uint16_t subscribeId)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnDiscoverySuccess pkgName:%s, subscribeId:%d.", pkgName.c_str(),
|
||||
subscribeId);
|
||||
LOGI("DeviceManager OnDiscoverySuccess pkgName:%s, subscribeId:%d.", pkgName.c_str(), subscribeId);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (deviceDiscoverCallbacks_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverySuccess: no register discoverCallback for this package");
|
||||
if (deviceDiscoveryCallbacks_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnDiscoverySuccess: no register DiscoveryCallback for this package");
|
||||
return;
|
||||
}
|
||||
std::map<uint16_t, std::shared_ptr<DiscoverCallback>> &discoverCallMap = deviceDiscoverCallbacks_[pkgName];
|
||||
std::map<uint16_t, std::shared_ptr<DiscoveryCallback>> &discoverCallMap = deviceDiscoveryCallbacks_[pkgName];
|
||||
auto iter = discoverCallMap.find(subscribeId);
|
||||
if (iter == discoverCallMap.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnDiscoverySuccess: no register discoverCallback for subscribeId %d",
|
||||
subscribeId);
|
||||
LOGE("DeviceManager OnDiscoverySuccess: no register DiscoveryCallback for subscribeId %d", subscribeId);
|
||||
return;
|
||||
}
|
||||
iter->second->OnDiscoverySuccess(subscribeId);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnAuthResult(std::string &pkgName, std::string &deviceId, int32_t pinToken,
|
||||
uint32_t status, uint32_t reason)
|
||||
void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::string &deviceId,
|
||||
const std::string &token, uint32_t status, uint32_t reason)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d",
|
||||
pkgName.c_str(), status, reason);
|
||||
LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d", pkgName.c_str(), status, reason);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (authenticateCallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnAuthResult: no register authCallback for this package");
|
||||
LOGE("DeviceManager OnAuthResult: no register authCallback for this package");
|
||||
return;
|
||||
}
|
||||
std::map<std::string, std::shared_ptr<AuthenticateCallback>> &authCallMap = authenticateCallback_[pkgName];
|
||||
auto iter = authCallMap.find(deviceId);
|
||||
if (iter == authCallMap.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnAuthResult: no register authCallback for deviceID ");
|
||||
LOGE("DeviceManager OnAuthResult: no register authCallback for deviceID ");
|
||||
return;
|
||||
}
|
||||
iter->second->OnAuthResult(deviceId, pinToken, status, reason);
|
||||
iter->second->OnAuthResult(deviceId, token, status, reason);
|
||||
authenticateCallback_[pkgName].erase(deviceId);
|
||||
if (authenticateCallback_[pkgName].empty()) {
|
||||
authenticateCallback_.erase(pkgName);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnCheckAuthResult(std::string &pkgName, std::string &deviceId, int32_t resultCode,
|
||||
int32_t flag)
|
||||
void DeviceManagerNotify::OnVerifyAuthResult(const std::string &pkgName, const std::string &deviceId,
|
||||
int32_t resultCode, int32_t flag)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManagerNotify::OnCheckAuthResult pkgName:%s, resultCode:%d, flag:%d",
|
||||
pkgName.c_str(), resultCode, flag);
|
||||
LOGI("DeviceManagerNotify::OnCheckAuthResult pkgName:%s, resultCode:%d, flag:%d", pkgName.c_str(), resultCode,
|
||||
flag);
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (checkauthcallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager OnCheckAuthResult: no register authCallback for this package");
|
||||
if (verifyAuthCallback_.count(pkgName) == 0) {
|
||||
LOGE("DeviceManager OnCheckAuthResult: no register authCallback for this package");
|
||||
return;
|
||||
}
|
||||
|
||||
checkauthcallback_[pkgName]->OnCheckAuthResult(deviceId, resultCode, flag);
|
||||
checkauthcallback_.erase(pkgName);
|
||||
verifyAuthCallback_[pkgName]->OnVerifyAuthResult(deviceId, resultCode, flag);
|
||||
verifyAuthCallback_.erase(pkgName);
|
||||
}
|
||||
|
||||
void DeviceManagerNotify::OnFaCall(std::string &pkgName, std::string ¶mJson)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DeviceManager OnFaCallback pkgName:%s", pkgName.c_str());
|
||||
LOGI("DeviceManager OnFaCallback pkgName:%s", pkgName.c_str());
|
||||
std::lock_guard<std::mutex> autoLock(lock_);
|
||||
if (dmFaCallback_.count(pkgName) == 0) {
|
||||
DMLOG(DM_LOG_ERROR, "DeviceManager DmFaCallback not register");
|
||||
LOGE("DeviceManager DmFaCallback not register");
|
||||
return;
|
||||
}
|
||||
dmFaCallback_[pkgName]->OnCall(paramJson);
|
||||
|
||||
@@ -16,17 +16,18 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
|
||||
|
||||
ohos_shared_library("devicemanager") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
"${utils_path}/include",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include/ipc/standard",
|
||||
"//third_party/node/src",
|
||||
"//third_party/json/include",
|
||||
"${common_path}/include",
|
||||
"//foundation/ace/napi/native_engine",
|
||||
"//foundation/ace/napi/interfaces/kits",
|
||||
"//utils/native/base/include",
|
||||
"include",
|
||||
"${utils_path}/include/log",
|
||||
"${common_path}/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/standard",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,12 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
|
||||
#define OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
|
||||
#ifndef OHOS_DM_NATIVE_EVENT_H
|
||||
#define OHOS_DM_NATIVE_EVENT_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
|
||||
struct DmEventListener {
|
||||
@@ -41,4 +42,4 @@ protected:
|
||||
std::map<std::string, std::shared_ptr<DmEventListener>> eventMap_;
|
||||
};
|
||||
|
||||
#endif /* OHOS_DEVICE_MANAGER_NATIVE_EVENT_H */
|
||||
#endif /* OHOS_DM_NATIVE_EVENT_H */
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,20 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DEVICE_MANAGER_NATIVE_DEVICEMANAGER_JS_H
|
||||
#define OHOS_DEVICE_MANAGER_NATIVE_DEVICEMANAGER_JS_H
|
||||
#ifndef OHOS_DM_NATIVE_DEVICEMANAGER_JS_H
|
||||
#define OHOS_DM_NATIVE_DEVICEMANAGER_JS_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "device_manager_callback.h"
|
||||
#include "dm_app_image_info.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_native_event.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "device_manager_callback.h"
|
||||
#include "dm_native_event.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_subscribe_info.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "dm_device_info.h"
|
||||
|
||||
#define DM_NAPI_BUF_LENGTH (256)
|
||||
|
||||
struct AsyncCallbackInfo {
|
||||
@@ -40,6 +40,22 @@ struct AsyncCallbackInfo {
|
||||
int32_t status = -1;
|
||||
};
|
||||
|
||||
struct DeviceInfoAsyncCallbackInfo {
|
||||
napi_env env = nullptr;
|
||||
napi_async_work asyncWork = nullptr;
|
||||
|
||||
std::string bundleName;
|
||||
size_t bundleNameLen = 0;
|
||||
OHOS::DistributedHardware::DmDeviceInfo deviceInfo;
|
||||
std::vector<OHOS::DistributedHardware::DmDeviceInfo> devList;
|
||||
std::string extra;
|
||||
// OHOS::DistributedHardware::DmFilterOptions filter;
|
||||
napi_ref callback = nullptr;
|
||||
napi_value thisVar = nullptr;
|
||||
napi_deferred deferred = nullptr;
|
||||
int32_t status = -1;
|
||||
int32_t isList = 0;
|
||||
};
|
||||
struct AuthAsyncCallbackInfo {
|
||||
napi_env env = nullptr;
|
||||
|
||||
@@ -50,17 +66,16 @@ struct AuthAsyncCallbackInfo {
|
||||
int32_t authType = -1;
|
||||
};
|
||||
|
||||
enum DmNapiDevStateChangeAction {
|
||||
ONLINE = 0,
|
||||
READY = 1,
|
||||
OFFLINE = 2,
|
||||
CHANGE = 3
|
||||
};
|
||||
enum DmNapiDevStateChangeAction { ONLINE = 0, READY = 1, OFFLINE = 2, CHANGE = 3 };
|
||||
|
||||
class DmNapiInitCallback : public OHOS::DistributedHardware::DmInitCallback {
|
||||
public:
|
||||
explicit DmNapiInitCallback(std::string &bundleName) : bundleName_(bundleName) {}
|
||||
virtual ~DmNapiInitCallback() {}
|
||||
explicit DmNapiInitCallback(std::string &bundleName) : bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiInitCallback()
|
||||
{
|
||||
}
|
||||
void OnRemoteDied() override;
|
||||
|
||||
private:
|
||||
@@ -69,7 +84,9 @@ private:
|
||||
|
||||
class DmNapiDeviceStateCallback : public OHOS::DistributedHardware::DeviceStateCallback {
|
||||
public:
|
||||
explicit DmNapiDeviceStateCallback(std::string &bundleName) : bundleName_(bundleName) {}
|
||||
explicit DmNapiDeviceStateCallback(std::string &bundleName) : bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiDeviceStateCallback() {};
|
||||
void OnDeviceOnline(const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo) override;
|
||||
void OnDeviceReady(const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo) override;
|
||||
@@ -80,12 +97,14 @@ private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiDiscoverCallback : public OHOS::DistributedHardware::DiscoverCallback {
|
||||
class DmNapiDiscoveryCallback : public OHOS::DistributedHardware::DiscoveryCallback {
|
||||
public:
|
||||
explicit DmNapiDiscoverCallback(std::string &bundleName) : refCount_(0), bundleName_(bundleName) {}
|
||||
virtual ~DmNapiDiscoverCallback() {};
|
||||
explicit DmNapiDiscoveryCallback(std::string &bundleName) : refCount_(0), bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiDiscoveryCallback() {};
|
||||
void OnDeviceFound(uint16_t subscribeId, const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo) override;
|
||||
void OnDiscoverFailed(uint16_t subscribeId, int32_t failedReason) override;
|
||||
void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) override;
|
||||
void OnDiscoverySuccess(uint16_t subscribeId) override;
|
||||
void IncreaseRefCount();
|
||||
void DecreaseRefCount();
|
||||
@@ -96,31 +115,37 @@ private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiAuthenticateCallback : public OHOS::DistributedHardware::AuthenticateCallback {
|
||||
public:
|
||||
explicit DmNapiAuthenticateCallback(std::string &bundleName) : bundleName_(bundleName) {}
|
||||
virtual ~DmNapiAuthenticateCallback() {};
|
||||
void OnAuthResult(std::string &deviceId, int32_t pinToken, int32_t status, int32_t reason) override;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiCheckAuthCallback : public OHOS::DistributedHardware::CheckAuthCallback {
|
||||
public:
|
||||
explicit DmNapiCheckAuthCallback(std::string &bundleName) : bundleName_(bundleName) {}
|
||||
virtual ~DmNapiCheckAuthCallback() {};
|
||||
void OnCheckAuthResult(std::string &deviceId, int32_t resultCode, int32_t flag) override;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiDeviceManagerFaCallback : public OHOS::DistributedHardware::DeviceManagerFaCallback {
|
||||
public:
|
||||
explicit DmNapiDeviceManagerFaCallback(std::string &bundleName) : bundleName_(bundleName) {}
|
||||
explicit DmNapiDeviceManagerFaCallback(std::string &bundleName) : bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiDeviceManagerFaCallback() {};
|
||||
void OnCall(std::string ¶mJson) override;
|
||||
void OnCall(const std::string ¶mJson) override;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiAuthenticateCallback : public OHOS::DistributedHardware::AuthenticateCallback {
|
||||
public:
|
||||
explicit DmNapiAuthenticateCallback(std::string &bundleName) : bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiAuthenticateCallback() {};
|
||||
void OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status, int32_t reason) override;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
};
|
||||
|
||||
class DmNapiVerifyAuthCallback : public OHOS::DistributedHardware::VerifyAuthCallback {
|
||||
public:
|
||||
explicit DmNapiVerifyAuthCallback(std::string &bundleName) : bundleName_(bundleName)
|
||||
{
|
||||
}
|
||||
virtual ~DmNapiVerifyAuthCallback() {};
|
||||
void OnVerifyAuthResult(const std::string &deviceId, int32_t resultCode, int32_t flag) override;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
@@ -134,58 +159,78 @@ public:
|
||||
static napi_value Constructor(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateDeviceManager(napi_env env, napi_callback_info info);
|
||||
static napi_value ReleaseDeviceManager(napi_env env, napi_callback_info info);
|
||||
static napi_value SetUserOperationSync(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTrustedDeviceListSync(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTrustedDeviceList(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLocalDeviceInfoSync(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLocalDeviceInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value UnAuthenticateDevice(napi_env env, napi_callback_info info);
|
||||
static napi_value StartDeviceDiscoverSync(napi_env env, napi_callback_info info);
|
||||
static napi_value StopDeviceDiscoverSync(napi_env env, napi_callback_info info);
|
||||
static napi_value AuthenticateDevice(napi_env env, napi_callback_info info);
|
||||
static napi_value VerifyAuthInfo(napi_env env, napi_callback_info info);
|
||||
static napi_value JsOn(napi_env env, napi_callback_info info);
|
||||
static napi_value JsOff(napi_env env, napi_callback_info info);
|
||||
static napi_value SetUserOperationSync(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAuthenticationParamSync(napi_env env, napi_callback_info info);
|
||||
static void HandleCreateDmCallBack(const napi_env &env, AsyncCallbackInfo *asCallbackInfo);
|
||||
static DeviceManagerNapi *GetDeviceManagerNapi(std::string &buldleName);
|
||||
static void CreateDmCallback(std::string &bundleName, std::string &eventType);
|
||||
static void ReleaseDmCallback(std::string &bundleName, std::string &eventType);
|
||||
static void DeviceInfoToJsArray(const napi_env &env,
|
||||
const std::vector<OHOS::DistributedHardware::DmDeviceInfo>& vecDevInfo,
|
||||
const int32_t idx, napi_value &arrayResult);
|
||||
static void DmAuthParamToJsAuthParam(const napi_env &env,
|
||||
const OHOS::DistributedHardware::DmAuthParam &authParam, napi_value ¶mResult);
|
||||
const std::vector<OHOS::DistributedHardware::DmDeviceInfo> &vecDevInfo,
|
||||
const int32_t idx, napi_value &arrayResult);
|
||||
static void DmAuthParamToJsAuthParam(const napi_env &env, const OHOS::DistributedHardware::DmAuthParam &authParam,
|
||||
napi_value ¶mResult);
|
||||
static void SetValueInt32(const napi_env &env, const std::string &fieldStr, const int32_t intValue,
|
||||
napi_value &result);
|
||||
napi_value &result);
|
||||
static void SetValueUtf8String(const napi_env &env, const std::string &fieldStr, const std::string &str,
|
||||
napi_value &result);
|
||||
static void JsObjectToString(const napi_env &env, const napi_value &object,
|
||||
const std::string &fieldStr, char *dest, const int32_t destLen);
|
||||
static void JsObjectToBool(const napi_env &env, const napi_value &object,
|
||||
const std::string &fieldStr, bool& fieldRef);
|
||||
napi_value &result);
|
||||
static void JsObjectToString(const napi_env &env, const napi_value &object, const std::string &fieldStr, char *dest,
|
||||
const int32_t destLen);
|
||||
static void JsObjectToBool(const napi_env &env, const napi_value &object, const std::string &fieldStr,
|
||||
bool &fieldRef);
|
||||
static void JsObjectToInt(const napi_env &env, const napi_value &object, const std::string &fieldStr,
|
||||
int& fieldRef);
|
||||
int &fieldRef);
|
||||
static std::string JsObjectToString(const napi_env &env, const napi_value &object);
|
||||
static int32_t JsToDmSubscribeInfo(const napi_env &env, const napi_value &object,
|
||||
OHOS::DistributedHardware::DmSubscribeInfo& info);
|
||||
OHOS::DistributedHardware::DmSubscribeInfo &info);
|
||||
static void JsToDmDeviceInfo(const napi_env &env, const napi_value &object,
|
||||
OHOS::DistributedHardware::DmDeviceInfo& info);
|
||||
static void JsToDmAppImageInfoAndDmExtra(const napi_env &env, const napi_value &object,
|
||||
OHOS::DistributedHardware::DmAppImageInfo& appImageInfo, std::string &extra, int32_t &authType);
|
||||
OHOS::DistributedHardware::DmDeviceInfo &info);
|
||||
static void JsToDmExtra(const napi_env &env, const napi_value &object, std::string &extra, int32_t &authType);
|
||||
static void JsToDmAuthInfo(const napi_env &env, const napi_value &object, std::string &extra);
|
||||
static void JsToDmBuffer(const napi_env &env, const napi_value &object, const std::string &fieldStr,
|
||||
uint8_t **bufferPtr, int32_t &bufferLen);
|
||||
uint8_t **bufferPtr, int32_t &bufferLen);
|
||||
static void JsToJsonObject(const napi_env &env, const napi_value &object, const std::string &fieldStr,
|
||||
nlohmann::json &jsonObj);
|
||||
static void JsToDmTokenInfo(const napi_env &env, const napi_value &object,
|
||||
const std::string &fieldStr, nlohmann::json &jsonObj);
|
||||
nlohmann::json &jsonObj);
|
||||
static void JsToDmTokenInfo(const napi_env &env, const napi_value &object, const std::string &fieldStr,
|
||||
nlohmann::json &jsonObj);
|
||||
static void JsToDmAuthExtra(const napi_env &env, const napi_value ¶m, nlohmann::json &jsonObj);
|
||||
static void DmDeviceInfotoJsDeviceInfo(const napi_env &env,
|
||||
const OHOS::DistributedHardware::DmDeviceInfo &vecDevInfo,
|
||||
napi_value &result);
|
||||
void OnDeviceStateChange(DmNapiDevStateChangeAction action,
|
||||
const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo);
|
||||
const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo);
|
||||
void OnDeviceFound(uint16_t subscribeId, const OHOS::DistributedHardware::DmDeviceInfo &deviceInfo);
|
||||
void OnDiscoverFailed(uint16_t subscribeId, int32_t failedReason);
|
||||
void OnAuthResult(const std::string &deviceId, int32_t pinToken, int32_t status, int32_t reason);
|
||||
void OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason);
|
||||
void OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status, int32_t reason);
|
||||
void OnVerifyResult(const std::string &deviceId, int32_t resultCode, int32_t flag);
|
||||
void OnDmfaCall(const std::string ¶mJson);
|
||||
static void DmAuthParamToJsAuthParamy(const napi_env &env,
|
||||
const OHOS::DistributedHardware::DmAuthParam &authParam, napi_value ¶mResult);
|
||||
|
||||
private:
|
||||
static napi_value JsOffFrench(napi_env env, int32_t num, napi_value thisVar, napi_value argv[]);
|
||||
static napi_value JsOnFrench(napi_env env, int32_t num, napi_value thisVar, napi_value argv[]);
|
||||
static void CallAsyncWorkSync(napi_env env, DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static void CallAsyncWork(napi_env env, DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static void CallGetTrustedDeviceListStatusSync(napi_env env, napi_status &status,
|
||||
DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static void CallGetTrustedDeviceListStatus(napi_env env, napi_status &status,
|
||||
DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static napi_value CallDeviceList(napi_env env, napi_callback_info info,
|
||||
DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static void CallGetLocalDeviceInfoSync(napi_env env, napi_status &status,
|
||||
DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
static void CallGetLocalDeviceInfo(napi_env env, napi_status &status,
|
||||
DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo);
|
||||
|
||||
private:
|
||||
napi_env env_;
|
||||
@@ -196,4 +241,4 @@ private:
|
||||
static AuthAsyncCallbackInfo verifyAsyncCallbackInfo_;
|
||||
};
|
||||
|
||||
#endif // OHOS_DEVICE_MANAGER_NATIVE_DEVICEMANAGER_JS_H
|
||||
#endif // OHOS_DM_NATIVE_DEVICEMANAGER_JS_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "dm_native_event.h"
|
||||
|
||||
#include "device_manager_log.h"
|
||||
#include "dm_log.h"
|
||||
|
||||
using namespace OHOS::DistributedHardware;
|
||||
|
||||
@@ -38,7 +38,7 @@ DmNativeEvent::~DmNativeEvent()
|
||||
|
||||
void DmNativeEvent::On(std::string &eventType, napi_value handler)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DmNativeEvent On in for event: %s", eventType.c_str());
|
||||
LOGI("DmNativeEvent On in for event: %s", eventType.c_str());
|
||||
auto listener = std::make_shared<DmEventListener>();
|
||||
listener->eventType = eventType;
|
||||
napi_create_reference(env_, handler, 1, &listener->handlerRef);
|
||||
@@ -47,17 +47,17 @@ void DmNativeEvent::On(std::string &eventType, napi_value handler)
|
||||
|
||||
void DmNativeEvent::Off(std::string &eventType)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "DmNativeEvent Off in for event: %s", eventType.c_str());
|
||||
LOGI("DmNativeEvent Off in for event: %s", eventType.c_str());
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(env_, &scope);
|
||||
if (scope == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "scope is nullptr");
|
||||
LOGE("scope is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = eventMap_.find(eventType);
|
||||
if (iter == eventMap_.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "eventType %s not find", eventType.c_str());
|
||||
LOGE("eventType %s not find", eventType.c_str());
|
||||
return;
|
||||
}
|
||||
auto listener = iter->second;
|
||||
@@ -68,38 +68,38 @@ void DmNativeEvent::Off(std::string &eventType)
|
||||
|
||||
void DmNativeEvent::OnEvent(const std::string &eventType, size_t argc, const napi_value *argv)
|
||||
{
|
||||
DMLOG(DM_LOG_INFO, "OnEvent for %s", eventType.c_str());
|
||||
LOGI("OnEvent for %s", eventType.c_str());
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(env_, &scope);
|
||||
if (scope == nullptr) {
|
||||
DMLOG(DM_LOG_ERROR, "scope is nullptr");
|
||||
LOGE("scope is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = eventMap_.find(eventType);
|
||||
if (iter == eventMap_.end()) {
|
||||
DMLOG(DM_LOG_ERROR, "eventType %s not find", eventType.c_str());
|
||||
LOGE("eventType %s not find", eventType.c_str());
|
||||
return;
|
||||
}
|
||||
auto listener = iter->second;
|
||||
napi_value thisVar = nullptr;
|
||||
napi_status status = napi_get_reference_value(env_, thisVarRef_, &thisVar);
|
||||
if (status != napi_ok) {
|
||||
DMLOG(DM_LOG_ERROR, "napi_get_reference_value thisVar for %s failed, status=%d", eventType.c_str(), status);
|
||||
LOGE("napi_get_reference_value thisVar for %s failed, status=%d", eventType.c_str(), status);
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value handler = nullptr;
|
||||
status = napi_get_reference_value(env_, listener->handlerRef, &handler);
|
||||
if (status != napi_ok) {
|
||||
DMLOG(DM_LOG_ERROR, "napi_get_reference_value handler for %s failed, status=%d", eventType.c_str(), status);
|
||||
LOGE("napi_get_reference_value handler for %s failed, status=%d", eventType.c_str(), status);
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value callResult = nullptr;
|
||||
status = napi_call_function(env_, thisVar, handler, argc, argv, &callResult);
|
||||
if (status != napi_ok) {
|
||||
DMLOG(DM_LOG_ERROR, "napi_call_function for %s failed, status=%d", eventType.c_str(), status);
|
||||
LOGE("napi_call_function for %s failed, status=%d", eventType.c_str(), status);
|
||||
return;
|
||||
}
|
||||
napi_close_handle_scope(env_, scope);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+4
-3
@@ -12,8 +12,7 @@
|
||||
"device_manager.h",
|
||||
"device_manager_callback.h",
|
||||
"dm_device_info.h",
|
||||
"dm_subscribe_info.h",
|
||||
"dm_app_image_info.h"
|
||||
"dm_subscribe_info.h"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -23,7 +22,9 @@
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk",
|
||||
"//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager_native_js",
|
||||
"//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice",
|
||||
"//foundation/distributedhardware/devicemanager/sa_profile:dm_sa_profile"
|
||||
"//foundation/distributedhardware/devicemanager/sa_profile:dm_sa_profile",
|
||||
"//foundation/distributedhardware/devicemanager/ext/pin_auth:devicemanagerext_pin_auth",
|
||||
"//foundation/distributedhardware/devicemanager/ext/profile:devicemanagerext_profile"
|
||||
],
|
||||
"test_list": [
|
||||
"//foundation/distributedhardware/devicemanager/test:test"
|
||||
|
||||
+4
-4
@@ -15,12 +15,12 @@
|
||||
-->
|
||||
<info>
|
||||
<process>foundation</process>
|
||||
<systemability> <!-- Declare a sytem ability and its profile -->
|
||||
<systemability> <!-- Declare a system ability and its profile -->
|
||||
<name>4802</name> <!-- Declare the name of system ability -->
|
||||
<libpath>libdevicemanagerservice.z.so</libpath> <!-- Declare the path of .so file which includes the system ability; Note: 1 .so file can have 1 to N system abilities. -->
|
||||
<!--<depend></depend> --> <!-- Declare the name of system abilities which the system ability depends on, using ";" as separator among names. If there are dependencies, it needs to check if all those dependencies are avliable in service manager before starting the system ability. -->
|
||||
<!--<depend-time-out></depend-time-out> --> <!-- Check all dependencies are avaliable before the timeout period ended. The MAX_DEPENDENCY_TIMEOUT is 60s. -->
|
||||
<run-on-create>true</run-on-create> <!-- "true" means the system ability would start imediately, "false" means the system ability would start on demand. -->
|
||||
<!--<depend></depend> --> <!-- Declare the name of system abilities which the system ability depends on, using ";" as separator among names. If there are dependencies, it needs to check if all those dependencies are available in service manager before starting the system ability. -->
|
||||
<!--<depend-time-out></depend-time-out> --> <!-- Check all dependencies are available before the timeout period ended. The MAX_DEPENDENCY_TIMEOUT is 60s. -->
|
||||
<run-on-create>true</run-on-create> <!-- "true" means the system ability would start immediately, "false" means the system ability would start on demand. -->
|
||||
<distributed>false</distributed> <!-- "true" means the system ability supports distributed scheduling while "false" is not. -->
|
||||
<dump-level>1</dump-level> <!-- Declare the dump level. 1-high; 2-media; 3-low -->
|
||||
</systemability>
|
||||
|
||||
@@ -21,138 +21,67 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
|
||||
|
||||
if (defined(ohos_lite)) {
|
||||
executable("devicemanagerservice") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/ability",
|
||||
"include/softbus",
|
||||
"include/requestauth",
|
||||
"include/auth",
|
||||
"include/ipc",
|
||||
"include/timer",
|
||||
"include/message",
|
||||
"include/ipc/lite",
|
||||
"${utils_path}/include/cipher",
|
||||
"${utils_path}/include/log",
|
||||
"${utils_path}/include/ipc/lite",
|
||||
"${utils_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
"${common_path}/include/ipc/model",
|
||||
"${common_path}/include",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc/lite",
|
||||
]
|
||||
|
||||
include_dirs += [
|
||||
"//base/security/deviceauth/interfaces/innerkits",
|
||||
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
|
||||
"//utils/native/lite/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//third_party/json/include",
|
||||
"//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//foundation/communication/ipc_lite/interfaces/kits",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/bus_center",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/discovery",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/ability/lite/dm_ability_manager.cpp",
|
||||
"src/auth/hichain_connector.cpp",
|
||||
"src/ipc/ipc_server_adapter.cpp",
|
||||
"src/ipc/ipc_server_listener_adapter.cpp",
|
||||
"src/ipc/lite/ipc_cmd_parser.cpp",
|
||||
"src/ipc/lite/ipc_server_listener.cpp",
|
||||
"src/ipc/lite/ipc_server_listenermgr.cpp",
|
||||
"src/ipc/lite/ipc_server_main.cpp",
|
||||
"src/ipc/lite/ipc_server_stub.cpp",
|
||||
"src/message/msg_codec.cpp",
|
||||
"src/message/msg_head.cpp",
|
||||
"src/message/msg_request_auth.cpp",
|
||||
"src/message/msg_response_auth.cpp",
|
||||
"src/message/msg_sync_group.cpp",
|
||||
"src/requestauth/auth_manager.cpp",
|
||||
"src/requestauth/request_session.cpp",
|
||||
"src/requestauth/response_session.cpp",
|
||||
"src/softbus/softbus_adapter.cpp",
|
||||
"src/softbus/softbus_session.cpp",
|
||||
"src/timer/dm_timer.cpp",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"LITE_DEVICE",
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"devicemanagerservice\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
ldflags = dm_ldflags
|
||||
|
||||
deps = [
|
||||
"${innerkits_path}/native_cpp:devicemanagersdk",
|
||||
"${utils_path}:devicemanagerutils",
|
||||
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
|
||||
"//base/security/deviceauth/services:deviceauth_sdk",
|
||||
"//base/startup/syspara_lite/frameworks/parameter/src:sysparam",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//foundation/communication/ipc_lite:liteipc_adapter",
|
||||
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
"//third_party/mbedtls:mbedtls_shared",
|
||||
"//utils/native/lite:utils",
|
||||
]
|
||||
sources = [ "src/ipc/lite/ipc_server_main.cpp" ]
|
||||
}
|
||||
} else {
|
||||
ohos_shared_library("devicemanagerservice") {
|
||||
include_dirs = [
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"include",
|
||||
"include/config",
|
||||
"include/adapter",
|
||||
"include/authentication",
|
||||
"include/ability",
|
||||
"include/softbus",
|
||||
"include/requestauth",
|
||||
"include/auth",
|
||||
"include/deviceinfo",
|
||||
"include/devicestate",
|
||||
"include/discovery",
|
||||
"include/dependency/commonevent",
|
||||
"include/dependency/hichain",
|
||||
"include/dependency/softbus",
|
||||
"include/dependency/timer",
|
||||
"include/ipc",
|
||||
"include/message",
|
||||
"include/timer",
|
||||
"include/ipc/standard",
|
||||
"${utils_path}/include/cipher",
|
||||
"${utils_path}/include/log",
|
||||
"${utils_path}/include",
|
||||
"${utils_path}/include/ipc/standard",
|
||||
"include/eventbus",
|
||||
"${common_path}/include",
|
||||
"${common_path}/include/ipc",
|
||||
"${common_path}/include/ipc/model",
|
||||
"${utils_path}/include",
|
||||
"${utils_path}/include/ipc/standard",
|
||||
"${innerkits_path}/native_cpp/include",
|
||||
"${innerkits_path}/native_cpp/include/ipc",
|
||||
"${innerkits_path}/native_cpp/include/ipc/standard",
|
||||
"//utils/native/base/include",
|
||||
"//utils/system/safwk/native/include",
|
||||
"//base/notification/ces_standard/frameworks/core/include",
|
||||
"//base/notification/ces_standard/interfaces/innerkits/native/include",
|
||||
"//base/security/deviceauth/interfaces/innerkits",
|
||||
"//base/startup/syspara_lite/interfaces/kits",
|
||||
"//base/startup/syspara_lite/adapter/native/syspara/include",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/ability/standard/dm_ability_manager.cpp",
|
||||
"src/auth/hichain_connector.cpp",
|
||||
"src/ipc/ipc_server_adapter.cpp",
|
||||
"src/ipc/ipc_server_listener_adapter.cpp",
|
||||
"src/adapter/standard/dm_adapter_manager.cpp",
|
||||
"src/authentication/auth_message_processor.cpp",
|
||||
"src/authentication/auth_request_state.cpp",
|
||||
"src/authentication/auth_response_state.cpp",
|
||||
"src/authentication/auth_ui.cpp",
|
||||
"src/authentication/dm_auth_manager.cpp",
|
||||
"src/config/dm_config_manager.cpp",
|
||||
"src/dependency/commonevent/dm_common_event_manager.cpp",
|
||||
"src/dependency/hichain/hichain_connector.cpp",
|
||||
"src/dependency/softbus/softbus_connector.cpp",
|
||||
"src/dependency/softbus/softbus_session.cpp",
|
||||
"src/dependency/timer/dm_timer.cpp",
|
||||
"src/device_manager_service.cpp",
|
||||
"src/device_manager_service_listener.cpp",
|
||||
"src/deviceinfo/dm_device_info_manager.cpp",
|
||||
"src/devicestate/dm_device_state_manager.cpp",
|
||||
"src/discovery/dm_discovery_manager.cpp",
|
||||
"src/ipc/standard/ipc_cmd_parser.cpp",
|
||||
"src/ipc/standard/ipc_server_client_proxy.cpp",
|
||||
"src/ipc/standard/ipc_server_listener.cpp",
|
||||
"src/ipc/standard/ipc_server_stub.cpp",
|
||||
"src/message/msg_codec.cpp",
|
||||
"src/message/msg_head.cpp",
|
||||
"src/message/msg_request_auth.cpp",
|
||||
"src/message/msg_response_auth.cpp",
|
||||
"src/message/msg_sync_group.cpp",
|
||||
"src/requestauth/auth_manager.cpp",
|
||||
"src/requestauth/request_session.cpp",
|
||||
"src/requestauth/response_session.cpp",
|
||||
"src/softbus/softbus_adapter.cpp",
|
||||
"src/softbus/softbus_session.cpp",
|
||||
"src/timer/dm_timer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
@@ -175,12 +104,15 @@ if (defined(ohos_lite)) {
|
||||
"appexecfwk_standard:appexecfwk_base",
|
||||
"appexecfwk_standard:appexecfwk_core",
|
||||
"appexecfwk_standard:libeventhandler",
|
||||
"ces_standard:cesfwk_core",
|
||||
"ces_standard:cesfwk_innerkits",
|
||||
"dsoftbus_standard:softbus_client",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"startup_l2:syspara",
|
||||
"startup_l2:syspara_watchagent",
|
||||
]
|
||||
|
||||
subsystem_name = "distributedhardware"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -16,37 +16,29 @@
|
||||
#ifndef OHOS_DM_ABILITY_MANAGER_H
|
||||
#define OHOS_DM_ABILITY_MANAGER_H
|
||||
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
enum AbilityRole : int32_t {
|
||||
ABILITY_ROLE_PASSIVE = 0,
|
||||
ABILITY_ROLE_INITIATIVE = 1,
|
||||
ABILITY_ROLE_UNKNOWN = 2
|
||||
};
|
||||
enum AbilityRole { ABILITY_ROLE_PASSIVE = 0, ABILITY_ROLE_INITIATIVE = 1, ABILITY_ROLE_UNKNOWN = 2 };
|
||||
|
||||
enum AbilityStatus : int32_t {
|
||||
ABILITY_STATUS_FAILED = 0,
|
||||
ABILITY_STATUS_SUCCESS = 1,
|
||||
ABILITY_STATUS_START = 2
|
||||
};
|
||||
enum AbilityStatus { ABILITY_STATUS_FAILED = 0, ABILITY_STATUS_SUCCESS = 1, ABILITY_STATUS_START = 2 };
|
||||
|
||||
typedef enum FaAction {
|
||||
enum FaAction {
|
||||
USER_OPERATION_TYPE_ALLOW_AUTH = 0,
|
||||
USER_OPERATION_TYPE_CANCEL_AUTH = 1,
|
||||
USER_OPERATION_TYPE_AUTH_CONFIRM_TIMEOUT = 2,
|
||||
USER_OPERATION_TYPE_CANCEL_PINCODE_DISPLAY = 3,
|
||||
USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT = 4
|
||||
} FaAction;
|
||||
};
|
||||
|
||||
class DmAbilityManager {
|
||||
DECLARE_SINGLE_INSTANCE(DmAbilityManager);
|
||||
public:
|
||||
AbilityRole GetAbilityRole();
|
||||
AbilityStatus StartAbility(AbilityRole role);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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_DM_CRYPTO_ADAPTER_H
|
||||
#define OHOS_DM_CRYPTO_ADAPTER_H
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class ICryptoAdapter {
|
||||
public:
|
||||
virtual ~ICryptoAdapter() = default;
|
||||
virtual std::string GetName() = 0;
|
||||
virtual std::string GetVersion() = 0;
|
||||
virtual int32_t MbedTlsEncrypt(const uint8_t *plainText, int32_t plainTextLen, uint8_t *cipherText,
|
||||
int32_t cipherTextLen, int32_t *outLen) = 0;
|
||||
virtual int32_t MbedTlsDecrypt(const uint8_t *cipherText, int32_t cipherTextLen, uint8_t *plainText,
|
||||
int32_t plainTextLen, int32_t *outLen) = 0;
|
||||
};
|
||||
|
||||
using CreateICryptoAdapterFuncPtr = ICryptoAdapter *(*)(void);
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_CRYPTO_ADAPTER_H
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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_DM_DECISION_ADAPTER_H
|
||||
#define OHOS_DM_DECISION_ADAPTER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "dm_device_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IDecisionAdapter {
|
||||
public:
|
||||
virtual ~IDecisionAdapter() = default;
|
||||
virtual std::string GetName() = 0;
|
||||
virtual std::string GetVersion() = 0;
|
||||
virtual int32_t FilterDeviceList(std::vector<DmDeviceInfo> &infoList, const std::string &filterOptions) = 0;
|
||||
virtual int32_t SortDeviceList(std::vector<DmDeviceInfo> &infoList, const std::string &sortOptions) = 0;
|
||||
};
|
||||
|
||||
using CreateIDecisionAdapterFuncPtr = IDecisionAdapter *(*)(void);
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_DECISION_ADAPTER_H
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_DM_ADAPTER_MANAGER_H
|
||||
#define OHOS_DM_ADAPTER_MANAGER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "crypto_adapter.h"
|
||||
#include "decision_adapter.h"
|
||||
#include "profile_adapter.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IProfileAdapter;
|
||||
class DmAdapterManager {
|
||||
DECLARE_SINGLE_INSTANCE(DmAdapterManager);
|
||||
|
||||
public:
|
||||
std::shared_ptr<IDecisionAdapter> GetDecisionAdapter(const std::string &soName);
|
||||
std::shared_ptr<IProfileAdapter> GetProfileAdapter(const std::string &soName);
|
||||
std::shared_ptr<ICryptoAdapter> GetCryptoAdapter(const std::string &soName);
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_ADAPTER_MANAGER_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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_DM_PROFILE_ADAPTER_H
|
||||
#define OHOS_DM_PROFILE_ADAPTER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DmDeviceStateManager;
|
||||
class IProfileAdapter {
|
||||
public:
|
||||
virtual ~IProfileAdapter() = default;
|
||||
virtual int32_t RegisterProfileListener(const std::string &pkgName, const std::string &deviceId,
|
||||
std::shared_ptr<DmDeviceStateManager> callback) = 0;
|
||||
virtual int32_t UnRegisterProfileListener(const std::string &pkgName) = 0;
|
||||
};
|
||||
|
||||
using CreateIProfileAdapterFuncPtr = IProfileAdapter *(*)(void);
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_PROFILE_ADAPTER_H
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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_DM_AUTH_MESSAGE_PROCESSOR_H
|
||||
#define OHOS_DM_AUTH_MESSAGE_PROCESSOR_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "crypto_adapter.h"
|
||||
#include "dm_auth_manager.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DmAuthManager;
|
||||
struct DmAuthRequestContext;
|
||||
struct DmAuthResponseContext;
|
||||
class ICryptoAdapter;
|
||||
class AuthMessageProcessor {
|
||||
public:
|
||||
AuthMessageProcessor(std::shared_ptr<DmAuthManager> authMgr);
|
||||
~AuthMessageProcessor();
|
||||
std::vector<std::string> CreateAuthRequestMessage();
|
||||
std::string CreateSimpleMessage(int32_t msgType);
|
||||
int32_t ParseMessage(const std::string &message);
|
||||
void SetRequestContext(std::shared_ptr<DmAuthRequestContext> authRequestContext);
|
||||
void SetResponseContext(std::shared_ptr<DmAuthResponseContext> authResponseContext);
|
||||
std::shared_ptr<DmAuthResponseContext> GetResponseContext();
|
||||
std::shared_ptr<DmAuthRequestContext> GetRequestContext();
|
||||
|
||||
private:
|
||||
std::string CreateRequestAuthMessage(nlohmann::json &json);
|
||||
void CreateNegotiateMessage(nlohmann::json &json);
|
||||
void CreateSyncGroupMessage(nlohmann::json &json);
|
||||
void CreateResponseAuthMessage(nlohmann::json &json);
|
||||
void ParseAuthResponseMessage(nlohmann::json &json);
|
||||
void ParseAuthRequestMessage();
|
||||
void ParseNegotiateMessage(const nlohmann::json &json);
|
||||
void CreateResponseFinishMessage(nlohmann::json &json);
|
||||
void ParseResponseFinishMessage(nlohmann::json &json);
|
||||
|
||||
private:
|
||||
std::weak_ptr<DmAuthManager> authMgr_;
|
||||
std::shared_ptr<ICryptoAdapter> cryptoAdapter_;
|
||||
std::shared_ptr<DmAuthRequestContext> authRequestContext_;
|
||||
std::shared_ptr<DmAuthResponseContext> authResponseContext_;
|
||||
std::vector<nlohmann::json> authSplitJsonList_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTH_MESSAGE_PROCESSOR_H
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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_DM_AUTH_REQUEST_STATE_H
|
||||
#define OHOS_DM_AUTH_REQUEST_STATE_H
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include "dm_log.h"
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DmAuthManager;
|
||||
struct DmAuthRequestContext;
|
||||
class AuthRequestState : public std::enable_shared_from_this<AuthRequestState> {
|
||||
public:
|
||||
virtual ~AuthRequestState()
|
||||
{
|
||||
authManager_.reset();
|
||||
LOGE("~AuthRequestState");
|
||||
};
|
||||
virtual int32_t GetStateType() = 0;
|
||||
virtual void Enter() = 0;
|
||||
void Leave();
|
||||
void TransitionTo(std::shared_ptr<AuthRequestState> state);
|
||||
void SetAuthManager(std::shared_ptr<DmAuthManager> authManager);
|
||||
void SetAuthContext(std::shared_ptr<DmAuthRequestContext> context);
|
||||
std::shared_ptr<DmAuthRequestContext> GetAuthContext();
|
||||
|
||||
protected:
|
||||
std::weak_ptr<DmAuthManager> authManager_;
|
||||
std::shared_ptr<DmAuthRequestContext> context_;
|
||||
};
|
||||
|
||||
class AuthRequestInitState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestNegotiateState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
class AuthRequestNegotiateDoneState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestReplyState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestInputState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestJoinState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestNetworkState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthRequestFinishState : public AuthRequestState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTH_REQUEST_STATE_H
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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_DM_AUTH_RESPONSE_STATE_H
|
||||
#define OHOS_DM_AUTH_RESPONSE_STATE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class DmAuthManager;
|
||||
struct DmAuthResponseContext;
|
||||
class AuthResponseState : public std::enable_shared_from_this<AuthResponseState> {
|
||||
public:
|
||||
virtual ~AuthResponseState()
|
||||
{
|
||||
authManager_.reset();
|
||||
};
|
||||
virtual int32_t GetStateType() = 0;
|
||||
virtual void Enter() = 0;
|
||||
void Leave();
|
||||
void TransitionTo(std::shared_ptr<AuthResponseState> state);
|
||||
void SetAuthManager(std::shared_ptr<DmAuthManager> authManager);
|
||||
void SetAuthContext(std::shared_ptr<DmAuthResponseContext> context);
|
||||
std::shared_ptr<DmAuthResponseContext> GetAuthContext();
|
||||
|
||||
protected:
|
||||
std::weak_ptr<DmAuthManager> authManager_;
|
||||
std::shared_ptr<DmAuthResponseContext> context_;
|
||||
};
|
||||
|
||||
class AuthResponseInitState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthResponseNegotiateState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthResponseConfirmState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthResponseGroupState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthResponseShowState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
|
||||
class AuthResponseFinishState : public AuthResponseState {
|
||||
public:
|
||||
int32_t GetStateType() override;
|
||||
void Enter() override;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTH_RESPONSE_STATE_H
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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_DM_AUTH_UI_H
|
||||
#define OHOS_DM_AUTH_UI_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "dm_ability_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class AuthUi {
|
||||
public:
|
||||
AuthUi();
|
||||
int32_t ShowConfirmDialog(std::shared_ptr<DmAbilityManager> dmAbilityManager);
|
||||
|
||||
private:
|
||||
int32_t StartFaService();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DmAbilityManager> dmAbilityMgr_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTH_UI_H
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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_DM_AUTHENTICATION_H
|
||||
#define OHOS_DM_AUTHENTICATION_H
|
||||
|
||||
#include "dm_ability_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IAuthentication {
|
||||
public:
|
||||
virtual ~IAuthentication() = default;
|
||||
virtual int32_t ShowAuthInfo() = 0;
|
||||
virtual int32_t StartAuth(std::shared_ptr<DmAbilityManager> dmAbilityManager) = 0;
|
||||
virtual int32_t VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam) = 0;
|
||||
};
|
||||
|
||||
using CreateIAuthAdapterFuncPtr = IAuthentication *(*)(void);
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTHENTICATION_H
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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_DM_AUTH_MANAGER_H
|
||||
#define OHOS_DM_AUTH_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "auth_request_state.h"
|
||||
#include "auth_response_state.h"
|
||||
#include "auth_ui.h"
|
||||
#include "authentication.h"
|
||||
#include "device_manager_service_listener.h"
|
||||
#include "dm_ability_manager.h"
|
||||
#include "dm_adapter_manager.h"
|
||||
#include "dm_constants.h"
|
||||
#include "dm_device_info.h"
|
||||
#include "dm_timer.h"
|
||||
#include "hichain_connector.h"
|
||||
#include "softbus_connector.h"
|
||||
#include "softbus_session.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
typedef enum AuthState {
|
||||
AUTH_REQUEST_INIT = 1,
|
||||
AUTH_REQUEST_NEGOTIATE,
|
||||
AUTH_REQUEST_NEGOTIATE_DONE,
|
||||
AUTH_REQUEST_REPLY,
|
||||
AUTH_REQUEST_INPUT,
|
||||
AUTH_REQUEST_JOIN,
|
||||
AUTH_REQUEST_NETWORK,
|
||||
AUTH_REQUEST_FINISH,
|
||||
AUTH_RESPONSE_INIT = 20,
|
||||
AUTH_RESPONSE_NEGOTIATE,
|
||||
AUTH_RESPONSE_CONFIRM,
|
||||
AUTH_RESPONSE_GROUP,
|
||||
AUTH_RESPONSE_SHOW,
|
||||
AUTH_RESPONSE_FINISH,
|
||||
} AuthState;
|
||||
|
||||
enum DmMsgType : int32_t {
|
||||
MSG_TYPE_UNKNOWN = 0,
|
||||
MSG_TYPE_NEGOTIATE = 80,
|
||||
MSG_TYPE_RESP_NEGOTIATE = 90,
|
||||
MSG_TYPE_REQ_AUTH = 100,
|
||||
MSG_TYPE_INVITE_AUTH_INFO = 102,
|
||||
MSG_TYPE_REQ_AUTH_TERMINATE = 104,
|
||||
MSG_TYPE_RESP_AUTH = 200,
|
||||
MSG_TYPE_JOIN_AUTH_INFO = 201,
|
||||
MSG_TYPE_RESP_AUTH_TERMINATE = 205,
|
||||
MSG_TYPE_CHANNEL_CLOSED = 300,
|
||||
MSG_TYPE_SYNC_GROUP = 400,
|
||||
MSG_TYPE_AUTH_BY_PIN = 500,
|
||||
};
|
||||
|
||||
typedef struct DmAuthRequestContext {
|
||||
int32_t authType;
|
||||
std::string localDeviceId;
|
||||
std::string deviceId;
|
||||
std::string deviceName;
|
||||
std::string deviceTypeId;
|
||||
int32_t sessionId;
|
||||
int32_t groupVisibility;
|
||||
bool cryptoSupport;
|
||||
std::string cryptoName;
|
||||
std::string cryptoVer;
|
||||
std::string hostPkgName;
|
||||
std::string targetPkgName;
|
||||
std::string appName;
|
||||
std::string appDesc;
|
||||
std::string appIcon;
|
||||
std::string appThumbnail;
|
||||
std::string token;
|
||||
int32_t reason;
|
||||
std::vector<std::string> syncGroupList;
|
||||
} DmAuthRequestContext;
|
||||
|
||||
typedef struct DmAuthResponseContext {
|
||||
int32_t authType;
|
||||
std::string deviceId;
|
||||
std::string localDeviceId;
|
||||
int32_t msgType;
|
||||
int32_t sessionId;
|
||||
bool cryptoSupport;
|
||||
std::string cryptoName;
|
||||
std::string cryptoVer;
|
||||
int32_t reply;
|
||||
std::string networkId;
|
||||
std::string groupId;
|
||||
std::string groupName;
|
||||
std::string hostPkgName;
|
||||
std::string targetPkgName;
|
||||
std::string appName;
|
||||
std::string appDesc;
|
||||
std::string appIcon;
|
||||
std::string appThumbnail;
|
||||
std::string token;
|
||||
int64_t requestId;
|
||||
int32_t code;
|
||||
int32_t state;
|
||||
std::vector<std::string> syncGroupList;
|
||||
} DmAuthResponseContext;
|
||||
|
||||
class AuthMessageProcessor;
|
||||
|
||||
class DmAuthManager final : public ISoftbusSessionCallback,
|
||||
public IHiChainConnectorCallback,
|
||||
public std::enable_shared_from_this<DmAuthManager> {
|
||||
public:
|
||||
DmAuthManager(std::shared_ptr<SoftbusConnector> softbusConnector,
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener);
|
||||
~DmAuthManager();
|
||||
int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
|
||||
const std::string &extra);
|
||||
int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId);
|
||||
int32_t VerifyAuthentication(const std::string &authParam);
|
||||
void OnSessionOpened(const std::string &pkgName, int32_t sessionId, int32_t sessionSide, int32_t result);
|
||||
void OnSessionClosed(const std::string &pkgName, int32_t sessionId);
|
||||
void OnDataReceived(const std::string &pkgName, int32_t sessionId, std::string message);
|
||||
void OnGroupCreated(int64_t requestId, const std::string &groupId);
|
||||
void OnMemberJoin(int64_t requestId, int32_t status);
|
||||
|
||||
// auth state machine
|
||||
void EstablishAuthChannel(const std::string &deviceId);
|
||||
void StartNegotiate(const int32_t &sessionId);
|
||||
void RespNegotiate(const int32_t &sessionId);
|
||||
void SendAuthRequest(const int32_t &sessionId);
|
||||
void StartAuthProcess(const int32_t &authType);
|
||||
void StartRespAuthProcess();
|
||||
void CreateGroup();
|
||||
void AddMember(const std::string &deviceId);
|
||||
std::string GetConnectAddr(std::string deviceId);
|
||||
void JoinNetwork();
|
||||
void AuthenticateFinish();
|
||||
void GetIsCryptoSupport(bool &isCryptoSupport);
|
||||
void SetAuthRequestState(std::shared_ptr<AuthRequestState> authRequestState);
|
||||
void SetAuthResponseState(std::shared_ptr<AuthResponseState> authResponseState);
|
||||
int32_t GetPinCode();
|
||||
std::string GenerateGroupName();
|
||||
void HandleAuthenticateTimeout();
|
||||
void CancelDisplay();
|
||||
int32_t GeneratePincode();
|
||||
void ShowConfigDialog();
|
||||
void ShowAuthInfoDialog();
|
||||
void ShowStartAuthDialog();
|
||||
int32_t GetAuthenticationParam(DmAuthParam &authParam);
|
||||
int32_t RegisterSessionCallback();
|
||||
int32_t OnUserOperation(int32_t action);
|
||||
|
||||
private:
|
||||
std::shared_ptr<SoftbusConnector> softbusConnector_;
|
||||
std::shared_ptr<HiChainConnector> hiChainConnector_;
|
||||
std::shared_ptr<DeviceManagerServiceListener> listener_;
|
||||
std::shared_ptr<DmAdapterManager> adapterMgr_;
|
||||
std::map<int32_t, std::shared_ptr<IAuthentication>> authenticationMap_;
|
||||
std::shared_ptr<AuthRequestState> authRequestState_ = nullptr;
|
||||
std::shared_ptr<AuthResponseState> authResponseState_ = nullptr;
|
||||
std::shared_ptr<DmAuthRequestContext> authRequestContext_;
|
||||
std::shared_ptr<DmAuthResponseContext> authResponseContext_;
|
||||
std::shared_ptr<AuthMessageProcessor> authMessageProcessor_;
|
||||
std::map<std::string, std::shared_ptr<DmTimer>> timerMap_;
|
||||
std::shared_ptr<DmAbilityManager> dmAbilityMgr_;
|
||||
bool isCryptoSupport_ = false;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_AUTH_MANAGER_H
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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_OHOS_DM_CONFIG_MANAGER_H
|
||||
#define OHOS_OHOS_DM_CONFIG_MANAGER_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "authentication.h"
|
||||
#include "crypto_adapter.h"
|
||||
#include "decision_adapter.h"
|
||||
#include "profile_adapter.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
typedef struct {
|
||||
std::string name;
|
||||
std::string type;
|
||||
std::string version;
|
||||
std::string funcName;
|
||||
std::string soName;
|
||||
std::string soPath;
|
||||
} AdapterSoLoadInfo;
|
||||
|
||||
typedef struct {
|
||||
int32_t authType;
|
||||
std::string name;
|
||||
std::string type;
|
||||
std::string version;
|
||||
std::string funcName;
|
||||
std::string soName;
|
||||
std::string soPath;
|
||||
} AuthSoLoadInfo;
|
||||
|
||||
class DmConfigManager final {
|
||||
DECLARE_SINGLE_INSTANCE_BASE(DmConfigManager);
|
||||
|
||||
public:
|
||||
~DmConfigManager();
|
||||
void GetAllAuthType(std::vector<std::string> &allAuthType);
|
||||
std::shared_ptr<IDecisionAdapter> GetDecisionAdapter(const std::string &soName);
|
||||
std::shared_ptr<IProfileAdapter> GetProfileAdapter(const std::string &soName);
|
||||
std::shared_ptr<ICryptoAdapter> GetCryptoAdapter(const std::string &soName);
|
||||
void GetAuthAdapter(std::map<int32_t, std::shared_ptr<IAuthentication>> &authAdapter);
|
||||
|
||||
private:
|
||||
DmConfigManager();
|
||||
|
||||
private:
|
||||
std::mutex authAdapterMutex_;
|
||||
std::mutex cryptoAdapterMutex_;
|
||||
std::mutex decisionAdapterMutex_;
|
||||
std::mutex profileAdapterMutex_;
|
||||
std::map<int32_t, AuthSoLoadInfo> soAuthLoadInfo_;
|
||||
std::map<std::string, AdapterSoLoadInfo> soAdapterLoadInfo_;
|
||||
std::map<std::string, std::shared_ptr<IDecisionAdapter>> decisionAdapterPtr_;
|
||||
std::map<std::string, std::shared_ptr<IProfileAdapter>> profileAdapterPtr_;
|
||||
std::map<std::string, std::shared_ptr<ICryptoAdapter>> cryptoAdapterPtr_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_OHOS_DM_CONFIG_MANAGER_H
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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_OHOS_DM_JSON_CONFIG_H
|
||||
#define OHOS_OHOS_DM_JSON_CONFIG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
const std::string adapterJsonConfigString =
|
||||
R"({
|
||||
"devicemanager_adapter_components": [
|
||||
{
|
||||
"name": "crypto_adapter",
|
||||
"type": "CPYPTO",
|
||||
"version": "1.0",
|
||||
"funcName": "CreateCryptoAdapterObject",
|
||||
"soName": "libdevicemanager_crypto_adapter.z.so",
|
||||
"soPath": "/system/lib/"
|
||||
},
|
||||
{
|
||||
"name": "device_profile",
|
||||
"type": "PROFILE",
|
||||
"version": "1.0",
|
||||
"funcName": "CreateDeviceProfileObject",
|
||||
"soName": "libdevicemanagerext_profile.z.so",
|
||||
"soPath": "/system/lib/"
|
||||
}
|
||||
]
|
||||
})";
|
||||
|
||||
const std::string authJsonConfigString =
|
||||
R"({
|
||||
"devicemanager_auth_components": [
|
||||
{
|
||||
"name": "pin_auth",
|
||||
"type": "AUTHENTICATE",
|
||||
"version": "1.0",
|
||||
"authType": 1,
|
||||
"funcName": "CreatePinAuthObject",
|
||||
"soName": "libdevicemanagerext_pin_auth.z.so",
|
||||
"soPath": "/system/lib/"
|
||||
},
|
||||
{
|
||||
"name": "QRcode_auth",
|
||||
"type": "AUTHENTICATE",
|
||||
"version": "1.0",
|
||||
"authType": 2,
|
||||
"funcName": "CreateQRcodeAuthObject",
|
||||
"soName": "libdevicemanager_qrcodeauth.z.so",
|
||||
"soPath": "/system/lib/"
|
||||
},
|
||||
{
|
||||
"name": "nfc_auth",
|
||||
"type": "AUTHENTICATE",
|
||||
"version": "1.0",
|
||||
"authType": 3,
|
||||
"funcName": "CreateNfcAuthObject",
|
||||
"soName": "libdevicemanager_nfcauth.z.so",
|
||||
"soPath": "/system/lib/"
|
||||
}
|
||||
]
|
||||
})";
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_OHOS_DM_JSON_CONFIG_H
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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_EVENT_MANAGER_ADAPT_H
|
||||
#define OHOS_EVENT_MANAGER_ADAPT_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
#include "common_event.h"
|
||||
#include "common_event_data.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_subscribe_info.h"
|
||||
#include "common_event_subscriber.h"
|
||||
#include "dm_log.h"
|
||||
#include "matching_skills.h"
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
using CommomEventCallback = void (*)(void);
|
||||
|
||||
class DmCommonEventManager {
|
||||
DECLARE_SINGLE_INSTANCE_BASE(DmCommonEventManager);
|
||||
public:
|
||||
bool SubscribeServiceEvent(const std::string &event, CommomEventCallback callback);
|
||||
bool UnsubscribeServiceEvent(const std::string &event);
|
||||
void Test(const std::string &event);
|
||||
class EventSubscriber : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
EventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo, CommomEventCallback callback,
|
||||
std::string event) : EventFwk::CommonEventSubscriber(subscribeInfo), callback_(callback), event_(event) {}
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData &data);
|
||||
void TestCommonEvent(const std::string &event);
|
||||
private:
|
||||
CommomEventCallback callback_;
|
||||
std::string event_;
|
||||
};
|
||||
private:
|
||||
DmCommonEventManager();
|
||||
~DmCommonEventManager();
|
||||
private:
|
||||
static void DealCallback(void);
|
||||
private:
|
||||
static std::mutex callbackQueueMutex_;
|
||||
static std::mutex eventSubscriberMutex_;
|
||||
static std::condition_variable notEmpty_;
|
||||
static std::list<CommomEventCallback> callbackQueue_;
|
||||
std::map<std::string, std::shared_ptr<EventSubscriber>> dmEventSubscriber_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_EVENT_MANAGER_ADAPT_H
|
||||
+29
-44
@@ -4,7 +4,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -16,26 +16,19 @@
|
||||
#ifndef OHOS_HICHAIN_CONNECTOR_H
|
||||
#define OHOS_HICHAIN_CONNECTOR_H
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "device_auth.h"
|
||||
|
||||
#include "hichain_connector_callback.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "single_instance.h"
|
||||
#include "msg_response_auth.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
enum {
|
||||
HICHAIN_SUCCESS = 0,
|
||||
GROUP_CREATE_FAILED = 1,
|
||||
MEMBER_ADD_FAILED = 2,
|
||||
CREATE_CHANNEL_FAILED = 3,
|
||||
};
|
||||
|
||||
struct GroupInfo {
|
||||
std::string groupName;
|
||||
std::string groupId;
|
||||
@@ -43,54 +36,46 @@ struct GroupInfo {
|
||||
int32_t groupType;
|
||||
int32_t groupVisibility;
|
||||
|
||||
GroupInfo() : groupName(""), groupId(""), groupOwner(""), groupType(0), groupVisibility(0) {}
|
||||
GroupInfo() : groupName(""), groupId(""), groupOwner(""), groupType(0), groupVisibility(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void from_json(const nlohmann::json& jsonObject, GroupInfo& groupInfo);
|
||||
void from_json(const nlohmann::json &jsonObject, GroupInfo &groupInfo);
|
||||
|
||||
class HichainConnectorCallback {
|
||||
public:
|
||||
virtual void OnGroupCreated(int64_t requestId, const std::string &groupId) = 0;
|
||||
virtual void OnMemberJoin(int64_t requestId, int32_t status) = 0;
|
||||
};
|
||||
|
||||
class HichainAuthenCallBack {
|
||||
class HiChainConnector {
|
||||
public:
|
||||
static bool onTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen);
|
||||
static void onSessionKeyReturned(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen);
|
||||
static void onFinish(int64_t requestId, int32_t operationCode, const char *returnData);
|
||||
static void onError(int64_t requestId, int32_t operationCode, int32_t errorCode, const char *errorReturn);
|
||||
static char *onRequest(int64_t requestId, int32_t operationCode, const char *reqParams);
|
||||
};
|
||||
|
||||
class HichainConnector {
|
||||
DECLARE_SINGLE_INSTANCE(HichainConnector);
|
||||
public:
|
||||
int32_t Init();
|
||||
bool OnTransmit(int64_t requestId, const uint8_t *data, uint32_t dataLen);
|
||||
int64_t GenRequestId();
|
||||
void RegisterConnectorCallback(std::shared_ptr<HichainConnectorCallback> callback);
|
||||
HiChainConnector();
|
||||
~HiChainConnector();
|
||||
int32_t RegisterHiChainCallback(const std::string &pkgName, std::shared_ptr<IHiChainConnectorCallback> callback);
|
||||
int32_t UnRegisterHiChainCallback(const std::string &pkgName);
|
||||
int32_t CreateGroup(int64_t requestId, const std::string &groupName);
|
||||
int32_t AddMemeber(std::string deviceId, std::shared_ptr<MsgResponseAuth> msgResponseAuth);
|
||||
void GetRelatedGroups(std::string DeviceId, std::vector<GroupInfo> &groupList);
|
||||
void SyncGroups(std::string deviceId, std::vector<std::string> &remoteGroupIdList);
|
||||
int32_t AddMember(std::string deviceId, std::string &connectInfo);
|
||||
int32_t DelMemberFromGroup(std::string groupId, std::string deviceId);
|
||||
void DeleteGroup(std::string &groupId);
|
||||
void OnGroupCreated(int64_t requestId, const std::string &returnData);
|
||||
void GetSyncGroupList(std::vector<GroupInfo> &groupList, std::vector<std::string> &syncGroupList);
|
||||
void OnMemberJoin(int64_t requestId, int32_t status);
|
||||
int32_t GetGroupInfo(std::string queryParams, std::vector<GroupInfo> &groupList);
|
||||
int32_t IsGroupCreated(std::string groupName, GroupInfo &groupInfo);
|
||||
int32_t DeleteGroup(std::string &groupId);
|
||||
bool IsDevicesInGroup(std::string hostDevice, std::string peerDevice);
|
||||
int32_t GetRelatedGroups(std::string DeviceId, std::vector<GroupInfo> &groupList);
|
||||
|
||||
private:
|
||||
std::string GetConnectPara(std::string deviceId, std::shared_ptr<MsgResponseAuth> msgResponseAuth);
|
||||
int64_t GenRequestId();
|
||||
int32_t SyncGroups(std::string deviceId, std::vector<std::string> &remoteGroupIdList);
|
||||
int32_t GetSyncGroupList(std::vector<GroupInfo> &groupList, std::vector<std::string> &syncGroupList);
|
||||
int32_t GetGroupInfo(std::string queryParams, std::vector<GroupInfo> &groupList);
|
||||
std::string GetConnectPara(std::string deviceId, std::string reqDeviceId);
|
||||
bool IsGroupCreated(std::string groupName, GroupInfo &groupInfo);
|
||||
bool IsGroupInfoInvalid(GroupInfo &group);
|
||||
|
||||
private:
|
||||
std::shared_ptr<HichainConnectorCallback> hichainConnectorCallback_ = nullptr;
|
||||
const DeviceGroupManager *deviceGroupManager_ = nullptr;
|
||||
DeviceAuthCallback deviceAuthCallback_ ;
|
||||
DeviceAuthCallback deviceAuthCallback_;
|
||||
static std::map<std::string, std::shared_ptr<IHiChainConnectorCallback>> hiChainConnectorCallbackMap_;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_HICHAIN_ADAPTER_H
|
||||
#endif // OHOS_HICHAIN_CONNECTOR_H
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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_DM_HICHAIN_CONNECTOR_CALLBACK_H
|
||||
#define OHOS_DM_HICHAIN_CONNECTOR_CALLBACK_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
class IHiChainConnectorCallback {
|
||||
public:
|
||||
virtual void OnGroupCreated(int64_t requestId, const std::string &groupId) = 0;
|
||||
virtual void OnMemberJoin(int64_t requestId, int32_t status) = 0;
|
||||
virtual std::string GetConnectAddr(std::string deviceId) = 0;
|
||||
virtual int32_t GetPinCode() = 0;
|
||||
};
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DM_HICHAIN_CONNECTOR_CALLBACK_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user