diff --git a/display/@ohos.distributedHardware.deviceManager.d.ts b/display/@ohos.distributedHardware.deviceManager.d.ts index 604936a6..69179ba1 100644 --- a/display/@ohos.distributedHardware.deviceManager.d.ts +++ b/display/@ohos.distributedHardware.deviceManager.d.ts @@ -15,9 +15,18 @@ import { AsyncCallback, Callback } from './basic'; +/** + * Providers interfaces to creat a {@link deviceManager} instances. + * + * @since 7 + * @Syscap SystemCapability.DISTRIBUTEDHARDWARE.deviceManager + * + */ declare namespace deviceManager { /** * DeviceInfo + * + * @systemapi this method can be used only by system applications. */ interface DeviceInfo { /** @@ -34,6 +43,13 @@ declare namespace deviceManager { * Device type of the device. */ deviceType: DeviceType; + + /** + * NetworkId of the device. + * + * @since 8 + */ + networkId: string; } /** @@ -78,6 +94,8 @@ declare namespace deviceManager { /** * Device state change event definition + * + * @systemapi this method can be used only by system applications. */ enum DeviceStateChangeAction { /** @@ -221,9 +239,14 @@ declare namespace deviceManager { */ enum SubscribeCap { /** - * ddmpCapability + * ddmpCapability, will be discarded later. Currently, it will be converted to OSD capability inner. */ - SUBSCRIBE_CAPABILITY_DDMP = 0 + SUBSCRIBE_CAPABILITY_DDMP = 0, + + /** + * One Super Device Capability + */ + SUBSCRIBE_CAPABILITY_OSD = 1 } /** @@ -237,21 +260,10 @@ declare namespace deviceManager { */ authType: number; - /** - * App application Icon. - */ - appIcon?: Uint8Array; - - /** - * App application thumbnail. - */ - appThumbnail?: Uint8Array; - /** * Authentication extra infos. */ extraInfo: {[key:string] : any}; - } /** @@ -276,38 +288,6 @@ declare namespace deviceManager { extraInfo: {[key:string] : any}; } - /** - * User Operation Action from devicemanager Fa. - * - * @systemapi this method can be used only by system applications. - */ - enum UserOperationAction { - /** - * allow authentication - */ - ACTION_ALLOW_AUTH = 0, - - /** - * cancel authentication - */ - ACTION_CANCEL_AUTH = 1, - - /** - * user operation timeout for authentication confirm - */ - ACTION_AUTH_CONFIRM_TIMEOUT = 2, - - /** - * cancel pincode display - */ - ACTION_CANCEL_PINCODE_DISPLAY = 3, - - /** - * cancel pincode input - */ - ACTION_CANCEL_PINCODE_INPUT = 4, - } - /** * Creates a {@code DeviceManager} instance. * @@ -316,6 +296,7 @@ declare namespace deviceManager { * * @param bundleName Indicates the bundle name of the application. * @param callback Indicates the callback to be invoked upon {@code DeviceManager} instance creation. + * @systemapi this method can be used only by system applications. */ function createDeviceManager(bundleName: string, callback: AsyncCallback): void; @@ -325,23 +306,69 @@ declare namespace deviceManager { interface DeviceManager { /** * Releases the {@code DeviceManager} instance after the methods for device management are no longer used. + * + * @systemapi this method can be used only by system applications. */ release(): void; /** * Obtains a list of trusted devices. * - * @param options Indicates the extra parameters to be passed to this method for device filtering or sorting. - * This parameter can be null. For details about available values, see {@link #TARGET_PACKAGE_NAME} and - * {@link #SORT_TYPE}. * @return Returns a list of trusted devices. + * @systemapi this method can be used only by system applications. */ getTrustedDeviceListSync(): Array; + /** + * Obtains a list of trusted devices. + * + * @since 8 + * @param callback Indicates the callback to be invoked upon getTrustedDeviceList + * @return Returns a list of trusted devices. + * @systemapi this method can be used only by system applications. + */ + getTrustedDeviceList(callback:AsyncCallback>): void; + + /** + * Obtains a list of trusted devices. + * + * @since 8 + * @return Returns a list of trusted devices. + * @systemapi this method can be used only by system applications. + */ + getTrustedDeviceList(): Promise>; + + /** + * Obtains local device info + * + * @since 8 + * @return Returns local device info. + * @systemapi this method can be used only by system applications. + */ + getLocalDeviceInfoSync(): DeviceInfo; + + /** + * Obtains local device info + * + * @since 8 + * @param callback Indicates the callback to be invoked upon getLocalDeviceInfo + * @return Returns local device info. + * @systemapi this method can be used only by system applications. + */ + getLocalDeviceInfo(callback:AsyncCallback): void; + + /** + * Obtains local device info + * + * @since 8 + * @return Returns local device info. + * @systemapi this method can be used only by system applications. + */ + getLocalDeviceInfo(): Promise; + /** * Start to discover device. * - * @param bundleName Indicates the bundle name of the application. * @param subscribeInfo subscribe info to discovery device * @systemapi this method can be used only by system applications. */ @@ -350,7 +377,6 @@ declare namespace deviceManager { /** * Stop to discover device. * - * @param bundleName Indicates the bundle name of the application. * @param subscribeId Service subscribe ID * @systemapi this method can be used only by system applications. */ @@ -360,60 +386,37 @@ declare namespace deviceManager { * Authenticate the specified device. * * @param deviceInfo deviceInfo of device to authenticate - * @param authparam authparam of device to authenticate + * @param authParam authParam of device to authenticate * @param callback Indicates the callback to be invoked upon authenticateDevice * @systemapi this method can be used only by system applications. - */ - authenticateDevice(deviceInfo: DeviceInfo, authparam: AuthParam, callback: AsyncCallback<{deviceId: string, pinTone ?: number}>): void; - + */ + authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: AsyncCallback<{deviceId: string, pinTone ?: number}>): void; + + /** + * unAuthenticate the specified device. + * + * @since 8 + * @param deviceInfo deviceInfo of device to unAuthenticate + * @systemapi this method can be used only by system applications. + */ + unAuthenticateDevice(deviceInfo: DeviceInfo): void + /** * verify auth info, such as pin code. * * @param authInfo device auth info o verify * @param callback Indicates the callback to be invoked upon verifyAuthInfo * @systemapi this method can be used only by system applications. - */ + */ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string, level: number}>): void; - /** - * Get authenticate parameters for peer device, this interface can only used by devicemanager Fa. - * - * @param authParam authparam for peer device - * @systemapi this method can be used only by system applications. - */ - getAuthenticationParam(): AuthParam; - - /** - * Set user Operation from devicemanager Fa, this interface can only used by devicemanager Fa. - * - * @param operateAction User Operation Actions. - * @systemapi this method can be used only by system applications. - */ - setUserOperation(operateAction: UserOperationAction): void; - - /** - * Register a callback from deviceManager service so that the devicemanager Fa can be notified when some events happen. - * this interface can only used by devicemanager Fa. - * - * @param callback for devicemanager Fa to register. - * @systemapi this method can be used only by system applications. - */ - on(type: 'dmFaCallback', callback: Callback<{ param: string}>): void; - - /** - * UnRegister dmFaCallback, this interface can only used by devicemanager Fa. - * - * @param callback for devicemanager Fa to register. - * @systemapi this method can be used only by system applications. - */ - off(type: 'dmFaCallback', callback?: Callback<{ param: string}>): void; - /** * Register a device state callback so that the application can be notified upon device state changes based on * the application bundle name. * * @param bundleName Indicates the bundle name of the application. * @param callback Indicates the device state callback to register. + * @systemapi this method can be used only by system applications. */ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void; @@ -422,6 +425,7 @@ declare namespace deviceManager { * * @param bundleName Indicates the bundle name of the application. * @param callback Indicates the device state callback to register. + * @systemapi this method can be used only by system applications. */ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChangeAction, device: DeviceInfo }>): void; @@ -461,6 +465,7 @@ declare namespace deviceManager { * Register a serviceError callback so that the application can be notified when devicemanager service died * * @param callback Indicates the service error callback to register. + * @systemapi this method can be used only by system applications. */ on(type: 'serviceDie', callback: () => void): void; @@ -468,6 +473,7 @@ declare namespace deviceManager { * UnRegister a serviceError callback so that the application can be notified when devicemanager service died * * @param callback Indicates the service error callback to register. + * @systemapi this method can be used only by system applications. */ off(type: 'serviceDie', callback?: () => void): void; } diff --git a/services/devicemanagerservice/include/device_manager_service.h b/services/devicemanagerservice/include/device_manager_service.h index 739c4f17..8c54e9f3 100644 --- a/services/devicemanagerservice/include/device_manager_service.h +++ b/services/devicemanagerservice/include/device_manager_service.h @@ -51,7 +51,6 @@ public: int32_t SetUserOperation(std::string &pkgName, int32_t action); private: DeviceManagerService() = default; -private: bool intFlag_ = false; std::shared_ptr authMgr_; std::shared_ptr deviceInfoMgr_; diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index d31850e8..6b3fcae0 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -88,8 +88,8 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au } if (authRequestState_ != nullptr || authResponseState_ != nullptr) { - LOGE("DmAuthManager::AuthenticateDevice %s is request authentication.",pkgName.c_str()); - listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_BUSINESS_BUSY); + LOGE("DmAuthManager::AuthenticateDevice %s is request authentication.", pkgName.c_str()); + listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, DM_AUTH_BUSINESS_BUSY); return DM_AUTH_BUSINESS_BUSY; } @@ -228,8 +228,8 @@ void DmAuthManager::OnSessionOpened(int32_t sessionId, int32_t sessionSide, int3 softbusConnector_->GetSoftbusSession()->SendData(sessionId, message); } } else { - if (authResponseState_ == nullptr && authRequestState_ != nullptr && - authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_INIT){ + if (authResponseState_ == nullptr && authRequestState_ != nullptr && + authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_INIT) { authRequestContext_->sessionId = sessionId; authRequestState_->SetAuthContext(authRequestContext_); authMessageProcessor_->SetRequestContext(authRequestContext_); @@ -729,14 +729,14 @@ int32_t DmAuthManager::OnUserOperation(int32_t action) return DM_OK; } -void DmAuthManager::UserSwitchEventCallback (void) +void DmAuthManager::UserSwitchEventCallback (void) { LOGI("all groups from this device will be deleted"); nlohmann::json jsonObj; jsonObj[FIELD_GROUP_TYPE] = GROUP_TYPE_PEER_TO_PEER_GROUP; std::string queryParams = jsonObj.dump(); std::vector groupList; - int32_t ret = hiChainConnector_->GetGroupInfo(queryParams, groupList); + int32_t ret = hiChainConnector_->GetGroupInfo(queryParams, groupList); if (ret != DM_OK) { LOGE("failed to get device join groups"); return; diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index 9876035a..5faa4cca 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -89,13 +89,11 @@ int32_t DeviceManagerService::Init() } authMgr_->RegisterCallback(); } - DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); CommomEventCallback callback = std::bind(&DmAuthManager::UserSwitchEventCallback, *authMgr_.get()); if (dmCommonEventManager.SubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_SWITCHED, callback)) { LOGI("subscribe service event success"); - } - + } LOGI("Init success, singleton initialized"); intFlag_ = true; return DM_OK; diff --git a/test/unittest/UTTest_auth_message_processor.cpp b/test/unittest/UTTest_auth_message_processor.cpp index b86db898..b0e7dc35 100644 --- a/test/unittest/UTTest_auth_message_processor.cpp +++ b/test/unittest/UTTest_auth_message_processor.cpp @@ -37,7 +37,6 @@ void AuthMessageProcessorTest::TearDownTestCase() } namespace { - /** * @tc.name: AuthMessageProcessor::CreateNegotiateMessage_001 * @tc.desc: 1 set cryptoAdapter_ to null diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index 5e4b6716..60b68ec2 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -37,7 +37,6 @@ void AuthResponseStateTest::TearDownTestCase() } namespace { - /** * @tc.name: AuthResponseInitState::SetAuthManager_001 * @tc.desc: 1 set authManager not null diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index b47ad8fb..f2af9ddb 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -262,7 +262,7 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_003, testing::ext::TestSiz } /** * @tc.name: AuthenticateDevice_004 - * @tc.desc: Set intFlag for GAuthenticateDevice to true and pkgName to com.ohos.test; The return value is DM_AUTH_NOT_SUPPORT + * @tc.desc: Set intFlag for GAuthenticateDevice to true and pkgName to com.ohos.test * @tc.type: FUNC * @tc.require: AR000GHSJK */ diff --git a/test/unittest/UTTest_dm_auth_manager.cpp b/test/unittest/UTTest_dm_auth_manager.cpp index a4264d1b..c3da111c 100644 --- a/test/unittest/UTTest_dm_auth_manager.cpp +++ b/test/unittest/UTTest_dm_auth_manager.cpp @@ -38,7 +38,6 @@ void DmAuthManagerTest::TearDownTestCase() } namespace { - std::string AUTHENTICATE_TIMEOUT_TASK = "authenticateTimeoutTask"; std::string NEGOTIATE_TIMEOUT_TASK = "negotiateTimeoutTask"; std::string CONFIRM_TIMEOUT_TASK = "confirmTimeoutTask"; @@ -123,7 +122,7 @@ HWTEST_F(DmAuthManagerTest, EstablishAuthChannel_001, testing::ext::TestSize.Lev authManager->authRequestState_ = std::make_shared(); std::string deviceId1; int32_t ret = authManager->EstablishAuthChannel(deviceId1); - ASSERT_EQ(ret,DM_OK); + ASSERT_EQ(ret, DM_OK); } /** diff --git a/test/unittest/UTTest_hichain_connector.cpp b/test/unittest/UTTest_hichain_connector.cpp index 58cbf0f4..3395fda4 100644 --- a/test/unittest/UTTest_hichain_connector.cpp +++ b/test/unittest/UTTest_hichain_connector.cpp @@ -41,7 +41,6 @@ void HichainConnectorTest::TearDownTestCase() { } namespace { - std::shared_ptr listener_ = std::make_shared(); std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr discoveryMgr_ = std::make_shared(softbusConnector, listener_);