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