mirror of
https://gitee.com/openharmony/deviceprofile_device_info_manager
synced 2024-11-23 15:40:27 +00:00
增加DP初始化完成回调
Signed-off-by: wangzhaohao <wangzhaohao@huawei.com>
This commit is contained in:
parent
87351eb845
commit
e7095567ba
@ -55,7 +55,8 @@ enum class DPInterfaceCode : uint32_t {
|
||||
ON_CHAR_PROFILE_ADD = 37,
|
||||
ON_CHAR_PROFILE_UPDATE = 38,
|
||||
ON_CHAR_PROFILE_DELETE = 39,
|
||||
MAX = 40
|
||||
SUBSCRIBE_DEVICE_PROFILE_INITED = 40,
|
||||
MAX = 41
|
||||
};
|
||||
|
||||
enum class DeviceIdType : uint32_t {
|
||||
|
34
common/include/interfaces/i_dp_inited_callback.h
Normal file
34
common/include/interfaces/i_dp_inited_callback.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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_DP_I_DP_INITED_CALLBCK_H
|
||||
#define OHOS_DP_I_DP_INITED_CALLBCK_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "distributed_device_profile_enums.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedDeviceProfile {
|
||||
|
||||
class IDpInitedCallback : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DeviceProfile.IDpInitedCallback");
|
||||
IDpInitedCallback() = default;
|
||||
virtual ~IDpInitedCallback() = default;
|
||||
virtual void OnDpInited() = 0;
|
||||
};
|
||||
} // namespace DistributedDeviceProfile
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DP_I_DP_INITED_CALLBCK_H
|
@ -27,6 +27,7 @@
|
||||
#include <condition_variable>
|
||||
#include "i_profile_change_listener.h"
|
||||
#include "i_distributed_device_profile.h"
|
||||
#include "i_dp_inited_callback.h"
|
||||
#include "iremote_object.h"
|
||||
#include "refbase.h"
|
||||
#include "single_instance.h"
|
||||
@ -65,6 +66,7 @@ public:
|
||||
int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo);
|
||||
int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo);
|
||||
int32_t SyncDeviceProfile(const DpSyncOptions& syncOptions, sptr<ISyncCompletedCallback> syncCb);
|
||||
int32_t SubscribeDeviceProfileInited(int32_t saId, sptr<IDpInitedCallback> dpInitedCallback);
|
||||
|
||||
void LoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
|
||||
void LoadSystemAbilityFail();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "i_distributed_device_profile.h"
|
||||
#include "i_dp_inited_callback.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "refbase.h"
|
||||
@ -59,6 +60,7 @@ public:
|
||||
int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName,
|
||||
const std::string& characteristicId) override;
|
||||
int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override;
|
||||
int32_t SubscribeDeviceProfileInited(int32_t saId, sptr<IDpInitedCallback> dpInitedCallback) override;
|
||||
int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override;
|
||||
int32_t SyncDeviceProfile(const DpSyncOptions& syncOptions, sptr<IRemoteObject> syncCompletedCallback) override;
|
||||
int32_t SendSubscribeInfos(std::map<std::string, SubscribeInfo> listenerMap) override;
|
||||
|
@ -452,6 +452,16 @@ void DistributedDeviceProfileClient::StartThreadSendSubscribeInfos()
|
||||
std::thread(&DistributedDeviceProfileClient::SendSubscribeInfosToService, this).detach();
|
||||
}
|
||||
|
||||
int32_t DistributedDeviceProfileClient::SubscribeDeviceProfileInited(int32_t saId,
|
||||
sptr<IDpInitedCallback> dpInitedCallback) {
|
||||
auto dpService = GetDeviceProfileService();
|
||||
if (dpService == nullptr) {
|
||||
HILOGE("Get dp service failed");
|
||||
return DP_GET_SERVICE_FAILED;
|
||||
}
|
||||
return dpService->SubscribeDeviceProfileInited(saId, dpInitedCallback);
|
||||
}
|
||||
|
||||
void DistributedDeviceProfileClient::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId,
|
||||
const std::string &deviceId)
|
||||
{
|
||||
|
@ -336,5 +336,18 @@ int32_t DistributedDeviceProfileProxy::SendSubscribeInfos(std::map<std::string,
|
||||
SEND_REQUEST(remote, static_cast<uint32_t>(DPInterfaceCode::SEND_SUBSCRIBE_INFOS), data, reply);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedDeviceProfileProxy::SubscribeDeviceProfileInited(int32_t saId,
|
||||
sptr<IDpInitedCallback> dpInitedCallback) {
|
||||
sptr<IRemoteObject> remote = nullptr;
|
||||
GET_REMOTE_OBJECT(remote);
|
||||
MessageParcel data;
|
||||
WRITE_INTERFACE_TOKEN(data);
|
||||
WRITE_HELPER(data, Int32, saId);
|
||||
WRITE_HELPER(data, RemoteObject, dpInitedCallback);
|
||||
MessageParcel reply;
|
||||
SEND_REQUEST(remote, static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED), data, reply);
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
} // namespace DeviceProfile
|
||||
} // namespace OHOS
|
@ -64,6 +64,7 @@ public:
|
||||
int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override;
|
||||
int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions,
|
||||
sptr<IRemoteObject> syncCompletedCallback) override;
|
||||
int32_t SubscribeDeviceProfileInited(int32_t saId, sptr<IDpInitedCallback> dpInitedCallback);
|
||||
int32_t SendSubscribeInfos(std::map<std::string, SubscribeInfo> listenerMap) override;
|
||||
int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
|
||||
void DelayUnloadTask() override;
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
int32_t UnSubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t SyncDeviceProfileInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t SendSubscribeInfosInner(MessageParcel& data, MessageParcel& reply);
|
||||
int32_t SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply);
|
||||
virtual void DelayUnloadTask() = 0;
|
||||
virtual bool IsInited() = 0;
|
||||
|
||||
|
@ -755,5 +755,9 @@ void DistributedDeviceProfileServiceNew::ClearProfileCache()
|
||||
switchProfileMap_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfileInited(int32_t saId,
|
||||
sptr <IDpInitedCallback> dpInitedCallback) {
|
||||
}
|
||||
} // namespace DeviceProfile
|
||||
} // namespace OHOS
|
@ -73,6 +73,8 @@ DistributedDeviceProfileStubNew::DistributedDeviceProfileStubNew()
|
||||
&DistributedDeviceProfileStubNew::SyncDeviceProfileInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::SEND_SUBSCRIBE_INFOS)] =
|
||||
&DistributedDeviceProfileStubNew::SendSubscribeInfosInner;
|
||||
funcsMap_[static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED)] =
|
||||
&DistributedDeviceProfileStubNew::SubscribeDeviceProfileInitedInner;
|
||||
InitAclAndSubscribe();
|
||||
}
|
||||
|
||||
@ -511,5 +513,17 @@ int32_t DistributedDeviceProfileStubNew::SendSubscribeInfosInner(MessageParcel&
|
||||
}
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DistributedDeviceProfileStubNew::SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply)
|
||||
{
|
||||
int32_t saId = -1;
|
||||
READ_HELPER(data, Int32, saId);
|
||||
sptr<IRemoteObject> dpInitedCallback = data.ReadRemoteObject();
|
||||
int32_t ret = SubscribeDeviceProfileInited(saId, dpInitedCallback);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOGE("Write reply failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
}
|
||||
} // namespace DeviceProfile
|
||||
} // namespace OHOS
|
||||
|
Loading…
Reference in New Issue
Block a user