mirror of
https://gitee.com/openharmony/filemanagement_storage_service
synced 2024-11-30 10:40:32 +00:00
modify the return val of func
Signed-off-by: 张文迪 <zhangwendi3@huawei.com>
This commit is contained in:
parent
fc579b8f87
commit
49650e0e98
@ -28,7 +28,9 @@ config("private_config") {
|
||||
ohos_shared_library("storage_manager_sa_proxy") {
|
||||
sources = [
|
||||
"//foundation/filemanagement/storage_service/services/storage_daemon/ipc/src/storage_daemon_proxy.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/src/bundle_stats.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/src/disk.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/src/storage_stats.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/src/volume_core.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/innerkits_impl/src/volume_external.cpp",
|
||||
"//foundation/filemanagement/storage_service/services/storage_manager/ipc/src/storage_manager_proxy.cpp",
|
||||
|
40
interfaces/innerkits/storage_manager/native/bundle_stats.h
Normal file
40
interfaces/innerkits/storage_manager/native/bundle_stats.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_STORAGE_MANAGER_BUNDLE_STATS_H
|
||||
#define OHOS_STORAGE_MANAGER_BUNDLE_STATS_H
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
class BundleStats final : public Parcelable {
|
||||
public:
|
||||
BundleStats() {}
|
||||
BundleStats(int64_t appSize, int64_t cacheSize, int64_t dataSize)
|
||||
: appSize_(appSize), cacheSize_(cacheSize), dataSize_(dataSize) {}
|
||||
~BundleStats() {}
|
||||
|
||||
int64_t appSize_ {0};
|
||||
int64_t cacheSize_ {0};
|
||||
int64_t dataSize_ {0};
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static std::unique_ptr<BundleStats> Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // StorageManager
|
||||
} // OHOS
|
||||
|
||||
#endif // OHOS_STORAGE_MANAGER_BUNDLE_STATS_H
|
@ -20,6 +20,8 @@
|
||||
#include "volume_core.h"
|
||||
#include "volume_external.h"
|
||||
#include "disk.h"
|
||||
#include "bundle_stats.h"
|
||||
#include "storage_stats.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
@ -31,13 +33,13 @@ public:
|
||||
virtual int32_t StopUser(int32_t userId) = 0;
|
||||
virtual int64_t GetFreeSizeOfVolume(std::string volumeUuid) = 0;
|
||||
virtual int64_t GetTotalSizeOfVolume(std::string volumeUuid) = 0;
|
||||
virtual std::vector<int64_t> GetBundleStats(std::string pkgName) = 0;
|
||||
virtual BundleStats GetBundleStats(std::string pkgName) = 0;
|
||||
virtual int64_t GetSystemSize() = 0;
|
||||
virtual int64_t GetTotalSize() = 0;
|
||||
virtual int64_t GetFreeSize() = 0;
|
||||
virtual std::vector<int64_t> GetUserStorageStats() = 0;
|
||||
virtual std::vector<int64_t> GetUserStorageStats(int32_t userId) = 0;
|
||||
virtual std::vector<int64_t> GetCurrentBundleStats() = 0;
|
||||
virtual StorageStats GetUserStorageStats() = 0;
|
||||
virtual StorageStats GetUserStorageStats(int32_t userId) = 0;
|
||||
virtual BundleStats GetCurrentBundleStats() = 0;
|
||||
virtual void NotifyVolumeCreated(VolumeCore vc) = 0;
|
||||
virtual void NotifyVolumeMounted(std::string volumeId, int fsType, std::string fsUuid,
|
||||
std::string path, std::string description) = 0;
|
||||
|
43
interfaces/innerkits/storage_manager/native/storage_stats.h
Normal file
43
interfaces/innerkits/storage_manager/native/storage_stats.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_STORAGE_MANAGER_STORAGE_STATS_H
|
||||
#define OHOS_STORAGE_MANAGER_STORAGE_STATS_H
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
class StorageStats final : public Parcelable {
|
||||
public:
|
||||
StorageStats() {}
|
||||
StorageStats(int64_t total, int64_t audio, int64_t video, int64_t file, int64_t app)
|
||||
: total_(total), audio_(audio), video_(video), file_(file), app_(app) {}
|
||||
~StorageStats() {}
|
||||
|
||||
int64_t total_ {0};
|
||||
int64_t audio_ {0};
|
||||
int64_t video_ {0};
|
||||
int64_t image_ {0};
|
||||
int64_t file_ {0};
|
||||
int64_t app_ {0};
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override;
|
||||
static std::unique_ptr<StorageStats> Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // StorageMangaer
|
||||
} // OHOS
|
||||
|
||||
#endif // OHOS_STORAGE_MANAGER_STORAGE_STATS_H
|
@ -29,7 +29,7 @@ class StorageManagerConnect : public NoCopyable {
|
||||
DECLARE_DELAYED_SINGLETON(StorageManagerConnect);
|
||||
public:
|
||||
int32_t Connect();
|
||||
std::vector<int64_t> GetBundleStats(std::string pkgName);
|
||||
BundleStats GetBundleStats(std::string pkgName);
|
||||
int64_t GetFreeSizeOfVolume(std::string volumeUuid);
|
||||
int64_t GetTotalSizeOfVolume(std::string volumeUuid);
|
||||
bool Mount(std::string volumeId);
|
||||
@ -38,9 +38,9 @@ public:
|
||||
int64_t GetSystemSize();
|
||||
int64_t GetTotalSize();
|
||||
int64_t GetFreeSize();
|
||||
std::vector<int64_t> GetUserStorageStats();
|
||||
std::vector<int64_t> GetUserStorageStats(int32_t userId);
|
||||
std::vector<int64_t> GetCurrentBundleStats();
|
||||
StorageStats GetUserStorageStats();
|
||||
StorageStats GetUserStorageStats(int32_t userId);
|
||||
BundleStats GetCurrentBundleStats();
|
||||
private:
|
||||
sptr<StorageManager::IStorageManager> storageManager_ = nullptr;
|
||||
};
|
||||
|
@ -48,7 +48,9 @@ ohos_prebuilt_etc("storage_daemon_disk_config") {
|
||||
|
||||
ohos_executable("storage_daemon") {
|
||||
sources = [
|
||||
"../storage_manager/innerkits_impl/src/bundle_stats.cpp",
|
||||
"../storage_manager/innerkits_impl/src/disk.cpp",
|
||||
"../storage_manager/innerkits_impl/src/storage_stats.cpp",
|
||||
"../storage_manager/innerkits_impl/src/volume_core.cpp",
|
||||
"../storage_manager/innerkits_impl/src/volume_external.cpp",
|
||||
"../storage_manager/ipc/src/storage_manager_proxy.cpp",
|
||||
@ -119,7 +121,9 @@ config("sdc_config") {
|
||||
ohos_executable("sdc") {
|
||||
sources = [
|
||||
"../storage_manager/client/storage_manager_client.cpp",
|
||||
"../storage_manager/innerkits_impl/src/bundle_stats.cpp",
|
||||
"../storage_manager/innerkits_impl/src/disk.cpp",
|
||||
"../storage_manager/innerkits_impl/src/storage_stats.cpp",
|
||||
"../storage_manager/innerkits_impl/src/volume_core.cpp",
|
||||
"../storage_manager/innerkits_impl/src/volume_external.cpp",
|
||||
"../storage_manager/ipc/src/storage_manager_proxy.cpp",
|
||||
|
@ -42,13 +42,13 @@ public:
|
||||
|
||||
int64_t GetFreeSizeOfVolume(std::string volumeUuid) override;
|
||||
int64_t GetTotalSizeOfVolume(std::string volumeUuid) override;
|
||||
std::vector<int64_t> GetBundleStats(std::string pkgName) override;
|
||||
BundleStats GetBundleStats(std::string pkgName) override;
|
||||
int64_t GetSystemSize() override;
|
||||
int64_t GetTotalSize() override;
|
||||
int64_t GetFreeSize() override;
|
||||
std::vector<int64_t> GetUserStorageStats() override;
|
||||
std::vector<int64_t> GetUserStorageStats(int32_t userId) override;
|
||||
std::vector<int64_t> GetCurrentBundleStats() override;
|
||||
StorageStats GetUserStorageStats() override;
|
||||
StorageStats GetUserStorageStats(int32_t userId) override;
|
||||
BundleStats GetCurrentBundleStats() override;
|
||||
|
||||
void NotifyVolumeCreated(VolumeCore vc) override;
|
||||
void NotifyVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid,
|
||||
|
@ -33,13 +33,13 @@ public:
|
||||
int32_t StopUser(int32_t userId) override;
|
||||
int64_t GetFreeSizeOfVolume(std::string volumeUuid) override;
|
||||
int64_t GetTotalSizeOfVolume(std::string volumeUuid) override;
|
||||
std::vector<int64_t> GetBundleStats(std::string pkgName) override;
|
||||
BundleStats GetBundleStats(std::string pkgName) override;
|
||||
int64_t GetSystemSize() override;
|
||||
int64_t GetTotalSize() override;
|
||||
int64_t GetFreeSize() override;
|
||||
std::vector<int64_t> GetUserStorageStats() override;
|
||||
std::vector<int64_t> GetUserStorageStats(int32_t userId) override;
|
||||
std::vector<int64_t> GetCurrentBundleStats() override;
|
||||
StorageStats GetUserStorageStats() override;
|
||||
StorageStats GetUserStorageStats(int32_t userId) override;
|
||||
BundleStats GetCurrentBundleStats() override;
|
||||
void NotifyVolumeCreated(VolumeCore vc) override;
|
||||
void NotifyVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid,
|
||||
std::string path, std::string description) override;
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <nocopyable.h>
|
||||
#include <singleton.h>
|
||||
#include <iostream>
|
||||
#include "bundle_stats.h"
|
||||
#include "storage_stats.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
@ -27,10 +29,10 @@ class StorageStatusService : public NoCopyable {
|
||||
DECLARE_DELAYED_SINGLETON(StorageStatusService);
|
||||
|
||||
public:
|
||||
std::vector<int64_t> GetBundleStats(std::string pkgName);
|
||||
std::vector<int64_t> GetUserStorageStats();
|
||||
std::vector<int64_t> GetUserStorageStats(int32_t userId);
|
||||
std::vector<int64_t> GetCurrentBundleStats();
|
||||
BundleStats GetBundleStats(std::string pkgName);
|
||||
StorageStats GetUserStorageStats();
|
||||
StorageStats GetUserStorageStats(int32_t userId);
|
||||
BundleStats GetCurrentBundleStats();
|
||||
private:
|
||||
int GetCurrentUserId();
|
||||
std::string GetCallingPkgName();
|
||||
|
37
services/storage_manager/innerkits_impl/src/bundle_stats.cpp
Normal file
37
services/storage_manager/innerkits_impl/src/bundle_stats.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "bundle_stats.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
bool BundleStats::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
parcel.WriteInt64(appSize_);
|
||||
parcel.WriteInt64(cacheSize_);
|
||||
parcel.WriteInt64(dataSize_);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<BundleStats> BundleStats::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto obj = std::make_unique<BundleStats>();
|
||||
obj->appSize_ = parcel.ReadInt64();
|
||||
obj->cacheSize_ = parcel.ReadInt64();
|
||||
obj->dataSize_ = parcel.ReadInt64();
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "storage_stats.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace StorageManager {
|
||||
bool StorageStats::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
parcel.WriteInt64(total_);
|
||||
parcel.WriteInt64(audio_);
|
||||
parcel.WriteInt64(video_);
|
||||
parcel.WriteInt64(image_);
|
||||
parcel.WriteInt64(file_);
|
||||
parcel.WriteInt64(app_);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<StorageStats> StorageStats::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
auto obj = std::make_unique<StorageStats>();
|
||||
obj->total_ = parcel.ReadInt64();
|
||||
obj->audio_ = parcel.ReadInt64();
|
||||
obj->video_ = parcel.ReadInt64();
|
||||
obj->image_ = parcel.ReadInt64();
|
||||
obj->file_ = parcel.ReadInt64();
|
||||
obj->app_ = parcel.ReadInt64();
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -90,10 +90,10 @@ int64_t StorageManager::GetTotalSizeOfVolume(std::string volumeUuid)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManager::GetBundleStats(std::string pkgName)
|
||||
BundleStats StorageManager::GetBundleStats(std::string pkgName)
|
||||
{
|
||||
LOGI("StorageManger::getBundleStats start, pkgName: %{public}s", pkgName.c_str());
|
||||
std::vector<int64_t> result = DelayedSingleton<StorageStatusService>::GetInstance()->GetBundleStats(pkgName);
|
||||
BundleStats result = DelayedSingleton<StorageStatusService>::GetInstance()->GetBundleStats(pkgName);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -118,24 +118,24 @@ int64_t StorageManager::GetFreeSize()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManager::GetUserStorageStats()
|
||||
StorageStats StorageManager::GetUserStorageStats()
|
||||
{
|
||||
LOGI("StorageManger::GetUserStorageStats start");
|
||||
std::vector<int64_t> result = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManager::GetUserStorageStats(int32_t userId)
|
||||
{
|
||||
LOGI("StorageManger::GetUserStorageStats start");
|
||||
std::vector<int64_t> result = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats(userId);
|
||||
StorageStats result = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManager::GetCurrentBundleStats()
|
||||
StorageStats StorageManager::GetUserStorageStats(int32_t userId)
|
||||
{
|
||||
LOGI("StorageManger::GetUserStorageStats start");
|
||||
StorageStats result = DelayedSingleton<StorageStatusService>::GetInstance()->GetUserStorageStats(userId);
|
||||
return result;
|
||||
}
|
||||
|
||||
BundleStats StorageManager::GetCurrentBundleStats()
|
||||
{
|
||||
LOGI("StorageManger::GetCurrentBundleStats start");
|
||||
std::vector<int64_t> result = DelayedSingleton<StorageStatusService>::GetInstance()->GetCurrentBundleStats();
|
||||
BundleStats result = DelayedSingleton<StorageStatusService>::GetInstance()->GetCurrentBundleStats();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -307,9 +307,9 @@ int64_t StorageManagerProxy::GetTotalSizeOfVolume(std::string volumeUuid)
|
||||
return reply.ReadInt64();
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerProxy::GetBundleStats(std::string pkgName)
|
||||
BundleStats StorageManagerProxy::GetBundleStats(std::string pkgName)
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
BundleStats result;
|
||||
MessageParcel data, reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||
@ -323,11 +323,8 @@ std::vector<int64_t> StorageManagerProxy::GetBundleStats(std::string pkgName)
|
||||
if (err != E_OK) {
|
||||
return result;
|
||||
}
|
||||
std::vector<int64_t> val;
|
||||
if (!reply.ReadInt64Vector(&val)) {
|
||||
val = {};
|
||||
}
|
||||
return val;
|
||||
result = *BundleStats::Unmarshalling(reply);
|
||||
return result;
|
||||
}
|
||||
|
||||
void StorageManagerProxy::NotifyVolumeCreated(VolumeCore vc)
|
||||
@ -624,9 +621,9 @@ int64_t StorageManagerProxy::GetFreeSize()
|
||||
return reply.ReadInt64();
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerProxy::GetUserStorageStats()
|
||||
StorageStats StorageManagerProxy::GetUserStorageStats()
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
StorageStats result;
|
||||
MessageParcel data, reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||
@ -637,16 +634,13 @@ std::vector<int64_t> StorageManagerProxy::GetUserStorageStats()
|
||||
if (err != E_OK) {
|
||||
return result;
|
||||
}
|
||||
std::vector<int64_t> val;
|
||||
if (!reply.ReadInt64Vector(&val)) {
|
||||
val = {};
|
||||
}
|
||||
return val;
|
||||
result = *StorageStats::Unmarshalling(reply);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerProxy::GetUserStorageStats(int32_t userId)
|
||||
StorageStats StorageManagerProxy::GetUserStorageStats(int32_t userId)
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
StorageStats result;
|
||||
MessageParcel data, reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||
@ -660,16 +654,13 @@ std::vector<int64_t> StorageManagerProxy::GetUserStorageStats(int32_t userId)
|
||||
if (err != E_OK) {
|
||||
return result;
|
||||
}
|
||||
std::vector<int64_t> val;
|
||||
if (!reply.ReadInt64Vector(&val)) {
|
||||
val = {};
|
||||
}
|
||||
return val;
|
||||
result = *StorageStats::Unmarshalling(reply);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerProxy::GetCurrentBundleStats()
|
||||
BundleStats StorageManagerProxy::GetCurrentBundleStats()
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
BundleStats result;
|
||||
MessageParcel data, reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
|
||||
@ -680,11 +671,8 @@ std::vector<int64_t> StorageManagerProxy::GetCurrentBundleStats()
|
||||
if (err != E_OK) {
|
||||
return result;
|
||||
}
|
||||
std::vector<int64_t> val;
|
||||
if (!reply.ReadInt64Vector(&val)) {
|
||||
val = {};
|
||||
}
|
||||
return val;
|
||||
result = *BundleStats::Unmarshalling(reply);
|
||||
return result;
|
||||
}
|
||||
} // StorageManager
|
||||
} // OHOS
|
||||
|
@ -234,8 +234,8 @@ int32_t StorageManagerStub::HandleGetFree(MessageParcel &data, MessageParcel &re
|
||||
int32_t StorageManagerStub::HandleGetBundleStatus(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string pkgName = data.ReadString();
|
||||
std::vector<int64_t> bundleStats = GetBundleStats(pkgName);
|
||||
if (!reply.WriteInt64Vector(bundleStats)) {
|
||||
BundleStats bundleStats = GetBundleStats(pkgName);
|
||||
if (!reply.WriteParcelable(&bundleStats)) {
|
||||
return E_IPC_ERROR;
|
||||
}
|
||||
return E_OK;
|
||||
@ -273,8 +273,8 @@ int32_t StorageManagerStub::HandleGetFreeSize(MessageParcel &data, MessageParcel
|
||||
|
||||
int32_t StorageManagerStub::HandleGetCurrUserStorageStats(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<int64_t> storageStats = GetUserStorageStats();
|
||||
if (!reply.WriteInt64Vector(storageStats)) {
|
||||
StorageStats storageStats = GetUserStorageStats();
|
||||
if (!reply.WriteParcelable(&storageStats)) {
|
||||
return E_IPC_ERROR;
|
||||
}
|
||||
return E_OK;
|
||||
@ -283,8 +283,8 @@ int32_t StorageManagerStub::HandleGetCurrUserStorageStats(MessageParcel &data, M
|
||||
int32_t StorageManagerStub::HandleGetUserStorageStats(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t userId = data.ReadInt32();
|
||||
std::vector<int64_t> storageStats = GetUserStorageStats(userId);
|
||||
if (!reply.WriteInt64Vector(storageStats)) {
|
||||
StorageStats storageStats = GetUserStorageStats(userId);
|
||||
if (!reply.WriteParcelable(&storageStats)) {
|
||||
return E_IPC_ERROR;
|
||||
}
|
||||
return E_OK;
|
||||
@ -292,8 +292,8 @@ int32_t StorageManagerStub::HandleGetUserStorageStats(MessageParcel &data, Messa
|
||||
|
||||
int32_t StorageManagerStub::HandleGetCurrentBundleStats(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<int64_t> bundleStats = GetCurrentBundleStats();
|
||||
if (!reply.WriteInt64Vector(bundleStats)) {
|
||||
BundleStats bundleStats = GetCurrentBundleStats();
|
||||
if (!reply.WriteParcelable(&bundleStats)) {
|
||||
return E_IPC_ERROR;
|
||||
}
|
||||
return E_OK;
|
||||
|
@ -433,10 +433,10 @@ HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetBundleStats_0000, tes
|
||||
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
|
||||
auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
|
||||
std::vector<int64_t> result = proxy->GetBundleStats(pkgName);
|
||||
GTEST_LOG_(INFO) << result[0];
|
||||
GTEST_LOG_(INFO) << result[1];
|
||||
GTEST_LOG_(INFO) << result[2];
|
||||
BundleStats result = proxy->GetBundleStats(pkgName);
|
||||
GTEST_LOG_(INFO) << result.appSize_;
|
||||
GTEST_LOG_(INFO) << result.cacheSize_;
|
||||
GTEST_LOG_(INFO) << result.dataSize_;
|
||||
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetBundleStats_0000";
|
||||
}
|
||||
|
||||
@ -456,10 +456,10 @@ HWTEST_F(StorageManagerProxyTest, Storage_manager_proxy_GetBundleStats_0001, tes
|
||||
auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
auto remote = samgr->GetSystemAbility(STORAGE_MANAGER_MANAGER_ID);
|
||||
auto proxy = iface_cast<StorageManager::IStorageManager>(remote);
|
||||
std::vector<int64_t> result = proxy->GetBundleStats(pkgName);
|
||||
GTEST_LOG_(INFO) << result[0];
|
||||
GTEST_LOG_(INFO) << result[1];
|
||||
GTEST_LOG_(INFO) << result[2];
|
||||
BundleStats result = proxy->GetBundleStats(pkgName);
|
||||
GTEST_LOG_(INFO) << result.appSize_;
|
||||
GTEST_LOG_(INFO) << result.cacheSize_;
|
||||
GTEST_LOG_(INFO) << result.dataSize_;
|
||||
GTEST_LOG_(INFO) << "StorageManagerProxyTest-end Storage_manager_proxy_GetBundleStats_0001";
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,9 @@ public:
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual std::vector<int64_t> GetBundleStats(std::string pkgName) override
|
||||
virtual BundleStats GetBundleStats(std::string pkgName) override
|
||||
{
|
||||
std::vector<int64_t> result;
|
||||
BundleStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -86,21 +86,21 @@ public:
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
virtual std::vector<int64_t> GetUserStorageStats() override
|
||||
virtual StorageStats GetUserStorageStats() override
|
||||
{
|
||||
std::vector<int64_t> result;
|
||||
StorageStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual std::vector<int64_t> GetUserStorageStats(int32_t userId) override
|
||||
virtual StorageStats GetUserStorageStats(int32_t userId) override
|
||||
{
|
||||
std::vector<int64_t> result;
|
||||
StorageStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual std::vector<int64_t> GetCurrentBundleStats() override
|
||||
virtual BundleStats GetCurrentBundleStats() override
|
||||
{
|
||||
std::vector<int64_t> result;
|
||||
BundleStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,9 @@ int32_t StorageManagerConnect::Connect()
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
vector<int64_t> StorageManagerConnect::GetBundleStats(string pkgName)
|
||||
BundleStats StorageManagerConnect::GetBundleStats(string pkgName)
|
||||
{
|
||||
vector<int64_t> result = {};
|
||||
BundleStats result;
|
||||
if (Connect() != E_OK) {
|
||||
LOGE("StorageManagerConnect::GetBundleStats:Connect error");
|
||||
return result;
|
||||
@ -147,9 +147,9 @@ int64_t StorageManagerConnect::GetFreeSize()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerConnect::GetUserStorageStats()
|
||||
StorageStats StorageManagerConnect::GetUserStorageStats()
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
StorageStats result;
|
||||
if (Connect() != E_OK) {
|
||||
LOGE("StorageManagerConnect::GetUserStorageStats:Connect error");
|
||||
return result;
|
||||
@ -158,9 +158,9 @@ std::vector<int64_t> StorageManagerConnect::GetUserStorageStats()
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerConnect::GetUserStorageStats(int32_t userId)
|
||||
StorageStats StorageManagerConnect::GetUserStorageStats(int32_t userId)
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
StorageStats result;
|
||||
if (Connect() != E_OK) {
|
||||
LOGE("StorageManagerConnect::GetUserStorageStats:Connect error");
|
||||
return result;
|
||||
@ -169,9 +169,9 @@ std::vector<int64_t> StorageManagerConnect::GetUserStorageStats(int32_t userId)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageManagerConnect::GetCurrentBundleStats()
|
||||
BundleStats StorageManagerConnect::GetCurrentBundleStats()
|
||||
{
|
||||
std::vector<int64_t> result = {};
|
||||
BundleStats result;
|
||||
if (Connect() != E_OK) {
|
||||
LOGE("StorageManagerConnect::GetCurrentBundleStats:Connect error");
|
||||
return result;
|
||||
|
@ -130,7 +130,7 @@ napi_value GetBundleStats(napi_env env, napi_callback_info info)
|
||||
UniError(EINVAL).ThrowErr(env, "Invalid name");
|
||||
return nullptr;
|
||||
}
|
||||
auto bundleStats = std::make_shared<std::vector<int64_t>>();
|
||||
auto bundleStats = std::make_shared<BundleStats>();
|
||||
std::string nameString(name.get());
|
||||
auto cbExec = [nameString, bundleStats](napi_env env) -> UniError {
|
||||
*bundleStats = DelayedSingleton<StorageManagerConnect>::GetInstance()->GetBundleStats(nameString);
|
||||
@ -141,14 +141,10 @@ napi_value GetBundleStats(napi_env env, napi_callback_info info)
|
||||
return { env, err.GetNapiErr(env) };
|
||||
}
|
||||
NVal bundleObject = NVal::CreateObject(env);
|
||||
if ((*bundleStats).size() != 3) { // 3 is the fixed size of bundle stats.
|
||||
UniError(EINVAL).ThrowErr(env, "vector size error");
|
||||
return bundleObject;
|
||||
}
|
||||
bundleObject.AddProp("appSize", NVal::CreateInt64(env, (*bundleStats)[0]).val_); // 0 is the index of app size
|
||||
bundleObject.AddProp("appSize", NVal::CreateInt64(env, (bundleStats->appSize_)).val_);
|
||||
bundleObject.AddProp("cacheSize", NVal::CreateInt64(env,
|
||||
(*bundleStats)[1]).val_); // 1 is the index of cache size
|
||||
bundleObject.AddProp("dataSize", NVal::CreateInt64(env, (*bundleStats)[2]).val_); // 2 is the index of data size
|
||||
(bundleStats->cacheSize_)).val_);
|
||||
bundleObject.AddProp("dataSize", NVal::CreateInt64(env, (bundleStats->dataSize_)).val_);
|
||||
return bundleObject;
|
||||
};
|
||||
std::string procedureName = "GetBundleStats";
|
||||
@ -170,7 +166,7 @@ napi_value GetCurrentBundleStats(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto bundleStats = std::make_shared<std::vector<int64_t>>();
|
||||
auto bundleStats = std::make_shared<BundleStats>();
|
||||
auto cbExec = [bundleStats](napi_env env) -> UniError {
|
||||
*bundleStats = DelayedSingleton<StorageManagerConnect>::GetInstance()->GetCurrentBundleStats();
|
||||
return UniError(ERRNO_NOERR);
|
||||
@ -180,14 +176,10 @@ napi_value GetCurrentBundleStats(napi_env env, napi_callback_info info)
|
||||
return { env, err.GetNapiErr(env) };
|
||||
}
|
||||
NVal bundleObject = NVal::CreateObject(env);
|
||||
if ((*bundleStats).size() != 3) {
|
||||
UniError(EINVAL).ThrowErr(env, "vector size error");
|
||||
return bundleObject;
|
||||
}
|
||||
bundleObject.AddProp("appSize", NVal::CreateInt64(env, (*bundleStats)[0]).val_);
|
||||
bundleObject.AddProp("appSize", NVal::CreateInt64(env, (bundleStats->appSize_)).val_);
|
||||
bundleObject.AddProp("cacheSize", NVal::CreateInt64(env,
|
||||
(*bundleStats)[1]).val_);
|
||||
bundleObject.AddProp("dataSize", NVal::CreateInt64(env, (*bundleStats)[2]).val_);
|
||||
(bundleStats->cacheSize_)).val_);
|
||||
bundleObject.AddProp("dataSize", NVal::CreateInt64(env, (bundleStats->dataSize_)).val_);
|
||||
return bundleObject;
|
||||
};
|
||||
std::string procedureName = "GetCurrentBundleStats";
|
||||
@ -248,26 +240,22 @@ napi_value GetUserStorageStats(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto totalStats = std::make_shared<std::vector<int64_t>>();
|
||||
auto cbExec = [userId, totalStats](napi_env env) -> UniError {
|
||||
*totalStats = DelayedSingleton<StorageManagerConnect>::GetInstance()->GetUserStorageStats(userId);
|
||||
auto storageStats = std::make_shared<StorageStats>();
|
||||
auto cbExec = [userId, storageStats](napi_env env) -> UniError {
|
||||
*storageStats = DelayedSingleton<StorageManagerConnect>::GetInstance()->GetUserStorageStats(userId);
|
||||
return UniError(ERRNO_NOERR);
|
||||
};
|
||||
auto cbComplete = [totalStats](napi_env env, UniError err) -> NVal {
|
||||
auto cbComplete = [storageStats](napi_env env, UniError err) -> NVal {
|
||||
if (err) {
|
||||
return { env, err.GetNapiErr(env) };
|
||||
}
|
||||
NVal totalObject = NVal::CreateObject(env);
|
||||
if ((*totalStats).size() != 6) {
|
||||
UniError(EINVAL).ThrowErr(env, "vector size error");
|
||||
return totalObject;
|
||||
}
|
||||
totalObject.AddProp("total", NVal::CreateInt64(env, (*totalStats)[0]).val_);
|
||||
totalObject.AddProp("audio", NVal::CreateInt64(env, (*totalStats)[1]).val_);
|
||||
totalObject.AddProp("video", NVal::CreateInt64(env, (*totalStats)[2]).val_);
|
||||
totalObject.AddProp("image", NVal::CreateInt64(env, (*totalStats)[3]).val_);
|
||||
totalObject.AddProp("file", NVal::CreateInt64(env, (*totalStats)[4]).val_);
|
||||
totalObject.AddProp("app", NVal::CreateInt64(env, (*totalStats)[5]).val_);
|
||||
totalObject.AddProp("total", NVal::CreateInt64(env, (storageStats->total_)).val_);
|
||||
totalObject.AddProp("audio", NVal::CreateInt64(env, (storageStats->audio_)).val_);
|
||||
totalObject.AddProp("video", NVal::CreateInt64(env, (storageStats->video_)).val_);
|
||||
totalObject.AddProp("image", NVal::CreateInt64(env, (storageStats->image_)).val_);
|
||||
totalObject.AddProp("file", NVal::CreateInt64(env, (storageStats->file_)).val_);
|
||||
totalObject.AddProp("app", NVal::CreateInt64(env, (storageStats->app_)).val_);
|
||||
return totalObject;
|
||||
};
|
||||
std::string procedureName = "GetUserStorageStats";
|
||||
|
@ -45,13 +45,13 @@ std::string StorageStatusService::GetCallingPkgName()
|
||||
return tokenInfo.bundleName;
|
||||
}
|
||||
|
||||
vector<int64_t> StorageStatusService::GetBundleStats(std::string pkgName)
|
||||
BundleStats StorageStatusService::GetBundleStats(std::string pkgName)
|
||||
{
|
||||
vector<int64_t> result = {0, 0, 0};
|
||||
BundleStats result;
|
||||
int userId = GetCurrentUserId();
|
||||
LOGI("StorageStatusService::userId is:%d", userId);
|
||||
LOGD("StorageStatusService::userId is:%d", userId);
|
||||
if (userId < 0 || userId > StorageService::MAX_USER_ID) {
|
||||
LOGI("StorageStatusService::Invaild userId.");
|
||||
LOGE("StorageStatusService::Invaild userId.");
|
||||
return result;
|
||||
}
|
||||
vector<int64_t> bundleStats;
|
||||
@ -66,35 +66,35 @@ vector<int64_t> StorageStatusService::GetBundleStats(std::string pkgName)
|
||||
bundleStats[i] = 0;
|
||||
}
|
||||
}
|
||||
result[APPSIZE] = bundleStats[APP];
|
||||
result[CACHESIZE] = bundleStats[CACHE];
|
||||
result[DATASIZE] = bundleStats[LOCAL] + bundleStats[DISTRIBUTED] + bundleStats[DATABASE];
|
||||
result.appSize_ = bundleStats[APP];
|
||||
result.cacheSize_ = bundleStats[CACHE];
|
||||
result.dataSize_ = bundleStats[LOCAL] + bundleStats[DISTRIBUTED] + bundleStats[DATABASE];
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageStatusService::GetUserStorageStats()
|
||||
StorageStats StorageStatusService::GetUserStorageStats()
|
||||
{
|
||||
vector<int64_t> result = {0, 0, 0, 0, 0};
|
||||
StorageStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageStatusService::GetUserStorageStats(int32_t userId)
|
||||
StorageStats StorageStatusService::GetUserStorageStats(int32_t userId)
|
||||
{
|
||||
vector<int64_t> result = {0, 0, 0, 0, 0};
|
||||
StorageStats result;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> StorageStatusService::GetCurrentBundleStats()
|
||||
BundleStats StorageStatusService::GetCurrentBundleStats()
|
||||
{
|
||||
vector<int64_t> result = {0, 0, 0};
|
||||
BundleStats result;
|
||||
int userId = GetCurrentUserId();
|
||||
LOGI("StorageStatusService::userId is:%d", userId);
|
||||
LOGD("StorageStatusService::userId is:%d", userId);
|
||||
if (userId < 0 || userId > StorageService::MAX_USER_ID) {
|
||||
LOGI("StorageStatusService::Invaild userId.");
|
||||
LOGE("StorageStatusService::Invaild userId.");
|
||||
return result;
|
||||
}
|
||||
std::string pkgName = GetCallingPkgName();
|
||||
LOGI("StorageStatusService::pkgName is %{public}s", pkgName.c_str());
|
||||
LOGD("StorageStatusService::pkgName is %{public}s", pkgName.c_str());
|
||||
vector<int64_t> bundleStats;
|
||||
int errorcode = AppExecFwk::InstalldClient::GetInstance()->GetBundleStats(pkgName, userId, bundleStats);
|
||||
if (bundleStats.size() != dataDir.size() || errorcode != E_OK) {
|
||||
@ -107,9 +107,9 @@ std::vector<int64_t> StorageStatusService::GetCurrentBundleStats()
|
||||
bundleStats[i] = 0;
|
||||
}
|
||||
}
|
||||
result[APPSIZE] = bundleStats[APP];
|
||||
result[CACHESIZE] = bundleStats[CACHE];
|
||||
result[DATASIZE] = bundleStats[LOCAL] + bundleStats[DISTRIBUTED] + bundleStats[DATABASE];
|
||||
result.appSize_ = bundleStats[APP];
|
||||
result.cacheSize_ = bundleStats[CACHE];
|
||||
result.dataSize_ = bundleStats[LOCAL] + bundleStats[DISTRIBUTED] + bundleStats[DATABASE];
|
||||
return result;
|
||||
}
|
||||
} // StorageManager
|
||||
|
Loading…
Reference in New Issue
Block a user