modify function name

Signed-off-by: 张文迪 <zhangwendi3@huawei.com>
This commit is contained in:
张文迪 2021-12-31 14:47:56 +08:00
parent 0b02c6a8a5
commit 174f853737
11 changed files with 119 additions and 152 deletions

View File

@ -23,16 +23,16 @@ namespace StorageManager {
class IStorageManager : public IRemoteBroker {
public:
virtual int32_t OnUserCreate(int32_t userId, uint32_t flags) = 0;
virtual int32_t OnUserDelete(int32_t userId, uint32_t flags) = 0;
virtual int32_t PrepareUserStart(int32_t userId) = 0;
virtual int32_t PrepareUserStop(int32_t userId) = 0;
virtual int32_t PrepareAddUser(int32_t userId) = 0;
virtual int32_t RemoveUser(int32_t userId) = 0;
virtual int32_t PrepareStartUser(int32_t userId) = 0;
virtual int32_t StopUser(int32_t userId) = 0;
enum {
ON_USER_CREATE = 1,
ON_USER_DELETE,
PREPARE_USER_START,
PREPARE_USER_STOP
PREPARE_ADD_USER = 1,
REMOVE_USER,
PREPARE_START_USER,
STOP_USER
};
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.StorageManager.IStorageManager");

View File

@ -32,10 +32,10 @@ public:
void OnStart() override;
void OnStop() override;
int32_t OnUserCreate(int32_t userId, uint32_t flags) override;
int32_t OnUserDelete(int32_t userId, uint32_t flags) override;
int32_t PrepareUserStart(int32_t userId) override;
int32_t PrepareUserStop(int32_t userId) override;
int32_t PrepareAddUser(int32_t userId) override;
int32_t RemoveUser(int32_t userId) override;
int32_t PrepareStartUser(int32_t userId) override;
int32_t StopUser(int32_t userId) override;
private:
StorageManager();
static sptr<StorageManager> instance_;

View File

@ -28,10 +28,10 @@ public:
: IRemoteProxy<IStorageManager>(impl) {}
~StorageManagerProxy() override{}
int32_t OnUserCreate(int32_t userId, uint32_t flags) override;
int32_t OnUserDelete(int32_t userId, uint32_t flags) override;
int32_t PrepareUserStart(int32_t userId) override;
int32_t PrepareUserStop(int32_t userId) override;
int32_t PrepareAddUser(int32_t userId) override;
int32_t RemoveUser(int32_t userId) override;
int32_t PrepareStartUser(int32_t userId) override;
int32_t StopUser(int32_t userId) override;
private:
static inline BrokerDelegator<StorageManagerProxy> delegator_;

View File

@ -27,10 +27,10 @@ public:
int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
private:
int32_t HandleOnUserCreate(MessageParcel &data, MessageParcel &reply);
int32_t HandleOnUserDelete(MessageParcel &data, MessageParcel &reply);
int32_t HandlePrepareUserStart(MessageParcel &data, MessageParcel &reply);
int32_t HandlePrepareUserStop(MessageParcel &data, MessageParcel &reply);
int32_t HandlePrepareAddUser(MessageParcel &data, MessageParcel &reply);
int32_t HandleRemoveUser(MessageParcel &data, MessageParcel &reply);
int32_t HandlePrepareStartUser(MessageParcel &data, MessageParcel &reply);
int32_t HandleStopUser(MessageParcel &data, MessageParcel &reply);
};
} // StorageManager
} // OHOS

View File

@ -30,10 +30,10 @@ class StorageDaemonCommunication : public NoCopyable {
public:
int32_t Connect();
int32_t OnUserCreate(int32_t userId, uint32_t flags);
int32_t OnUserDelete(int32_t userId, uint32_t flags);
int32_t PrepareUserStart(int32_t userId);
int32_t PrepareUserStop(int32_t userId);
int32_t PrepareAddUser(int32_t userId);
int32_t RemoveUser(int32_t userId);
int32_t PrepareStartUser(int32_t userId);
int32_t StopUser(int32_t userId);
private:
sptr<OHOS::StorageDaemon::IStorageDaemon> storageDaemon_;

View File

@ -25,10 +25,10 @@ namespace StorageManager {
class MultiUserManagerService final : public NoCopyable {
DECLARE_DELAYED_SINGLETON(MultiUserManagerService);
public:
int32_t OnUserCreate(int32_t userId, uint32_t flags) const;
int32_t OnUserDelete(int32_t userId, uint32_t flags) const;
int32_t PrepareUserStart(int32_t userId) const;
int32_t PrepareUserStop(int32_t userId) const;
int32_t PrepareAddUser(int32_t userId) const;
int32_t RemoveUser(int32_t userId) const;
int32_t PrepareStartUser(int32_t userId) const;
int32_t StopUser(int32_t userId) const;
};
} // StorageManager
} // OHOS

