已合并
空间统计新增API #35105
2301_76815458创建于 18 天前
空间统计新增API #35105
已合并
共 1 个文件变更+100-0
| @@ -774,6 +774,106 @@ declare namespace storageStatistics { | |||
| 774 | * 24 dynamic&static | 774 | * 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 | + * ohos.permission.STORAGE_MANAGER | ||
| 782 | + * { string } packageName - Package name of the application. | ||
| 783 | + * { BundleStatsOptions } [option] - Options for obtaining the bundle statistics. | ||
| 784 | + * { Promise<BundleStats> } Promise used to return the application storage space (in bytes) obtained. | ||
| 785 | + * { BusinessError } 201 - Permission verification failed. | ||
| 786 | + * { BusinessError } 202 - The caller is not a system application. | ||
| 787 | + * { BusinessError } 13600001 - IPC error. | ||
| 788 | + * { BusinessError } 13600008 - No such object. | ||
| 789 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 790 | + * | ||
| 791 | + * | ||
| 792 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 800 | + * | ||
| 801 | + * | ||
| 802 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 809 | + * | ||
| 810 | + * | ||
| 811 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 819 | + * | ||
| 820 | + * | ||
| 821 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 829 | + * | ||
| 830 | + * | ||
| 831 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 839 | + * | ||
| 840 | + * | ||
| 841 | + * 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 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 851 | + * | ||
| 852 | + * | ||
| 853 | + * 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]{ ./bundleManager/BundleResourceInfo:BundleResourceInfo}. | ||
| 860 | + * | ||
| 861 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 862 | + * | ||
| 863 | + * | ||
| 864 | + * 26.1.0 dynamic&static | ||
| 865 | + */ | ||
| 866 | + index?: int; | ||
| 867 | + /** | ||
| 868 | + * Flag for obtaining the bundle statistics. | ||
| 869 | + * | ||
| 870 | + * SystemCapability.FileManagement.StorageService.SpatialStatistics | ||
| 871 | + * | ||
| 872 | + * | ||
| 873 | + * 26.1.0 dynamic&static | ||
| 874 | + */ | ||
| 875 | + statFlag?: GetBundleStatsFlag; | ||
| 876 | + } | ||
| 777 | } | 877 | } |
| 778 | 878 | ||
| 779 | export default storageStatistics; | 879 | export default storageStatistics; |