已合并
空间统计新增API #35105
空间统计新增API #35105
已合并
2301_76815458创建于 18 天前
1 个文件变更+100-0
@@ -774,6 +774,106 @@ declare namespace storageStatistics {
774 * @since 24 dynamic&static774 * @since 24 dynamic&static
775 */775 */
776 function getSystemDataSize(): Promise<long>;776 function getSystemDataSize(): Promise<long>;
777+ 
778+ /**
779+ * Obtains the storage space of an application, in bytes. This API uses a promise to return the result.
780+ *
781+ * @permission ohos.permission.STORAGE_MANAGER
782+ * @param { string } packageName - Package name of the application.
783+ * @param { BundleStatsOptions } [option] - Options for obtaining the bundle statistics.
784+ * @returns { Promise<BundleStats> } Promise used to return the application storage space (in bytes) obtained.
785+ * @throws { BusinessError } 201 - Permission verification failed.
786+ * @throws { BusinessError } 202 - The caller is not a system application.
787+ * @throws { BusinessError } 13600001 - IPC error.
788+ * @throws { BusinessError } 13600008 - No such object.
789+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
790+ * @systemapi
791+ * @stagemodelonly
792+ * @since 26.1.0 dynamic&static
793+ */
794+ function getBundleStats(packageName: string, option?: BundleStatsOptions): Promise<BundleStats>;
795+ 
796+ /**
797+ * Enumerates the flags for obtaining the bundle statistics.
798+ *
799+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
800+ * @systemapi
801+ * @stagemodelonly
802+ * @since 26.1.0 dynamic&static
803+ */
804+ export enum GetBundleStatsFlag {
805+ /**
806+ * Indicates that all the data size of the bundle is obtained.
807+ *
808+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
809+ * @systemapi
810+ * @stagemodelonly
811+ * @since 26.1.0 dynamic&static
812+ */
813+ GET_BUNDLE_WITH_ALL_SIZE = 0x00000000,
814+ 
815+ /**
816+ * Indicates that the installation size is excluded from the bundle statistics.
817+ *
818+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
819+ * @systemapi
820+ * @stagemodelonly
821+ * @since 26.1.0 dynamic&static
822+ */
823+ GET_BUNDLE_WITHOUT_INSTALL_SIZE = 0x00000001,
824+ 
825+ /**
826+ * Indicates that the data size is excluded from the bundle statistics.
827+ *
828+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
829+ * @systemapi
830+ * @stagemodelonly
831+ * @since 26.1.0 dynamic&static
832+ */
833+ GET_BUNDLE_WITHOUT_DATA_SIZE = 0x00000002,
834+ 
835+ /**
836+ * Indicates that the cache size is excluded from the bundle statistics.
837+ *
838+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
839+ * @systemapi
840+ * @stagemodelonly
841+ * @since 26.1.0 dynamic&static
842+ */
843+ GET_BUNDLE_WITHOUT_CACHE_SIZE = 0x00000004
844+ 
845+ }
846+ 
847+ /**
848+ * Options for obtaining the bundle statistics.
849+ *
850+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
851+ * @systemapi
852+ * @stagemodelonly
853+ * @since 26.1.0 dynamic&static
854+ */
855+ export interface BundleStatsOptions {
856+ /**
857+ * Index of an application clone. The default value is **0**, which indicates the application itself.
858+ * When an application clone is created, an index is assigned from 1 sequentially to **appIndex** of
859+ * [BundleResourceInfo]{@link ./bundleManager/BundleResourceInfo:BundleResourceInfo}.
860+ *
861+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
862+ * @systemapi
863+ * @stagemodelonly
864+ * @since 26.1.0 dynamic&static
865+ */
866+ index?: int;
867+ /**
868+ * Flag for obtaining the bundle statistics.
869+ *
870+ * @syscap SystemCapability.FileManagement.StorageService.SpatialStatistics
871+ * @systemapi
872+ * @stagemodelonly
873+ * @since 26.1.0 dynamic&static
874+ */
875+ statFlag?: GetBundleStatsFlag;
876+ }
777}877}
778 878 
779export default storageStatistics;879export default storageStatistics;