View File

@ -36,35 +36,35 @@ void StorageManager::OnStop()
LOGI("StorageManager::Onstop Done");
}
int32_t StorageManager::OnUserCreate(int32_t userId, uint32_t flags)
int32_t StorageManager::PrepareAddUser(int32_t userId)
{
LOGI("StorageManager::OnUserCreate start, userId: %{public}d", userId);
LOGI("StorageManager::PrepareAddUser start, userId: %{public}d", userId);
std::shared_ptr<MultiUserManagerService> userManager = DelayedSingleton<MultiUserManagerService>::GetInstance();
int32_t err = userManager->OnUserCreate(userId, flags);
int32_t err = userManager->PrepareAddUser(userId);
return err;
}
int32_t StorageManager::OnUserDelete(int32_t userId, uint32_t flags)
int32_t StorageManager::RemoveUser(int32_t userId)
{
LOGI("StorageManger::OnUserDelete start, userId: %{public}d", userId);
LOGI("StorageManger::RemoveUser start, userId: %{public}d", userId);
std::shared_ptr<MultiUserManagerService> userManager = DelayedSingleton<MultiUserManagerService>::GetInstance();
int32_t err = userManager->OnUserDelete(userId, flags);
int32_t err = userManager->RemoveUser(userId);
return err;
}
int32_t StorageManager::PrepareUserStart(int32_t userId)
int32_t StorageManager::PrepareStartUser(int32_t userId)
{
LOGI("StorageManger::PrepareUserStart start, userId: %{public}d", userId);
LOGI("StorageManger::PrepareStartUser start, userId: %{public}d", userId);
std::shared_ptr<MultiUserManagerService> userManager = DelayedSingleton<MultiUserManagerService>::GetInstance();
int32_t err = userManager->PrepareUserStart(userId);
int32_t err = userManager->PrepareStartUser(userId);
return err;
}
int32_t StorageManager::PrepareUserStop(int32_t userId)
int32_t StorageManager::StopUser(int32_t userId)
{
LOGI("StorageManger::PrepareUserStop start, userId: %{public}d", userId);
LOGI("StorageManger::StopUser start, userId: %{public}d", userId);
std::shared_ptr<MultiUserManagerService> userManager = DelayedSingleton<MultiUserManagerService>::GetInstance();
int32_t err = userManager->PrepareUserStop(userId);
int32_t err = userManager->StopUser(userId);
return err;
}
}

View File

