1# App Check Tool 2 3## Overview 4 5The app check tool is used to analyze and detect application installation packages. Based on the parameter settings, it scans the HAP, HSP, or APP file in the specified path and generates detection reports, providing data support for you to optimize the package structure or locate problems. The tool provides the following functions: 6- Scans for duplicate files. 7- Scans for large files (files that exceed the specified size). 8- Collects statistics on the size and proportion of each type of file.<br> 9 10By default, the tool generates detection reports in JSON and HTML format.<br> 11The **app_check_tool.jar** package of the tool is stored in the **toolchains** directory of the SDK. 12 13 14 15## Constraints 16The app check tool must run in Java 8 or later. 17 18## Scanning for Duplicate Files 19 20**Command example** 21 22``` 23java -jar app_check_tool.jar --input ./test.app --out-path ./test --stat-duplicate true 24``` 25 26**Parameters of the command** 27 28| Parameter | Mandatory| Description | 29| ---------------- | ---------- | ------------------------------------------------------------------ | 30| --input | Yes | Path of the HAP, HSP, or APP file. | 31| --out-path | Yes | Path of the detection reports. | 32| --stat-duplicate | No | Whether to scan for duplicate files. The default value is **false**.<br>**true**: Scanning is enabled.<br>**false**: Scanning is disabled. | 33 34**Detection report in JSON format** 35 36``` 37[{ 38 "taskType":1, 39 "taskDesc":"find the duplicated files", 40 "param":"--stat-duplicate", 41 "startTime":"2023-11-17 14:48:01:265", 42 "stopTime":"2023-11-17 14:48:01:434", 43 "result":[{ 44 "md5":"975c41f5727b416b1ffefa5bb0f073b", 45 "size":1108880, 46 "files":[ 47 "/application-entry-default.hap/libs/armeabi-v7a/example.so", 48 "/entry-default.hap/libs/armeabi-v7a/example.so" 49 ] 50 }] 51}] 52``` 53 54**Fields of the output** 55 56| Field | Type | Description | 57| --------- | ------ | --------------------------- | 58| taskType | int | Type of the task. The value **1** means a task for scanning for duplicate files.| 59| taskDesc | String | Description of the task. | 60| param | String | Parameter passed in by the scanning program. | 61| startTime | String | Start time of the task. | 62| stopTime | String | End time of the task. | 63| result | Struct | [Fields of result](#section1) | 64 65**Fields of result**<a name="section1"></a> 66 67| Field | Type | Description | 68| ----- | --------------- | -------------------------- | 69| md5 | String | MD5 value of the duplicate files. | 70| size | int | Size of the duplicate files, in bytes.| 71| files | Vector\<String> | Paths of the duplicate files. | 72 73## Scanning for Large Files 74 75**Command example** 76 77``` 78java -jar app_check_tool.jar --input ./test.app --out-path ./test --stat-file-size 4 79``` 80 81**Parameters of the command** 82 83| Parameter | Mandatory| Description | 84| ---------------- | ---------- | ----------------------------------------------------------- | 85| --input | Yes | Path of the HAP, HSP, or APP file. | 86| --out-path | Yes | Path of the detection reports. | 87| --stat-file-size | No | File size, in KB. A file with the size larger than this value is treated as a large file.<br>The value ranges from 0 to 4294967295, in KB.| 88 89**Detection report in JSON format** 90 91``` 92[{ 93 "taskType":2, 94 "taskDesc":"find files whose size exceed the limit size", 95 "param":"--stat-file-size 4", 96 "startTime":"2023-11-17 14:48:01:458", 97 "stopTime":"2023-11-17 14:48:01:491", 98 "result":[{ 99 "file":"/application-entry-default.hap/libs/x86_64/example.so", 100 "size":1292840 101 }] 102}] 103``` 104 105 106**Fields of the output** 107 108| Field | Type | Description | 109| --------- | ------ | ----------------------------------- | 110| taskType | int | Type of the task. The value **2** means a task for scanning for large files.| 111| taskDesc | String | Description of the task. | 112| param | String | Parameter passed in by the scanning program. | 113| startTime | String | Start time of the task. | 114| stopTime | String | End time of the task. | 115| result | Struct | [Fields of result](#section2) | 116 117**Fields of result**<a name="section2"></a> 118 119| Field| Type | Description | 120| ---- | ------ | ------------------------------------ | 121| file | String | Path of a file. | 122| size | int | Size of the file, in bytes.| 123 124## Collecting Statistics on the Size and Proportion by File Type 125 126**Command example** 127 128``` 129java -jar app_check_tool.jar --input ./test.app --out-path ./test --stat-suffix true 130``` 131 132**Parameters of the command** 133 134| Parameter | Mandatory| Description | 135| ------------- | ---------- | ------------------------------------------------------------------------- | 136| --input | Yes | Path of the HAP, HSP, or APP file. | 137| --out-path | Yes | Path of the detection reports. | 138| --stat-suffix | No | Whether to collect statistics on the size and proportion of each type of file. The default value is **false**.<br>**true**: Statistics collection is enabled.<br>**false**: Statistics collection is disabled.| 139 140**Detection report in JSON format** 141 142``` 143[{ 144 "taskType":3, 145 "taskDesc":"show files group by file type[.suffix]", 146 "param":"--stat-suffix", 147 "startTime":"2023-11-17 14:48:01:497", 148 "stopTime":"2023-11-17 14:48:01:537", 149 "pathList":[ 150 "test.app/application-entry-default.hap", 151 "test.app/entry-default.hap" 152 ], 153 "result":[{ 154 "suffix":"so", 155 "totalSize":1292840, 156 "files":[{ 157 "compress":"false", 158 "file":"/application-entry-default.hap/libs/x86_64/example.so", 159 "size":1292840 160 }] 161 }, 162 { 163 "suffix":"abc", 164 "totalSize":84852, 165 "files":[{ 166 "file":"/application-entry-default.hap/ets/modules.abc", 167 "size":76304 168 }, 169 { 170 "file":"/entry-default.hap/ets/modules.abc", 171 "size":8548 172 }] 173 }] 174}] 175``` 176 177 178 179**Fields of the output** 180 181| Field | Type | Description | 182| --------- | --------------- | -------------------------------------------------------------------------------------- | 183| taskType | int | Type of the task. The value **3** means a task for collecting statistics on the size and proportion of each type of file. | 184| taskDesc | String | Description of the task. | 185| param | String | Parameter passed in by the scanning program. | 186| startTime | String | Start time of the task. | 187| stopTime | String | End time of the task. | 188| pathList | Vector\<String> | Paths of multiple HAP and HSP files. | 189| result | Struct | [Fields of result](#section3) | 190 191**Fields of result**<a name="section3"></a> 192 193| Field | Type | Description | 194| --------- | ------ | ------------------------------------------ | 195| suffix | String | File name extension. | 196| totalSize | int | Total size of the files with the same file name extension, in bytes.| 197| files | Stuct | [Fields of files](#section4) | 198 199**Fields of files**<a name="section4"></a> 200| Field | Type | Description | 201| -------- | ------ | ------------------------------------------------------------------- | 202| file | String | Path of a file. | 203| size | int | Size of the file. | 204| compress | bool | Whether the file is compressed. This field is displayed only for .so files.<br>**true**: The file is compressed.<br>**false**: The file is not compressed.| 205