mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-23 06:59:59 +00:00
storagemanager 支持媒体库fuse
Signed-off-by: jiangjinpeng3 <jiangjinpeng3@huawei.com> Change-Id: If7d7b8944910f9bad4574baca9af846e2dcab21e
This commit is contained in:
parent
b055b7ff07
commit
db588b55d1
@ -125,6 +125,10 @@ public:
|
|||||||
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) = 0;
|
const std::string &networkId, const std::string &deviceId) = 0;
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) = 0;
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) = 0;
|
||||||
|
|
||||||
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.StorageManager.IStorageManager");
|
DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.StorageManager.IStorageManager");
|
||||||
};
|
};
|
||||||
} // StorageManager
|
} // StorageManager
|
||||||
|
@ -89,6 +89,8 @@ namespace StorageManager {
|
|||||||
SET_RECOVER_KEY,
|
SET_RECOVER_KEY,
|
||||||
NOTIFY_MTP_MOUNT,
|
NOTIFY_MTP_MOUNT,
|
||||||
NOTIFY_MTP_UNMOUNT,
|
NOTIFY_MTP_UNMOUNT,
|
||||||
|
MOUNT_MEDIA_FUSE,
|
||||||
|
UMOUNT_MEDIA_FUSE,
|
||||||
};
|
};
|
||||||
} // namespace StorageManager
|
} // namespace StorageManager
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -114,6 +114,10 @@ public:
|
|||||||
|
|
||||||
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
private:
|
private:
|
||||||
static inline BrokerDelegator<StorageManagerProxy> delegator_;
|
static inline BrokerDelegator<StorageManagerProxy> delegator_;
|
||||||
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||||
|
@ -102,6 +102,10 @@ public:
|
|||||||
const std::string &networkId, const std::string &deviceId) = 0;
|
const std::string &networkId, const std::string &deviceId) = 0;
|
||||||
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) = 0;
|
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) = 0;
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) = 0;
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) = 0;
|
||||||
|
|
||||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.StorageDaemon");
|
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.StorageDaemon");
|
||||||
};
|
};
|
||||||
} // STORAGE_DAEMON
|
} // STORAGE_DAEMON
|
||||||
|
@ -109,6 +109,10 @@ public:
|
|||||||
void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef USER_CRYPTO_MIGRATE_KEY
|
#ifdef USER_CRYPTO_MIGRATE_KEY
|
||||||
std::string GetNeedRestoreFilePath(int32_t userId, const std::string &user_dir);
|
std::string GetNeedRestoreFilePath(int32_t userId, const std::string &user_dir);
|
||||||
|
@ -61,6 +61,8 @@ namespace StorageDaemon {
|
|||||||
GET_FILE_ENCRYPT_STATUS,
|
GET_FILE_ENCRYPT_STATUS,
|
||||||
CREATE_RECOVER_KEY,
|
CREATE_RECOVER_KEY,
|
||||||
SET_RECOVER_KEY,
|
SET_RECOVER_KEY,
|
||||||
|
MOUNT_MEDIA_FUSE,
|
||||||
|
UMOUNT_MEDIA_FUSE,
|
||||||
};
|
};
|
||||||
} // namespace StorageDaemon
|
} // namespace StorageDaemon
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -89,6 +89,10 @@ public:
|
|||||||
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override;
|
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override;
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
private:
|
private:
|
||||||
static inline BrokerDelegator<StorageDaemonProxy> delegator_;
|
static inline BrokerDelegator<StorageDaemonProxy> delegator_;
|
||||||
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||||
@ -96,4 +100,4 @@ private:
|
|||||||
} // StorageDaemon
|
} // StorageDaemon
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
|
||||||
#endif // OHOS_STORAGE_DAEMON_STORAGE_DAEMON_PROXY_H
|
#endif // OHOS_STORAGE_DAEMON_STORAGE_DAEMON_PROXY_H
|
||||||
|
@ -83,8 +83,11 @@ private:
|
|||||||
int32_t HandleGetBundleStatsForIncrease(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleGetBundleStatsForIncrease(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleUMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleUMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
int32_t HandleMountMediaFuse(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleUMountMediaFuse(MessageParcel &data, MessageParcel &reply);
|
||||||
};
|
};
|
||||||
} // StorageDaemon
|
} // StorageDaemon
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
|
||||||
#endif // OHOS_STORAGE_DAEMON_STORAGE_DAEMON_STUB_H
|
#endif // OHOS_STORAGE_DAEMON_STORAGE_DAEMON_STUB_H
|
||||||
|
@ -108,6 +108,8 @@ public:
|
|||||||
const std::string &bundleName, const std::string &userId);
|
const std::string &bundleName, const std::string &userId);
|
||||||
bool CheckMountFileByUser(int32_t userId);
|
bool CheckMountFileByUser(int32_t userId);
|
||||||
bool CloudDirFlag(const std::string &path);
|
bool CloudDirFlag(const std::string &path);
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd);
|
||||||
|
int32_t UMountMediaFuse(int32_t userId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool SupportHmdfs();
|
bool SupportHmdfs();
|
||||||
|
@ -62,6 +62,7 @@ struct MountArgument final {
|
|||||||
std::string GetCurFileMgrAppdataPath() const;
|
std::string GetCurFileMgrAppdataPath() const;
|
||||||
std::string GetNoSharefsAppdataPath() const;
|
std::string GetNoSharefsAppdataPath() const;
|
||||||
unsigned long GetFlags() const;
|
unsigned long GetFlags() const;
|
||||||
|
std::string GetFullMediaFuse() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MountArgumentDescriptors final {
|
struct MountArgumentDescriptors final {
|
||||||
|
@ -1151,5 +1151,15 @@ void StorageDaemon::ActiveAppCloneUserKey()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemon::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
return MountManager::GetInstance()->MountMediaFuse(userId, devFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemon::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
return MountManager::GetInstance()->UMountMediaFuse(userId);
|
||||||
|
}
|
||||||
} // namespace StorageDaemon
|
} // namespace StorageDaemon
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -1009,5 +1009,56 @@ int32_t StorageDaemonProxy::GetFileEncryptStatus(uint32_t userId, bool &isEncryp
|
|||||||
isEncrypted = reply.ReadBool();
|
isEncrypted = reply.ReadBool();
|
||||||
return reply.ReadInt32();
|
return reply.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonProxy::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
|
||||||
|
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
|
||||||
|
LOGE("WriteInterfaceToken failed");
|
||||||
|
return E_WRITE_DESCRIPTOR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.WriteInt32(userId)) {
|
||||||
|
return E_WRITE_PARCEL_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t err = SendRequest(static_cast<int32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE), data, reply, option);
|
||||||
|
if (err != E_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ret = reply.ReadInt32();
|
||||||
|
if (ret == E_OK) {
|
||||||
|
devFd = reply.ReadFileDescriptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonProxy::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
|
||||||
|
if (!data.WriteInterfaceToken(StorageDaemonProxy::GetDescriptor())) {
|
||||||
|
LOGE("WriteInterfaceToken failed");
|
||||||
|
return E_WRITE_DESCRIPTOR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.WriteInt32(userId)) {
|
||||||
|
return E_WRITE_PARCEL_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t err = SendRequest(static_cast<int32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE), data, reply, option);
|
||||||
|
if (err != E_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reply.ReadInt32();
|
||||||
|
}
|
||||||
} // StorageDaemon
|
} // StorageDaemon
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -102,6 +102,10 @@ StorageDaemonStub::StorageDaemonStub()
|
|||||||
&StorageDaemonStub::HandleCreateRecoverKey;
|
&StorageDaemonStub::HandleCreateRecoverKey;
|
||||||
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::SET_RECOVER_KEY)] =
|
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::SET_RECOVER_KEY)] =
|
||||||
&StorageDaemonStub::HandleSetRecoverKey;
|
&StorageDaemonStub::HandleSetRecoverKey;
|
||||||
|
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE)] =
|
||||||
|
&StorageDaemonStub::HandleMountMediaFuse;
|
||||||
|
opToInterfaceMap_[static_cast<uint32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE)] =
|
||||||
|
&StorageDaemonStub::HandleUMountMediaFuse;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||||
@ -151,6 +155,8 @@ int32_t StorageDaemonStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
|||||||
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GENERATE_APP_KEY):
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GENERATE_APP_KEY):
|
||||||
case static_cast<uint32_t>(StorageDaemonInterfaceCode::DELETE_APP_KEY):
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::DELETE_APP_KEY):
|
||||||
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GET_FILE_ENCRYPT_STATUS):
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GET_FILE_ENCRYPT_STATUS):
|
||||||
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE):
|
||||||
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE):
|
||||||
return OnRemoteRequestForApp(code, data, reply);
|
return OnRemoteRequestForApp(code, data, reply);
|
||||||
default:
|
default:
|
||||||
LOGE("Cannot response request %d: unknown tranction", code);
|
LOGE("Cannot response request %d: unknown tranction", code);
|
||||||
@ -253,6 +259,10 @@ int32_t StorageDaemonStub::OnRemoteRequestForApp(uint32_t code, MessageParcel &d
|
|||||||
return HandleDeleteAppkey(data, reply);
|
return HandleDeleteAppkey(data, reply);
|
||||||
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GET_FILE_ENCRYPT_STATUS):
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::GET_FILE_ENCRYPT_STATUS):
|
||||||
return HandleGetFileEncryptStatus(data, reply);
|
return HandleGetFileEncryptStatus(data, reply);
|
||||||
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE):
|
||||||
|
return HandleMountMediaFuse(data, reply);
|
||||||
|
case static_cast<uint32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE):
|
||||||
|
return HandleUMountMediaFuse(data, reply);
|
||||||
default:
|
default:
|
||||||
LOGE("Cannot response request %d: unknown tranction", code);
|
LOGE("Cannot response request %d: unknown tranction", code);
|
||||||
return E_SYS_ERR;
|
return E_SYS_ERR;
|
||||||
@ -812,5 +822,41 @@ int32_t StorageDaemonStub::HandleGetFileEncryptStatus(MessageParcel &data, Messa
|
|||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonStub::HandleMountMediaFuse(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
LOGI("StorageDaemonStub::HandleMountMediaFuse start.");
|
||||||
|
|
||||||
|
int32_t userId = data.ReadInt32();
|
||||||
|
int32_t fd = -1;
|
||||||
|
int32_t ret = MountMediaFuse(userId, fd);
|
||||||
|
if (!reply.WriteInt32(ret)) {
|
||||||
|
LOGE("Write reply error code failed");
|
||||||
|
if (ret == E_OK) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
if (ret == E_OK && fd > 0) {
|
||||||
|
if (!reply.WriteFileDescriptor(fd)) {
|
||||||
|
LOGE("Write reply fd failed");
|
||||||
|
close(fd);
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonStub::HandleUMountMediaFuse(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
LOGI("StorageDaemonStub::HandleUMountMediaFuse start.");
|
||||||
|
|
||||||
|
int32_t userId = data.ReadInt32();
|
||||||
|
int32_t ret = UMountMediaFuse(userId);
|
||||||
|
if (!reply.WriteInt32(ret)) {
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
} // StorageDaemon
|
} // StorageDaemon
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -1085,5 +1085,60 @@ HWTEST_F(StorageDaemonProxyTest, StorageDaemonProxyTest_GetBundleStatsForIncreas
|
|||||||
EXPECT_EQ(ret, E_WRITE_PARCEL_ERR);
|
EXPECT_EQ(ret, E_WRITE_PARCEL_ERR);
|
||||||
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_GetBundleStatsForIncrease_001 end";
|
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_GetBundleStatsForIncrease_001 end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: StorageDaemonProxyTest_MountMediaFuse_001
|
||||||
|
* @tc.desc: Verify the MountMediaFuse function.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonProxyTest, StorageDaemonProxyTest_MountMediaFuse_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_MountMediaFuse_001 start";
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageDaemonServiceMock::InvokeSendRequest));
|
||||||
|
ASSERT_TRUE(proxy_ != nullptr);
|
||||||
|
int32_t userId = 100;
|
||||||
|
int32_t devFd = -1;
|
||||||
|
int32_t ret = proxy_->MountMediaFuse(userId, devFd);
|
||||||
|
ASSERT_TRUE(ret == E_OK);
|
||||||
|
ASSERT_TRUE(mock_ != nullptr);
|
||||||
|
int m = static_cast<int32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE);
|
||||||
|
ASSERT_TRUE(m == mock_->code_);
|
||||||
|
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Return(E_WRITE_PARCEL_ERR));
|
||||||
|
ret = proxy_->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(ret, E_WRITE_PARCEL_ERR);
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_MountMediaFuse_001 end";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: StorageDaemonProxyTest_UMountMediaFuse_001
|
||||||
|
* @tc.desc: Verify the UMountMediaFuse function.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonProxyTest, StorageDaemonProxyTest_UMountMediaFuse_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_UMountMediaFuse_001 start";
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageDaemonServiceMock::InvokeSendRequest));
|
||||||
|
ASSERT_TRUE(proxy_ != nullptr);
|
||||||
|
int32_t userId = 100;
|
||||||
|
int32_t ret = proxy_->UMountMediaFuse(userId);
|
||||||
|
ASSERT_TRUE(ret == E_OK);
|
||||||
|
ASSERT_TRUE(mock_ != nullptr);
|
||||||
|
int m = static_cast<int32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE);
|
||||||
|
ASSERT_TRUE(m == mock_->code_);
|
||||||
|
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Return(E_WRITE_PARCEL_ERR));
|
||||||
|
ret = proxy_->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(ret, E_WRITE_PARCEL_ERR);
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonProxyTest_UMountMediaFuse_001 end";
|
||||||
|
}
|
||||||
} // STORAGE_DAEMON
|
} // STORAGE_DAEMON
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -233,6 +233,16 @@ public:
|
|||||||
{
|
{
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace StorageDaemon
|
} // namespace StorageDaemon
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -67,6 +67,9 @@ public:
|
|||||||
MOCK_METHOD4(CreateRecoverKey, int32_t (uint32_t, uint32_t, const std::vector<uint8_t> &,
|
MOCK_METHOD4(CreateRecoverKey, int32_t (uint32_t, uint32_t, const std::vector<uint8_t> &,
|
||||||
const std::vector<uint8_t> &));
|
const std::vector<uint8_t> &));
|
||||||
MOCK_METHOD1(SetRecoverKey, int32_t (const std::vector<uint8_t> &));
|
MOCK_METHOD1(SetRecoverKey, int32_t (const std::vector<uint8_t> &));
|
||||||
|
|
||||||
|
MOCK_METHOD2(MountMediaFuse, int32_t (int32_t, int32_t &));
|
||||||
|
MOCK_METHOD1(UMountMediaFuse, int32_t (int32_t));
|
||||||
};
|
};
|
||||||
} // namespace StorageDaemon
|
} // namespace StorageDaemon
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -67,6 +67,8 @@ namespace {
|
|||||||
static_cast<int32_t>(StorageDaemonInterfaceCode::CREATE_RECOVER_KEY),
|
static_cast<int32_t>(StorageDaemonInterfaceCode::CREATE_RECOVER_KEY),
|
||||||
static_cast<int32_t>(StorageDaemonInterfaceCode::SET_RECOVER_KEY),
|
static_cast<int32_t>(StorageDaemonInterfaceCode::SET_RECOVER_KEY),
|
||||||
static_cast<int32_t>(StorageDaemonInterfaceCode::COMPLETE_ADD_USER),
|
static_cast<int32_t>(StorageDaemonInterfaceCode::COMPLETE_ADD_USER),
|
||||||
|
static_cast<int32_t>(StorageDaemonInterfaceCode::MOUNT_MEDIA_FUSE),
|
||||||
|
static_cast<int32_t>(StorageDaemonInterfaceCode::UMOUNT_MEDIA_FUSE),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +175,8 @@ HWTEST_F(StorageDaemonStubTest, Storage_Manager_StorageDaemonStubTest_OnRemoteRe
|
|||||||
EXPECT_CALL(mock, GetFileEncryptStatus(testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, GetFileEncryptStatus(testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
EXPECT_CALL(mock, CreateRecoverKey(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, CreateRecoverKey(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
EXPECT_CALL(mock, SetRecoverKey(testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, SetRecoverKey(testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
EXPECT_CALL(mock, MountMediaFuse(testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
EXPECT_CALL(mock, UMountMediaFuse(testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
|
||||||
for (auto c : g_code) {
|
for (auto c : g_code) {
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
|
@ -549,5 +549,40 @@ HWTEST_F(StorageDaemonTest, Storage_Manager_StorageDaemonTest_GetBundleStatsForI
|
|||||||
|
|
||||||
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_GetBundleStatsForIncrease_001 end";
|
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_GetBundleStatsForIncrease_001 end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: Storage_Manager_StorageDaemonTest_MountMediaFuse_001
|
||||||
|
* @tc.desc: check the MountMediaFuse function normal
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonTest, Storage_Manager_StorageDaemonTest_MountMediaFuse_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_MountMediaFuse_001 start";
|
||||||
|
|
||||||
|
ASSERT_TRUE(storageDaemon_ != nullptr);
|
||||||
|
|
||||||
|
int32_t userId = 105;
|
||||||
|
int32_t devFd = -1;
|
||||||
|
auto ret = storageDaemon_->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(ret, E_MOUNT);
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_MountMediaFuse_001 end";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: Storage_Manager_StorageDaemonTest_UMountMediaFuse_001
|
||||||
|
* @tc.desc: check the UMountMediaFuse function normal
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonTest, Storage_Manager_StorageDaemonTest_UMountMediaFuse_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_UMountMediaFuse_001 start";
|
||||||
|
|
||||||
|
ASSERT_TRUE(storageDaemon_ != nullptr);
|
||||||
|
|
||||||
|
int32_t userId = 105;
|
||||||
|
auto ret = storageDaemon_->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(ret, E_UMOUNT);
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_StorageDaemonTest_UMountMediaFuse_001 end";
|
||||||
|
}
|
||||||
} // STORAGE_DAEMON
|
} // STORAGE_DAEMON
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -167,6 +167,7 @@ std::vector<DirInfo> MountManager::InitVirtualDir()
|
|||||||
{"/mnt/data/%d/", MODE_0711, OID_ROOT, OID_ROOT},
|
{"/mnt/data/%d/", MODE_0711, OID_ROOT, OID_ROOT},
|
||||||
{"/mnt/data/%d/cloud", MODE_0711, OID_ROOT, OID_ROOT},
|
{"/mnt/data/%d/cloud", MODE_0711, OID_ROOT, OID_ROOT},
|
||||||
{"/mnt/data/%d/cloud_fuse", MODE_0711, OID_DFS, OID_DFS},
|
{"/mnt/data/%d/cloud_fuse", MODE_0711, OID_DFS, OID_DFS},
|
||||||
|
{"/mnt/data/%d/media_fuse", MODE_0711, OID_USER_DATA_RW, OID_USER_DATA_RW},
|
||||||
{"/mnt/data/%d/hmdfs", MODE_0711, OID_FILE_MANAGER, OID_FILE_MANAGER},
|
{"/mnt/data/%d/hmdfs", MODE_0711, OID_FILE_MANAGER, OID_FILE_MANAGER},
|
||||||
{"/mnt/hmdfs/", MODE_0711, OID_ROOT, OID_ROOT},
|
{"/mnt/hmdfs/", MODE_0711, OID_ROOT, OID_ROOT},
|
||||||
{"/mnt/hmdfs/%d/", MODE_0711, OID_ROOT, OID_ROOT},
|
{"/mnt/hmdfs/%d/", MODE_0711, OID_ROOT, OID_ROOT},
|
||||||
@ -1141,6 +1142,20 @@ int32_t MountManager::UmountByUser(int32_t userId)
|
|||||||
LOGE("failed to umount cloud mount point, err %{public}d", err);
|
LOGE("failed to umount cloud mount point, err %{public}d", err);
|
||||||
return E_UMOUNT;
|
return E_UMOUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOGI("umount media fuse mount point start.");
|
||||||
|
count = 0;
|
||||||
|
while (count < UMOUNT_RETRY_TIMES) {
|
||||||
|
err = UMountMediaFuse(userId);
|
||||||
|
if (err == E_OK) {
|
||||||
|
break;
|
||||||
|
} else if (errno == EBUSY) {
|
||||||
|
count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
LOGE("failed to umount media fuse mount point, err %{public}d", err);
|
||||||
|
return E_UMOUNT;
|
||||||
|
}
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1530,5 +1545,62 @@ int32_t MountManager::UmountMntUserTmpfs(int32_t userId)
|
|||||||
}
|
}
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t MountManager::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
LOGI("start mount media fuse");
|
||||||
|
|
||||||
|
// umount mountpoint first
|
||||||
|
Utils::MountArgument mediaMntArgs(Utils::MountArgumentDescriptors::Alpha(userId, ""));
|
||||||
|
const string path = mediaMntArgs.GetFullMediaFuse();
|
||||||
|
if (E_OK != UMount2(path.c_str(), MNT_DETACH)) {
|
||||||
|
LOGE("UMount media fuse mountpoint failed, errno = %{public}d", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
// open fuse
|
||||||
|
devFd = open("/dev/fuse", O_RDWR);
|
||||||
|
if (devFd < 0) {
|
||||||
|
LOGE("open /dev/fuse fail");
|
||||||
|
return E_MOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mount fuse mountpoint
|
||||||
|
string opt = StringPrintf("fd=%i,"
|
||||||
|
"rootmode=40000,"
|
||||||
|
"default_permissions,"
|
||||||
|
"allow_other,"
|
||||||
|
"user_id=0,group_id=0,"
|
||||||
|
"context=\"u:object_r:hmdfs:s0\","
|
||||||
|
"fscontext=u:object_r:hmdfs:s0",
|
||||||
|
devFd);
|
||||||
|
int ret = Mount("/dev/fuse", path.c_str(), "fuse", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opt.c_str());
|
||||||
|
if (ret) {
|
||||||
|
LOGE("failed to mount fuse, err %{public}d %{public}d %{public}s", errno, ret, path.c_str());
|
||||||
|
close(devFd);
|
||||||
|
return E_MOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGI("mount %{public}s success", path.c_str());
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t MountManager::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
int32_t err = E_OK;
|
||||||
|
|
||||||
|
LOGI("start umount media fuse");
|
||||||
|
|
||||||
|
Utils::MountArgument mediaMntArgs(Utils::MountArgumentDescriptors::Alpha(userId, ""));
|
||||||
|
const string path = mediaMntArgs.GetFullMediaFuse();
|
||||||
|
|
||||||
|
err = UMount2(path, MNT_DETACH);
|
||||||
|
if (err != E_OK) {
|
||||||
|
LOGE("fuse umount2 failed, errno %{public}d, fuse dst %{public}s", errno, path.c_str());
|
||||||
|
return E_UMOUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGI("umount %{public}s success", path.c_str());
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
} // namespace StorageDaemon
|
} // namespace StorageDaemon
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -583,7 +583,6 @@ HWTEST_F(UserManagerTest, Storage_Manager_MountManagerTest_UmountFailRadar_000,
|
|||||||
* @tc.name: Storage_Manager_MountManagerTest_CheckMaps_001
|
* @tc.name: Storage_Manager_MountManagerTest_CheckMaps_001
|
||||||
* @tc.desc: Verify the CheckMaps function.
|
* @tc.desc: Verify the CheckMaps function.
|
||||||
* @tc.type: FUNC
|
* @tc.type: FUNC
|
||||||
* @tc.require: AR000GK4HB
|
|
||||||
*/
|
*/
|
||||||
HWTEST_F(UserManagerTest, Storage_Manager_MountManagerTest_CheckMaps_000, TestSize.Level1)
|
HWTEST_F(UserManagerTest, Storage_Manager_MountManagerTest_CheckMaps_000, TestSize.Level1)
|
||||||
{
|
{
|
||||||
@ -604,5 +603,27 @@ HWTEST_F(UserManagerTest, Storage_Manager_MountManagerTest_CheckMaps_000, TestSi
|
|||||||
mountManager->CheckSymlink(path, prefix, mountFailList);
|
mountManager->CheckSymlink(path, prefix, mountFailList);
|
||||||
GTEST_LOG_(INFO) << "Storage_Manager_MountManagerTest_UmountFailRadar_000 end";
|
GTEST_LOG_(INFO) << "Storage_Manager_MountManagerTest_UmountFailRadar_000 end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: Storage_Manager_MountManagerTest_MountMediaFuse_001
|
||||||
|
* @tc.desc: Verify the MountMediaFuse function.
|
||||||
|
* @tc.type: FUNC
|
||||||
|
*/
|
||||||
|
HWTEST_F(UserManagerTest, Storage_Manager_MountManagerTest_MountMediaFuse_001, TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_MountManagerTest_MountMediaFuse_001 start";
|
||||||
|
|
||||||
|
std::shared_ptr<MountManager> mountManager = MountManager::GetInstance();
|
||||||
|
ASSERT_TRUE(mountManager != nullptr);
|
||||||
|
|
||||||
|
int32_t userId = 101;
|
||||||
|
int32_t devFd = -1;
|
||||||
|
int32_t ret = mountManager->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(ret, E_MOUNT);
|
||||||
|
|
||||||
|
ret = mountManager->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(ret, E_UMOUNT);
|
||||||
|
GTEST_LOG_(INFO) << "Storage_Manager_MountManagerTest_MountMediaFuse_001 end";
|
||||||
|
}
|
||||||
} // STORAGE_DAEMON
|
} // STORAGE_DAEMON
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -296,6 +296,13 @@ unsigned long MountArgument::GetFlags() const
|
|||||||
return MS_NODEV;
|
return MS_NODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string MountArgument::GetFullMediaFuse() const
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << TMPFS_MNT_DATA << userId_ << "/" << "media_fuse";
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
MountArgument MountArgumentDescriptors::Alpha(int userId, string relativePath)
|
MountArgument MountArgumentDescriptors::Alpha(int userId, string relativePath)
|
||||||
{
|
{
|
||||||
MountArgument mountArgument = {
|
MountArgument mountArgument = {
|
||||||
|
@ -122,6 +122,11 @@ public:
|
|||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
|
|
||||||
|
// media fuse
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
|
|
||||||
// reset user event record api
|
// reset user event record api
|
||||||
void ResetUserEventRecord(int32_t userId);
|
void ResetUserEventRecord(int32_t userId);
|
||||||
|
|
||||||
|
@ -95,6 +95,10 @@ private:
|
|||||||
// dfs service
|
// dfs service
|
||||||
int32_t HandleMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleUMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleUMountDfsDocs(MessageParcel &data, MessageParcel &reply);
|
||||||
|
|
||||||
|
// mount media fuse
|
||||||
|
int32_t HandleMountMediaFuse(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int32_t HandleUMountMediaFuse(MessageParcel &data, MessageParcel &reply);
|
||||||
};
|
};
|
||||||
} // StorageManager
|
} // StorageManager
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -89,6 +89,8 @@ public:
|
|||||||
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override;
|
virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override;
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
private:
|
private:
|
||||||
static inline BrokerDelegator<StorageDaemonProxy> delegator_;
|
static inline BrokerDelegator<StorageDaemonProxy> delegator_;
|
||||||
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||||
|
@ -113,6 +113,8 @@ public:
|
|||||||
|
|
||||||
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId) override;
|
const std::string &networkId, const std::string &deviceId) override;
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override;
|
||||||
|
int32_t UMountMediaFuse(int32_t userId) override;
|
||||||
private:
|
private:
|
||||||
static inline BrokerDelegator<StorageManagerProxy> delegator_;
|
static inline BrokerDelegator<StorageManagerProxy> delegator_;
|
||||||
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||||
|
@ -95,6 +95,10 @@ public:
|
|||||||
const std::string &networkId, const std::string &deviceId);
|
const std::string &networkId, const std::string &deviceId);
|
||||||
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath,
|
||||||
const std::string &networkId, const std::string &deviceId);
|
const std::string &networkId, const std::string &deviceId);
|
||||||
|
|
||||||
|
// media fuse mount
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd);
|
||||||
|
int32_t UMountMediaFuse(int32_t userId);
|
||||||
private:
|
private:
|
||||||
sptr<OHOS::StorageDaemon::IStorageDaemon> storageDaemon_;
|
sptr<OHOS::StorageDaemon::IStorageDaemon> storageDaemon_;
|
||||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
|
sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
|
||||||
@ -111,4 +115,4 @@ public:
|
|||||||
} // StorageManager
|
} // StorageManager
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1589,5 +1589,59 @@ int32_t StorageManagerProxy::GetFileEncryptStatus(uint32_t userId, bool &isEncry
|
|||||||
return reply.ReadInt32();
|
return reply.ReadInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerProxy::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
|
||||||
|
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||||
|
LOGE("WriteInterfaceToken failed");
|
||||||
|
return E_WRITE_DESCRIPTOR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.WriteInt32(userId)) {
|
||||||
|
LOGE("WriteInt32 failed");
|
||||||
|
return E_WRITE_PARCEL_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t err = SendRequest(
|
||||||
|
static_cast<int32_t>(StorageManagerInterfaceCode::MOUNT_MEDIA_FUSE), data, reply, option);
|
||||||
|
if (err != E_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ret = reply.ReadInt32();
|
||||||
|
if (ret == E_OK) {
|
||||||
|
devFd = reply.ReadFileDescriptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerProxy::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_SYNC);
|
||||||
|
|
||||||
|
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||||
|
LOGE("WriteInterfaceToken failed");
|
||||||
|
return E_WRITE_DESCRIPTOR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.WriteInt32(userId)) {
|
||||||
|
LOGE("WriteInt32 failed");
|
||||||
|
return E_WRITE_PARCEL_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t err = SendRequest(
|
||||||
|
static_cast<int32_t>(StorageManagerInterfaceCode::UMOUNT_MEDIA_FUSE), data, reply, option);
|
||||||
|
if (err != E_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reply.ReadInt32();
|
||||||
|
}
|
||||||
} // StorageManager
|
} // StorageManager
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -669,5 +669,19 @@ int32_t StorageManager::NotifyMtpUnmounted(const std::string &id, const std::str
|
|||||||
#endif
|
#endif
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageManager::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
|
||||||
|
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||||
|
return sdCommunication->MountMediaFuse(userId, devFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageManager::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
std::shared_ptr<StorageDaemonCommunication> sdCommunication;
|
||||||
|
sdCommunication = DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||||
|
return sdCommunication->UMountMediaFuse(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "ipc/storage_manager_stub.h"
|
#include "ipc/storage_manager_stub.h"
|
||||||
#include "accesstoken_kit.h"
|
#include "accesstoken_kit.h"
|
||||||
#include "ipc_skeleton.h"
|
#include "ipc_skeleton.h"
|
||||||
|
#include "storage/bundle_manager_connector.h"
|
||||||
#include "storage_manager_ipc_interface_code.h"
|
#include "storage_manager_ipc_interface_code.h"
|
||||||
#include "storage_service_errno.h"
|
#include "storage_service_errno.h"
|
||||||
#include "storage_service_log.h"
|
#include "storage_service_log.h"
|
||||||
@ -28,6 +29,7 @@ constexpr pid_t ACCOUNT_UID = 3058;
|
|||||||
constexpr pid_t BACKUP_SA_UID = 1089;
|
constexpr pid_t BACKUP_SA_UID = 1089;
|
||||||
constexpr pid_t FOUNDATION_UID = 5523;
|
constexpr pid_t FOUNDATION_UID = 5523;
|
||||||
constexpr pid_t DFS_UID = 1009;
|
constexpr pid_t DFS_UID = 1009;
|
||||||
|
const std::string MEDIALIBRARY_BUNDLE_NAME = "com.ohos.medialibrary.medialibrarydata";
|
||||||
const std::string PERMISSION_STORAGE_MANAGER_CRYPT = "ohos.permission.STORAGE_MANAGER_CRYPT";
|
const std::string PERMISSION_STORAGE_MANAGER_CRYPT = "ohos.permission.STORAGE_MANAGER_CRYPT";
|
||||||
const std::string PERMISSION_STORAGE_MANAGER = "ohos.permission.STORAGE_MANAGER";
|
const std::string PERMISSION_STORAGE_MANAGER = "ohos.permission.STORAGE_MANAGER";
|
||||||
const std::string PERMISSION_MOUNT_MANAGER = "ohos.permission.MOUNT_UNMOUNT_MANAGER";
|
const std::string PERMISSION_MOUNT_MANAGER = "ohos.permission.MOUNT_UNMOUNT_MANAGER";
|
||||||
@ -190,6 +192,10 @@ StorageManagerStub::StorageManagerStub()
|
|||||||
&StorageManagerStub::HandleNotifyMtpMount;
|
&StorageManagerStub::HandleNotifyMtpMount;
|
||||||
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT)] =
|
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT)] =
|
||||||
&StorageManagerStub::HandleNotifyMtpUnmount;
|
&StorageManagerStub::HandleNotifyMtpUnmount;
|
||||||
|
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::MOUNT_MEDIA_FUSE)] =
|
||||||
|
&StorageManagerStub::HandleMountMediaFuse;
|
||||||
|
opToInterfaceMap_[static_cast<uint32_t>(StorageManagerInterfaceCode::UMOUNT_MEDIA_FUSE)] =
|
||||||
|
&StorageManagerStub::HandleUMountMediaFuse;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
|
int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
|
||||||
@ -307,6 +313,10 @@ int32_t StorageManagerStub::OnRemoteRequest(uint32_t code,
|
|||||||
return HandleNotifyMtpMount(data, reply);
|
return HandleNotifyMtpMount(data, reply);
|
||||||
case static_cast<uint32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT):
|
case static_cast<uint32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT):
|
||||||
return HandleNotifyMtpUnmount(data, reply);
|
return HandleNotifyMtpUnmount(data, reply);
|
||||||
|
case static_cast<uint32_t>(StorageManagerInterfaceCode::MOUNT_MEDIA_FUSE):
|
||||||
|
return HandleMountMediaFuse(data, reply);
|
||||||
|
case static_cast<uint32_t>(StorageManagerInterfaceCode::UMOUNT_MEDIA_FUSE):
|
||||||
|
return HandleUMountMediaFuse(data, reply);
|
||||||
default:
|
default:
|
||||||
LOGE("Cannot response request %d: unknown tranction", code);
|
LOGE("Cannot response request %d: unknown tranction", code);
|
||||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||||
@ -1269,5 +1279,78 @@ int32_t StorageManagerStub::HandleNotifyMtpUnmount(MessageParcel &data, MessageP
|
|||||||
LOGI("StorageManagerStub::HandleNotifyMtpUnmount");
|
LOGI("StorageManagerStub::HandleNotifyMtpUnmount");
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerStub::HandleMountMediaFuse(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
LOGI("StorageManagerStub::HandleMountMediaFuse start.");
|
||||||
|
|
||||||
|
// Only for medialibrary to mount fuse.
|
||||||
|
std::string bundleName;
|
||||||
|
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||||
|
auto bundleMgr = DelayedSingleton<BundleMgrConnector>::GetInstance()->GetBundleMgrProxy();
|
||||||
|
if (bundleMgr == nullptr) {
|
||||||
|
LOGE("Connect bundle manager sa proxy failed.");
|
||||||
|
return E_BUNDLEMGR_ERROR;
|
||||||
|
}
|
||||||
|
if (!bundleMgr->GetBundleNameForUid(uid, bundleName)) {
|
||||||
|
LOGE("Invoke bundleMgr interface to get bundle name failed.");
|
||||||
|
return E_BUNDLEMGR_ERROR;
|
||||||
|
}
|
||||||
|
if (bundleName != MEDIALIBRARY_BUNDLE_NAME) {
|
||||||
|
LOGE("permissionCheck error, caller is %{public}s(%{public}d), should be %{public}s",
|
||||||
|
bundleName.c_str(), uid, MEDIALIBRARY_BUNDLE_NAME.c_str());
|
||||||
|
return E_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t userId = data.ReadInt32();
|
||||||
|
int32_t fd = -1;
|
||||||
|
int32_t ret = MountMediaFuse(userId, fd);
|
||||||
|
if (!reply.WriteInt32(ret)) {
|
||||||
|
LOGE("Write reply error code failed");
|
||||||
|
if (ret == E_OK) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
if (ret == E_OK) {
|
||||||
|
if (!reply.WriteFileDescriptor(fd)) {
|
||||||
|
LOGE("Write reply fd failed");
|
||||||
|
close(fd);
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerStub::HandleUMountMediaFuse(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
LOGI("StorageManagerStub::HandleUMountMediaFuse start.");
|
||||||
|
|
||||||
|
// Only for medialibrary to mount fuse.
|
||||||
|
std::string bundleName;
|
||||||
|
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||||
|
auto bundleMgr = DelayedSingleton<BundleMgrConnector>::GetInstance()->GetBundleMgrProxy();
|
||||||
|
if (bundleMgr == nullptr) {
|
||||||
|
LOGE("Connect bundle manager sa proxy failed.");
|
||||||
|
return E_BUNDLEMGR_ERROR;
|
||||||
|
}
|
||||||
|
if (!bundleMgr->GetBundleNameForUid(uid, bundleName)) {
|
||||||
|
LOGE("Invoke bundleMgr interface to get bundle name failed.");
|
||||||
|
return E_BUNDLEMGR_ERROR;
|
||||||
|
}
|
||||||
|
if (bundleName != MEDIALIBRARY_BUNDLE_NAME) {
|
||||||
|
LOGE("permissionCheck error, caller is %{public}s(%{public}d), should be %{public}s",
|
||||||
|
bundleName.c_str(), uid, MEDIALIBRARY_BUNDLE_NAME.c_str());
|
||||||
|
return E_PERMISSION_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t userId = data.ReadInt32();
|
||||||
|
int32_t ret = UMountMediaFuse(userId);
|
||||||
|
if (!reply.WriteInt32(ret)) {
|
||||||
|
return E_WRITE_REPLY_ERR;
|
||||||
|
}
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
} // StorageManager
|
} // StorageManager
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -108,6 +108,7 @@ ohos_unittest("storage_manager_stub_test") {
|
|||||||
"${storage_manager_path}/innerkits_impl/src/volume_external.cpp",
|
"${storage_manager_path}/innerkits_impl/src/volume_external.cpp",
|
||||||
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
||||||
"${storage_manager_path}/ipc/test/storage_manager_stub_test.cpp",
|
"${storage_manager_path}/ipc/test/storage_manager_stub_test.cpp",
|
||||||
|
"${storage_manager_path}/storage/src/bundle_manager_connector.cpp",
|
||||||
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -119,6 +120,8 @@ ohos_unittest("storage_manager_stub_test") {
|
|||||||
"access_token:libnativetoken",
|
"access_token:libnativetoken",
|
||||||
"access_token:libtoken_setproc",
|
"access_token:libtoken_setproc",
|
||||||
"app_file_service:fileshare_native",
|
"app_file_service:fileshare_native",
|
||||||
|
"bundle_framework:appexecfwk_base",
|
||||||
|
"bundle_framework:appexecfwk_core",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"googletest:gmock_main",
|
"googletest:gmock_main",
|
||||||
"googletest:gtest_main",
|
"googletest:gtest_main",
|
||||||
@ -165,6 +168,7 @@ ohos_unittest("storage_manager_stub_nonpermission_test") {
|
|||||||
"${storage_manager_path}/innerkits_impl/src/volume_external.cpp",
|
"${storage_manager_path}/innerkits_impl/src/volume_external.cpp",
|
||||||
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
||||||
"${storage_manager_path}/ipc/test/storage_manager_stub_noper_test.cpp",
|
"${storage_manager_path}/ipc/test/storage_manager_stub_noper_test.cpp",
|
||||||
|
"${storage_manager_path}/storage/src/bundle_manager_connector.cpp",
|
||||||
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -174,6 +178,8 @@ ohos_unittest("storage_manager_stub_nonpermission_test") {
|
|||||||
"ability_base:zuri",
|
"ability_base:zuri",
|
||||||
"access_token:libaccesstoken_sdk",
|
"access_token:libaccesstoken_sdk",
|
||||||
"app_file_service:fileshare_native",
|
"app_file_service:fileshare_native",
|
||||||
|
"bundle_framework:appexecfwk_base",
|
||||||
|
"bundle_framework:appexecfwk_core",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"googletest:gmock_main",
|
"googletest:gmock_main",
|
||||||
"googletest:gtest_main",
|
"googletest:gtest_main",
|
||||||
@ -222,6 +228,7 @@ ohos_unittest("storage_manager_stub_mockipc_test") {
|
|||||||
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
"${storage_manager_path}/ipc/src/storage_manager_stub.cpp",
|
||||||
"${storage_manager_path}/ipc/test/ipc_skeleton_mock.cpp",
|
"${storage_manager_path}/ipc/test/ipc_skeleton_mock.cpp",
|
||||||
"${storage_manager_path}/ipc/test/storage_manager_stub_mockipc_test.cpp",
|
"${storage_manager_path}/ipc/test/storage_manager_stub_mockipc_test.cpp",
|
||||||
|
"${storage_manager_path}/storage/src/bundle_manager_connector.cpp",
|
||||||
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
"${storage_manager_path}/utils/src/storage_utils.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -231,6 +238,8 @@ ohos_unittest("storage_manager_stub_mockipc_test") {
|
|||||||
"ability_base:zuri",
|
"ability_base:zuri",
|
||||||
"access_token:libaccesstoken_sdk",
|
"access_token:libaccesstoken_sdk",
|
||||||
"app_file_service:fileshare_native",
|
"app_file_service:fileshare_native",
|
||||||
|
"bundle_framework:appexecfwk_base",
|
||||||
|
"bundle_framework:appexecfwk_core",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"googletest:gmock_main",
|
"googletest:gmock_main",
|
||||||
"googletest:gtest_main",
|
"googletest:gtest_main",
|
||||||
|
@ -1707,4 +1707,61 @@ HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_NotifyMtpUnmounted_0000,
|
|||||||
EXPECT_EQ(result, E_WRITE_PARCEL_ERR);
|
EXPECT_EQ(result, E_WRITE_PARCEL_ERR);
|
||||||
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyMtpUnmounted_0000";
|
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_NotifyMtpUnmounted_0000";
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
/**
|
||||||
|
* @tc.number: SUB_STORAGE_Storage_manager_proxy_MountMediaFuse_0000
|
||||||
|
* @tc.name: Storage_manager_proxy_MountMediaFuse_0000
|
||||||
|
* @tc.desc: Test function of MountMediaFuse interface for SUCCESS.
|
||||||
|
* @tc.size: MEDIUM
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.level Level 1
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_MountMediaFuse_0000, testing::ext::TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_MountMediaFuse_0000";
|
||||||
|
ASSERT_TRUE(mock_ != nullptr) << "StorageManagerServiceMock failed";
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
|
||||||
|
int32_t userId = 130;
|
||||||
|
int32_t devFd = 140;
|
||||||
|
ASSERT_TRUE(proxy_ != nullptr) << "StorageManagerProxy failed";
|
||||||
|
int32_t result = proxy_->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(result, E_OK);
|
||||||
|
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Return(E_WRITE_PARCEL_ERR));
|
||||||
|
result = proxy_->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(result, E_WRITE_PARCEL_ERR);
|
||||||
|
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_MountMediaFuse_0000";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number: SUB_STORAGE_Storage_manager_proxy_UMountMediaFuse_0000
|
||||||
|
* @tc.name: Storage_manager_proxy_UMountMediaFuse_0000
|
||||||
|
* @tc.desc: Test function of UMountMediaFuse interface for SUCCESS.
|
||||||
|
* @tc.size: MEDIUM
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.level Level 1
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_UMountMediaFuse_0000, testing::ext::TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageManagerProxyTest-begin Storage_manager_proxy_UMountMediaFuse_0000";
|
||||||
|
ASSERT_TRUE(mock_ != nullptr) << "StorageManagerServiceMock failed";
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Invoke(mock_.GetRefPtr(), &StorageManagerServiceMock::InvokeSendRequest));
|
||||||
|
int32_t userId = 130;
|
||||||
|
ASSERT_TRUE(proxy_ != nullptr) << "StorageManagerProxy failed";
|
||||||
|
int32_t result = proxy_->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(result, E_OK);
|
||||||
|
|
||||||
|
EXPECT_CALL(*mock_, SendRequest(testing::_, testing::_, testing::_, testing::_))
|
||||||
|
.Times(1)
|
||||||
|
.WillOnce(testing::Return(E_WRITE_PARCEL_ERR));
|
||||||
|
result = proxy_->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(result, E_WRITE_PARCEL_ERR);
|
||||||
|
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_UMountMediaFuse_0000";
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
@ -318,6 +318,16 @@ public:
|
|||||||
{
|
{
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int32_t UMountMediaFuse(int32_t userId) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace StorageManager
|
} // namespace StorageManager
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -85,6 +85,9 @@ public:
|
|||||||
MOCK_METHOD4(NotifyMtpMounted, int32_t(const std::string &, const std::string &, const std::string &,
|
MOCK_METHOD4(NotifyMtpMounted, int32_t(const std::string &, const std::string &, const std::string &,
|
||||||
const std::string &));
|
const std::string &));
|
||||||
MOCK_METHOD2(NotifyMtpUnmounted, int32_t(const std::string &, const std::string &));
|
MOCK_METHOD2(NotifyMtpUnmounted, int32_t(const std::string &, const std::string &));
|
||||||
|
|
||||||
|
MOCK_METHOD2(MountMediaFuse, int32_t (int32_t, int32_t &));
|
||||||
|
MOCK_METHOD1(UMountMediaFuse, int32_t (int32_t));
|
||||||
};
|
};
|
||||||
} // namespace StorageManager
|
} // namespace StorageManager
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -79,6 +79,8 @@ namespace {
|
|||||||
static_cast<uint32_t>(StorageManagerInterfaceCode::SET_RECOVER_KEY),
|
static_cast<uint32_t>(StorageManagerInterfaceCode::SET_RECOVER_KEY),
|
||||||
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_MOUNT),
|
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_MOUNT),
|
||||||
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT),
|
static_cast<int32_t>(StorageManagerInterfaceCode::NOTIFY_MTP_UNMOUNT),
|
||||||
|
static_cast<int32_t>(StorageManagerInterfaceCode::MOUNT_MEDIA_FUSE),
|
||||||
|
static_cast<int32_t>(StorageManagerInterfaceCode::UMOUNT_MEDIA_FUSE),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +219,8 @@ HWTEST_F(StorageManagerStubTest, Storage_Manager_StorageManagerStubTest_OnRemote
|
|||||||
EXPECT_CALL(mock, SetRecoverKey(testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, SetRecoverKey(testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
EXPECT_CALL(mock, NotifyMtpMounted(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, NotifyMtpMounted(testing::_, testing::_, testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
EXPECT_CALL(mock, NotifyMtpUnmounted(testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
EXPECT_CALL(mock, NotifyMtpUnmounted(testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
EXPECT_CALL(mock, MountMediaFuse(testing::_, testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
EXPECT_CALL(mock, UMountMediaFuse(testing::_)).WillOnce(testing::Return(E_OK));
|
||||||
|
|
||||||
for (auto c : g_code) {
|
for (auto c : g_code) {
|
||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
|
@ -235,5 +235,15 @@ int32_t StorageDaemonProxy::GetFileEncryptStatus(uint32_t userId, bool &isEncryp
|
|||||||
{
|
{
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonProxy::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonProxy::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
} // StorageDaemon
|
} // StorageDaemon
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -316,5 +316,15 @@ int32_t StorageManagerProxy::NotifyMtpUnmounted(const std::string &id, const std
|
|||||||
{
|
{
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerProxy::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageManagerProxy::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
} // StorageManager
|
} // StorageManager
|
||||||
} // OHOS
|
} // OHOS
|
||||||
|
@ -659,5 +659,33 @@ int32_t StorageDaemonCommunication::UMountDfsDocs(int32_t userId, const std::str
|
|||||||
return storageDaemon_->UMountDfsDocs(userId, relativePath, networkId, deviceId);
|
return storageDaemon_->UMountDfsDocs(userId, relativePath, networkId, deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonCommunication::MountMediaFuse(int32_t userId, int32_t &devFd)
|
||||||
|
{
|
||||||
|
int32_t err = Connect();
|
||||||
|
if (err != E_OK) {
|
||||||
|
LOGE("Connect failed");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (storageDaemon_ == nullptr) {
|
||||||
|
LOGE("StorageDaemonCommunication::Connect service nullptr");
|
||||||
|
return E_SERVICE_IS_NULLPTR;
|
||||||
|
}
|
||||||
|
return storageDaemon_->MountMediaFuse(userId, devFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t StorageDaemonCommunication::UMountMediaFuse(int32_t userId)
|
||||||
|
{
|
||||||
|
int32_t err = Connect();
|
||||||
|
if (err != E_OK) {
|
||||||
|
LOGE("Connect failed");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (storageDaemon_ == nullptr) {
|
||||||
|
LOGE("StorageDaemonCommunication::Connect service nullptr");
|
||||||
|
return E_SERVICE_IS_NULLPTR;
|
||||||
|
}
|
||||||
|
return storageDaemon_->UMountMediaFuse(userId);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace StorageManager
|
} // namespace StorageManager
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -215,6 +215,47 @@ HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_UMountDfsDocs_001,
|
|||||||
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_UMountDfsDocs_001 SUCCESS";
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_UMountDfsDocs_001 SUCCESS";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number: SUB_STORAGE_Daemon_communication_MountMediaFuse_001
|
||||||
|
* @tc.name: Daemon_communication_MountMediaFuse_001
|
||||||
|
* @tc.desc: Test function of MountMediaFuse interface for SUCCESS.
|
||||||
|
* @tc.size: MEDIUM
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.level Level 1
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_MountMediaFuse_001, testing::ext::TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-begin Daemon_communication_MountMediaFuse_001 SUCCESS";
|
||||||
|
std::shared_ptr<StorageDaemonCommunication> sdCommunication =
|
||||||
|
DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||||
|
int32_t userId = 130;
|
||||||
|
int32_t devFd = 140;
|
||||||
|
int32_t result = sdCommunication->MountMediaFuse(userId, devFd);
|
||||||
|
EXPECT_EQ(result, E_OK);
|
||||||
|
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_MountMediaFuse_001 SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.number: SUB_STORAGE_Daemon_communication_UMountMediaFus_001
|
||||||
|
* @tc.name: Daemon_communication_UMountMediaFuse_001
|
||||||
|
* @tc.desc: Test function of UMountMediaFuse interface for SUCCESS.
|
||||||
|
* @tc.size: MEDIUM
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.level Level 1
|
||||||
|
*/
|
||||||
|
HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_UMountMediaFuse_001, testing::ext::TestSize.Level1)
|
||||||
|
{
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-begin Daemon_communication_UMountMediaFuse_001 SUCCESS";
|
||||||
|
std::shared_ptr<StorageDaemonCommunication> sdCommunication =
|
||||||
|
DelayedSingleton<StorageDaemonCommunication>::GetInstance();
|
||||||
|
int32_t userId = 130;
|
||||||
|
int32_t result = sdCommunication->UMountMediaFuse(userId);
|
||||||
|
EXPECT_EQ(result, E_OK);
|
||||||
|
|
||||||
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_UMountMediaFuse_001 SUCCESS";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @tc.number: SUB_STORAGE_Daemon_communication_ResetSdProxy_001
|
* @tc.number: SUB_STORAGE_Daemon_communication_ResetSdProxy_001
|
||||||
* @tc.name: Daemon_communication_ResetSdProxy_001
|
* @tc.name: Daemon_communication_ResetSdProxy_001
|
||||||
@ -858,4 +899,4 @@ HWTEST_F(StorageDaemonCommunicationTest, Daemon_communication_GetLockScreenStatu
|
|||||||
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_GetLockScreenStatus_0000 SUCCESS";
|
GTEST_LOG_(INFO) << "StorageDaemonCommunicationTest-end Daemon_communication_GetLockScreenStatus_0000 SUCCESS";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -314,6 +314,16 @@ public:
|
|||||||
{
|
{
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t UMountMediaFuse(int32_t userId) override
|
||||||
|
{
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace StorageManager
|
} // namespace StorageManager
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
Loading…
Reference in New Issue
Block a user