@ -20,93 +20,85 @@
namespace OHOS {
namespace StorageManager {
int32_t StorageManagerProxy::OnUserCreate(int32_t userId, uint32_t flags)
int32_t StorageManagerProxy::PrepareAddUser(int32_t userId)
{
LOGI("StorageManagerProxy::OnUserCreate, userId:%{public}d", userId);
LOGI("StorageManagerProxy::PrepareAddUser, userId:%{public}d", userId);
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
LOGE("StorageManagerProxy::OnUserCreate, WriteInterfaceToken failed");
LOGE("StorageManagerProxy::PrepareAddUser, WriteInterfaceToken failed");
return E_IPC_ERROR;
}
if (!data.WriteInt32(userId)) {
LOGE("StorageManagerProxy::OnUserCreate, WriteInt32 failed");
LOGE("StorageManagerProxy::PrepareAddUser, WriteInt32 failed");
return E_IPC_ERROR;
}
if (!data.WriteUint32(flags)) {
LOGE("StorageManagerProxy::OnUserCreate, WriteUint32 failed");
return E_IPC_ERROR;
}
int err = Remote()->SendRequest(ON_USER_CREATE, data, reply, option);
int err = Remote()->SendRequest(PREPARE_ADD_USER, data, reply, option);
if (err != E_OK) {
LOGE("StorageManagerProxy::OnUserCreate, SendRequest failed");
LOGE("StorageManagerProxy::PrepareAddUser, SendRequest failed");
return E_IPC_ERROR;
}
return reply.ReadUint32();
}
int32_t StorageManagerProxy::OnUserDelete(int32_t userId, uint32_t flags)
int32_t StorageManagerProxy::RemoveUser(int32_t userId)
{
LOGI("StorageManagerProxy::OnUserDelete, userId:%{public}d", userId);
LOGI("StorageManagerProxy::RemoveUser, userId:%{public}d", userId);
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
LOGE("StorageManagerProxy::OnUserDelete, WriteInterfaceToken failed");
LOGE("StorageManagerProxy::RemoveUser, WriteInterfaceToken failed");
return E_IPC_ERROR;
}
if (!data.WriteInt32(userId)) {
LOGE("StorageManagerProxy::OnUserDelete, WriteInt32 failed");
LOGE("StorageManagerProxy::RemoveUser, WriteInt32 failed");
return E_IPC_ERROR;
}
if (!data.WriteUint32(flags)) {
LOGE("StorageManagerProxy::OnUserCreate, WriteUint32 failed");
return E_IPC_ERROR;
}
int err = Remote()->SendRequest(ON_USER_DELETE, data, reply, option);
int err = Remote()->SendRequest(REMOVE_USER, data, reply, option);
if (err != E_OK) {
LOGE("StorageManagerProxy::OnUserDelete, SendRequest failed");
LOGE("StorageManagerProxy::RemoveUser, SendRequest failed");
return E_IPC_ERROR;
}
return reply.ReadUint32();
}
int32_t StorageManagerProxy::PrepareUserStart(int32_t userId)
int32_t StorageManagerProxy::PrepareStartUser(int32_t userId)
{
LOGI("StorageManagerProxy::PrepareUserStart, userId:%{public}d", userId);
LOGI("StorageManagerProxy::PrepareStartUser, userId:%{public}d", userId);
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
LOGE("StorageManagerProxy::PrepareUserStart, WriteInterfaceToken failed");
LOGE("StorageManagerProxy::PrepareStartUser, WriteInterfaceToken failed");
return E_IPC_ERROR;
}
if (!data.WriteInt32(userId)) {
LOGE("StorageManagerProxy::PrepareUserStart, WriteInt32 failed");
LOGE("StorageManagerProxy::PrepareStartUser, WriteInt32 failed");
return E_IPC_ERROR;
}
int err = Remote()->SendRequest(PREPARE_USER_START, data, reply, option);
int err = Remote()->SendRequest(PREPARE_START_USER, data, reply, option);
if (err != E_OK) {
LOGE("StorageManagerProxy::PrepareUserStart, SendRequest failed");
LOGE("StorageManagerProxy::PrepareStartUser, SendRequest failed");
return E_IPC_ERROR;
}
return reply.ReadUint32();
}
int32_t StorageManagerProxy::PrepareUserStop(int32_t userId)
int32_t StorageManagerProxy::StopUser(int32_t userId)
{
LOGI("StorageManagerProxy::PrepareUserStop, userId:%{public}d", userId);
LOGI("StorageManagerProxy::StopUser, userId:%{public}d", userId);
MessageParcel data, reply;
MessageOption option(MessageOption::TF_SYNC);
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
LOGE("StorageManagerProxy::PrepareUserStop, WriteInterfaceToken failed");
LOGE("StorageManagerProxy::StopUser, WriteInterfaceToken failed");
return E_IPC_ERROR;
}
if (!data.WriteInt32(userId)) {
LOGE("StorageManagerProxy::PrepareUserStop, WriteInt32 failed");
LOGE("StorageManagerProxy::StopUser, WriteInt32 failed");
return E_IPC_ERROR;
}
int err = Remote()->SendRequest(PREPARE_USER_STOP, data, reply, option);
int err = Remote()->SendRequest(STOP_USER, data, reply, option);
if (err != E_OK) {
LOGE("StorageManagerProxy::PrepareUserStop, SendRequest failed");
LOGE("StorageManagerProxy::StopUser, SendRequest failed");
return E_IPC_ERROR;
}
return reply.ReadUint32();

View File

