diff --git a/dsoftbus/depend/BUILD.gn b/dsoftbus/depend/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..613a3c33ac09f9137430973c6789f3df0f5bb404 --- /dev/null +++ b/dsoftbus/depend/BUILD.gn @@ -0,0 +1,48 @@ +import("//build/ohos.gni") + +config("device_auth_config") { + include_dirs = [ "device_auth/include" ] +} + +ohos_shared_library("deviceauth_sdk") { + sources = [ "device_auth/device_auth.c" ] + public_configs = [ ":device_auth_config" ] +} + +config("hilog_config") { + include_dirs = [ "hilog/include" ] +} + +ohos_shared_library("libhilog") { + public_configs = [ ":hilog_config" ] +} + +config("ipc_config") { + include_dirs = [ "ipc/include", "//utils/native/base/include" ] +} + +ohos_shared_library("ipc_single") { + public_configs = [ ":ipc_config" ] +} + +group("ipc_core") { + public_configs = [ ":ipc_config" ] +} + +group("system_ability_fwk") { +} + +group("samgr_proxy") { +} + +group("libpermissionsdk_standard") { +} + +group("cesfwk_innerkits") { +} + +group("want") { +} + +group("appexecfwk_core") { +} diff --git a/dsoftbus/depend/device_auth/device_auth.c b/dsoftbus/depend/device_auth/device_auth.c new file mode 100644 index 0000000000000000000000000000000000000000..395449c35980e82bfaf194c06ddf1644457775fe --- /dev/null +++ b/dsoftbus/depend/device_auth/device_auth.c @@ -0,0 +1,59 @@ +#include +#include "device_auth.h" + +#define AUTH_START "auth_start" +#define AUTH_END "auth_end" + +#define KEY_LEN 33 +const uint8_t sessionkey_default[KEY_LEN]="01234567890123456789012345678901"; + +static int32_t ProcessData(int64_t authReqId, const uint8_t *data, uint32_t datalen, + const DeviceAuthCallback *callback) +{ + if (!strncmp((const char *)data, AUTH_START, strlen(AUTH_START))) { + callback->onTransmit(authReqId, (const uint8_t *)AUTH_END, strlen(AUTH_END)); + } + callback->onSessionKeyReturned(authReqId, sessionkey_default, KEY_LEN - 1); + return 0; +} + + +static int32_t AuthDevice(int64_t authReqId, const char *authParams, + const DeviceAuthCallback *callback) +{ + callback->onTransmit(authReqId, (const uint8_t *)AUTH_START, strlen(AUTH_START)); + return 0; +} + +static int32_t RegDataChangeListener(const char* appId, const DataChangeListener *listener) +{ + return 0; +} + +static GroupAuthManager g_groupAuthManager = { + .processData = ProcessData, + .authDevice = AuthDevice, +}; + +static DeviceGroupManager g_deviceGroupManager = { + .regDataChangeListener = RegDataChangeListener, +}; + +const GroupAuthManager *GetGaInstance(void) +{ + return (const GroupAuthManager *)&g_groupAuthManager; +} + +const DeviceGroupManager *GetGmInstance(void) +{ + return (const DeviceGroupManager *)&g_deviceGroupManager; +} + +int InitDeviceAuthService(void) +{ + return 0; +} + +void DestroyDeviceAuthService(void) +{ +} diff --git a/dsoftbus/depend/device_auth/include/device_auth.h b/dsoftbus/depend/device_auth/include/device_auth.h new file mode 100644 index 0000000000000000000000000000000000000000..200705eaa8a94cba5dfe7cffdcb40963e0073ebd --- /dev/null +++ b/dsoftbus/depend/device_auth/include/device_auth.h @@ -0,0 +1,41 @@ +#ifndef _DEVICE_AUTH_H +#define _DEVICE_AUTH_H + +#include +#include + +#define FIELD_PEER_CONN_DEVICE_ID "peerConnDeviceId" +#define FIELD_SERVICE_PKG_NAME "servicePkgName" +#define FIELD_IS_CLIENT "isClient" +#define FIELD_KEY_LENGTH "keyLength" +#define FIELD_CONFIRMATION "confirmation" + +#define REQUEST_ACCEPTED 0x80000006 + +typedef struct { + bool (*onTransmit)(int64_t requestId, const uint8_t *data, uint32_t dataLen); + void (*onSessionKeyReturned)(int64_t requestId, const uint8_t *sessionKey, uint32_t sessionKeyLen); + void (*onFinish)(int64_t requestId, int operationCode, const char *returnData); + void (*onError)(int64_t requestId, int operationCode, int errorCode, const char *errorReturn); + char *(*onRequest)(int64_t requestId, int operationCode, const char *reqParams); +} DeviceAuthCallback; + +typedef struct { + int32_t (*processData)(int64_t authReqId, const uint8_t *data, uint32_t dataLen, const DeviceAuthCallback *gaCallback); + int32_t (*authDevice)(int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback); +} GroupAuthManager; + +typedef struct { + void (*onDeviceNotTrusted)(const char *peerUdid); +} DataChangeListener; + +typedef struct { + int32_t (*regDataChangeListener)(const char *appId, const DataChangeListener *listener); +} DeviceGroupManager; + +int InitDeviceAuthService(void); +void DestroyDeviceAuthService(void); +const GroupAuthManager *GetGaInstance(void); +const DeviceGroupManager *GetGmInstance(void); + +#endif diff --git a/dsoftbus/depend/hilog/include/hilog/log.h b/dsoftbus/depend/hilog/include/hilog/log.h new file mode 100644 index 0000000000000000000000000000000000000000..47118811f63388628a698cb17290c50e7aa29e17 --- /dev/null +++ b/dsoftbus/depend/hilog/include/hilog/log.h @@ -0,0 +1,11 @@ +#ifndef _HILOG_H +#define _HILOG_H + +#include + +#define HILOG_DEBUG(type, fmt, ...) printf(fmt, ##__VA_ARGS__) +#define HILOG_INFO(type, fmt, ...) printf(fmt, ##__VA_ARGS__) +#define HILOG_WARN(type, fmt, ...) printf(fmt, ##__VA_ARGS__) +#define HILOG_ERROR(type, fmt, ...) printf(fmt, ##__VA_ARGS__) + +#endif diff --git a/dsoftbus/depend/ipc/include/depend.h b/dsoftbus/depend/ipc/include/depend.h new file mode 100644 index 0000000000000000000000000000000000000000..50cf6c78d9c7ca8224cd19d8f42e5f2b9639906a --- /dev/null +++ b/dsoftbus/depend/ipc/include/depend.h @@ -0,0 +1,118 @@ +#ifndef _DEPEND_CPP_H +#define _DEPEND_CPP_H + +//IRemoteBroker +#ifdef __cplusplus +#include +#include +#include +#include +#include "parcel.h" + +typedef enum TypePermissionState { + PERMISSION_NOT_GRANTED = -1, + PERMISSION_GRANTED = 0, +} PermissionState; + +#define DECLARE_SYSTEM_ABILITY(className) \ + public: \ + virtual std::string GetClassName() override { \ + return #className; \ + } + +#define DECLARE_BASE_SYSTEM_ABILITY(className) \ + public: \ + virtual std::string GetClassName() = 0; + +namespace OHOS { +namespace Security { +namespace Permission { +}; +}; + +#define REGISTER_SYSTEM_ABILITY_BY_ID(abilityClassName, systemAbilityId, runOnCreate) \ + const bool abilityClassName##_##RegisterResult = \ + SystemAbility::MakeAndRegisterAbility(new abilityClassName(systemAbilityId, runOnCreate)); + +enum { + SOFTBUS_SERVER_SA_ID = 4700, +}; + +template class BrokerDelegator { +}; + +class IRemoteObject; + +class MessageParcel : public Parcel { +public: + bool WriteFileDescriptor(int fd) {return true;} + bool WriteRawData(const void *data, size_t size) {return true;} + void *ReadRawData(size_t size) {return NULL;} + sptr ReadRemoteObject() {return NULL;} + int ReadFileDescriptor() {return 0;} +}; + +class MessageOption { +}; + +class IRemoteBroker { +#define DECLARE_INTERFACE_DESCRIPTOR(DESCRIPTOR) \ + static inline const std::u16string metaDescriptor_ = {DESCRIPTOR}; \ + static inline const std::u16string &GetDescriptor() \ + { \ + return metaDescriptor_; \ + } +}; + +class IRemoteObject : public virtual Parcelable { + public: + virtual int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {return 0;} + class DeathRecipient : public RefBase { + public: + virtual void OnRemoteDied(const wptr &object) {}; + }; + virtual bool RemoveDeathRecipient(const sptr &recipient) {return true;}; + virtual bool AddDeathRecipient(const sptr &recipient) {return true;}; + virtual bool Marshalling(Parcel &parcel) const override {return true;} +}; + +template class IRemoteProxy: public INTERFACE, public virtual RefBase { + public: + IRemoteProxy(const sptr &object) { + } + sptr Remote() {return NULL;} +}; + +class IPCObjectStub : public IRemoteObject { + public: + virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {return 0;} +}; + +template class IRemoteStub: public IPCObjectStub, public INTERFACE { + public: + virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {return 0;} +}; + +class IPCSkeleton { + public: + static sptr GetContextObject() {return NULL;} + static pid_t GetCallingPid() {return 0;} + static pid_t GetCallingUid() {return 0;} +}; + +class SystemAbility { + DECLARE_BASE_SYSTEM_ABILITY(SystemAbility); + public: + static bool MakeAndRegisterAbility(SystemAbility* systemAbility) {return true;} + bool Publish(sptr systemAbility) {return true;} + protected: + SystemAbility(bool runOnCreate = false) {} + SystemAbility(int32_t systemAbilityId, bool runOnCreate = false) {} + virtual void OnStart() = 0; + virtual void OnStop() = 0; +}; + +}; +#endif + +#endif diff --git a/dsoftbus/depend/ipc/include/ipc_skeleton.h b/dsoftbus/depend/ipc/include/ipc_skeleton.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/ipc_skeleton.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/ipc_types.h b/dsoftbus/depend/ipc/include/ipc_types.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/ipc_types.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/iremote_broker.h b/dsoftbus/depend/ipc/include/iremote_broker.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/iremote_broker.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/iremote_object.h b/dsoftbus/depend/ipc/include/iremote_object.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/iremote_object.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/iremote_parcel.h b/dsoftbus/depend/ipc/include/iremote_parcel.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/iremote_parcel.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/iremote_proxy.h b/dsoftbus/depend/ipc/include/iremote_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/iremote_proxy.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/iremote_stub.h b/dsoftbus/depend/ipc/include/iremote_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/iremote_stub.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/message_parcel.h b/dsoftbus/depend/ipc/include/message_parcel.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/message_parcel.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/system_ability.h b/dsoftbus/depend/ipc/include/system_ability.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/system_ability.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ipc/include/system_ability_definition.h b/dsoftbus/depend/ipc/include/system_ability_definition.h new file mode 100644 index 0000000000000000000000000000000000000000..f2e4d5342eb41f3f2c53911f0de9a2764d721479 --- /dev/null +++ b/dsoftbus/depend/ipc/include/system_ability_definition.h @@ -0,0 +1 @@ +#include "depend.h" diff --git a/dsoftbus/depend/ohos.build b/dsoftbus/depend/ohos.build new file mode 100644 index 0000000000000000000000000000000000000000..33673a313e5ada20432572a0835d7fbfa5b63953 --- /dev/null +++ b/dsoftbus/depend/ohos.build @@ -0,0 +1,121 @@ +{ + "subsystem": "depend", + "parts": { + "hiviewdfx_hilog_native": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:libhilog", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "ipc": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:ipc_single", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + }, + { + "name":"//depend:ipc_core", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "ces_standard": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:cesfwk_innerkits", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "aafwk_standard": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:want", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "appexecfwk_standard": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:appexecfwk_core", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "deviceauth_standard": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:deviceauth_sdk", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "permission_standard": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:libpermissionsdk_standard", + "header": { + "header_files": [ ], + "header_base":"//depend" + } + } + ] + }, + "safwk": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:system_ability_fwk", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + }, + "samgr_L2": { + "module_list": [ ], + "inner_kits": [ + { + "name": "//depend:samgr_proxy", + "header": { + "header_files": [ ], + "header_base": "//depend" + } + } + ] + } + } +} +