@ -30,20 +30,20 @@ int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
int err = 0;
switch (code) {
case ON_USER_CREATE:
HandleOnUserCreate(data, reply);
case PREPARE_ADD_USER:
HandlePrepareAddUser(data, reply);
break;
case ON_USER_DELETE:
HandleOnUserDelete(data, reply);
case REMOVE_USER:
HandleRemoveUser(data, reply);
break;
case PREPARE_USER_START:
HandlePrepareUserStart(data, reply);
case PREPARE_START_USER:
HandlePrepareStartUser(data, reply);
break;
case PREPARE_USER_STOP:
HandlePrepareUserStop(data, reply);
case STOP_USER:
HandleStopUser(data, reply);
break;
default: {
LOGI(" use IPCObjectStub default OnRemoteRequest");
LOGI("use IPCObjectStub default OnRemoteRequest");
err = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
break;
}
@ -51,51 +51,49 @@ int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
return err;
}
int32_t StorageManagerStub::HandleOnUserCreate(MessageParcel &data, MessageParcel &reply)
int32_t StorageManagerStub::HandlePrepareAddUser(MessageParcel &data, MessageParcel &reply)
{
int32_t userId = data.ReadInt32();
uint32_t flags = data.ReadUint32();
LOGI("StorageManagerStub::HandleOnUserCreate, userId:%{public}d", userId);
int err = OnUserCreate(userId, flags);
LOGI("StorageManagerStub::HandlePrepareAddUser, userId:%{public}d", userId);
int err = PrepareAddUser(userId);
if (!reply.WriteUint32(err)) {
LOGE("StorageManagerStub::HandleOnUserCreate call OnUserCreate failed");
LOGE("StorageManagerStub::HandlePrepareAddUser call PrepareAddUser failed");
return E_IPC_ERROR;
}
return E_OK;
}
int32_t StorageManagerStub::HandleOnUserDelete(MessageParcel &data, MessageParcel &reply)
int32_t StorageManagerStub::HandleRemoveUser(MessageParcel &data, MessageParcel &reply)
{
int32_t userId = data.ReadInt32();
uint32_t flags = data.ReadUint32();
LOGI("StorageManagerStub::HandleOnUserDelete, userId:%{public}d", userId);
int err = OnUserDelete(userId, flags);
LOGI("StorageManagerStub::HandleRemoveUser, userId:%{public}d", userId);
int err = RemoveUser(userId);
if (!reply.WriteUint32(err)) {
LOGE("StorageManagerStub::HandleOnUserDelete call OnUserDelete failed");
LOGE("StorageManagerStub::HandleRemoveUser call RemoveUser failed");
return E_IPC_ERROR;
}
return E_OK;
}
int32_t StorageManagerStub::HandlePrepareUserStart(MessageParcel &data, MessageParcel &reply)
int32_t StorageManagerStub::HandlePrepareStartUser(MessageParcel &data, MessageParcel &reply)
{
int32_t userId = data.ReadInt32();
LOGI("StorageManagerStub::HandlePrepareUserStart, userId:%{public}d", userId);
int err = PrepareUserStart(userId);
LOGI("StorageManagerStub::HandlePrepareStartUser, userId:%{public}d", userId);
int err = PrepareStartUser(userId);
if (!reply.WriteUint32(err)) {
LOGE("StorageManagerStub::HandlePrepareUserStart call PrepareUserStart failed");
LOGE("StorageManagerStub::HandlePrepareStartUser call PrepareStartUser failed");
return E_IPC_ERROR;
}
return E_OK;
}
int32_t StorageManagerStub::HandlePrepareUserStop(MessageParcel &data, MessageParcel &reply)
int32_t StorageManagerStub::HandleStopUser(MessageParcel &data, MessageParcel &reply)
{
int32_t userId = data.ReadInt32();
LOGI("StorageManagerStub::HandlePrepareUserStop, userId:%{public}d", userId);
int err = PrepareUserStop(userId);
LOGI("StorageManagerStub::HandleStopUser, userId:%{public}d", userId);
int err = StopUser(userId);
if (!reply.WriteUint32(err)) {
LOGE("StorageManagerStub::HandlePrepareUserStop call PrepareUserStop failed");
LOGE("StorageManagerStub::HandleStopUser call StopUser failed");
return E_IPC_ERROR;
}
return E_OK;

View File

@ -37,9 +37,6 @@ StorageDaemonCommunication::~StorageDaemonCommunication()
int32_t StorageDaemonCommunication::Connect()
{
if (storageDaemon_ != nullptr) {
return E_OK;
}
int32_t err = 0;
LOGI("StorageDaemonCommunication::Connect start");
if (storageDaemon_ == nullptr) {
@ -63,65 +60,45 @@ int32_t StorageDaemonCommunication::Connect()
return err;
}
int32_t StorageDaemonCommunication::OnUserCreate(int32_t userId, uint32_t flags)
int32_t StorageDaemonCommunication::PrepareAddUser(int32_t userId)
{
LOGI("StorageDaemonCommunication::OnUserCreate start");
LOGI("StorageDaemonCommunication::PrepareAddUser start");
if (Connect() != E_OK) {
LOGE("StorageDaemonCommunication::OnUserCreate failed");
LOGE("StorageDaemonCommunication::PrepareAddUser connect failed");
return E_IPC_ERROR;
} else {
int err = storageDaemon_->PrepareUserDirs(userId, flags);
if (err != E_OK) {
LOGE("StorageDaemonCommunication::OnUserCreate call StorageDaemon PrepareUserDirs failed");
}
return err;
}
return storageDaemon_->PrepareUserDirs(userId, 3);
}
int32_t StorageDaemonCommunication::OnUserDelete(int32_t userId, uint32_t flags)
int32_t StorageDaemonCommunication::RemoveUser(int32_t userId)
{
LOGI("StorageDaemonCommunication::OnUserDelete start");
LOGI("StorageDaemonCommunication::RemoveUser start");
if (Connect() != E_OK) {
LOGE("StorageDaemonCommunication::OnUserDelete failed");
LOGE("StorageDaemonCommunication::RemoveUser connect failed");
return E_IPC_ERROR;
} else {
int err = storageDaemon_->DestroyUserDirs(userId, flags);
if (err != E_OK) {
LOGE("StorageDaemonCommunication::OnUserDelete call StorageDaemon DestroyUserDirs failed");
}
return err;
}
}
return storageDaemon_->DestroyUserDirs(userId, 3);
}
int32_t StorageDaemonCommunication::PrepareUserStart(int32_t userId)
int32_t StorageDaemonCommunication::PrepareStartUser(int32_t userId)
{
LOGI("StorageDaemonCommunication::PrepareUserStart start");
LOGI("StorageDaemonCommunication::PrepareStartUser start");
if (Connect() != E_OK) {
LOGE("StorageDaemonCommunication::PrepareUserStart connect failed");
LOGE("StorageDaemonCommunication::PrepareStartUser connect failed");
return E_IPC_ERROR;
} else {
int err = storageDaemon_->StartUser(userId);
if (err != E_OK) {
LOGE("StorageDaemonCommunication::PrepareUserStart call StorageDaemon StartUser failed");
}
return err;
}
}
return storageDaemon_->StartUser(userId);
}
int32_t StorageDaemonCommunication::PrepareUserStop(int32_t userId)
int32_t StorageDaemonCommunication::StopUser(int32_t userId)
{
LOGI("StorageDaemonCommunication::PrepareUserStop start");
LOGI("StorageDaemonCommunication::StopUser start");
if (Connect() != E_OK) {
LOGE("StorageDaemonCommunication::PrepareUserStop connect failed");
LOGE("StorageDaemonCommunication::StopUser connect failed");
return E_IPC_ERROR;
} else {
int err = storageDaemon_->StopUser(userId);
if (err != E_OK) {
LOGE("StorageDaemonCommunication::PrepareUserStop call StorageDaemon StopUser failed");
}
return err;
}
return storageDaemon_->StopUser(userId);
}
} // StorageManager
} // OHOS

View File

@ -31,39 +31,39 @@ MultiUserManagerService::~MultiUserManagerService()
LOGI("DEBUG ~MultiUserManagerService destructer ~");
}
int32_t MultiUserManagerService::OnUserCreate(int32_t userId, uint32_t flags) const
int32_t MultiUserManagerService::PrepareAddUser(int32_t userId) const
{
LOGI("MultiUserManagerService_create, userId:%{public}d", userId);
LOGI("MultiUserManagerService::PrepareAddUser, userId:%{public}d", userId);
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
int32_t err = sdCommunication->OnUserCreate(userId, flags);
int32_t err = sdCommunication->PrepareAddUser(userId);
return err;
}
int32_t MultiUserManagerService::OnUserDelete(int32_t userId, uint32_t flags) const
int32_t MultiUserManagerService::RemoveUser(int32_t userId) const
{
LOGI("MultiUserManagerService_Delete, userId:%{public}d", userId);
LOGI("MultiUserManagerService::RemoveUser, userId:%{public}d", userId);
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
int32_t err = sdCommunication->OnUserDelete(userId, flags);
int32_t err = sdCommunication->RemoveUser(userId);
return err;
}
int32_t MultiUserManagerService::PrepareUserStart(int32_t userId) const
int32_t MultiUserManagerService::PrepareStartUser(int32_t userId) const
{
LOGI("MultiUserManagerService::PrepareUserStart, userId:%{public}d", userId);
LOGI("MultiUserManagerService::PrepareStartUser, userId:%{public}d", userId);
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
int32_t err = sdCommunication->PrepareUserStart(userId);
int32_t err = sdCommunication->PrepareStartUser(userId);
return err;
}
int32_t MultiUserManagerService::PrepareUserStop(int32_t userId) const
int32_t MultiUserManagerService::StopUser(int32_t userId) const
{
LOGI("MultiUserManagerService::PrepareUserStop, userId:%{public}d", userId);
LOGI("MultiUserManagerService::StopUser, userId:%{public}d", userId);
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
int32_t err = sdCommunication->PrepareUserStop(userId);
int32_t err = sdCommunication->StopUser(userId);
return err;
}
} // StorageManager