1# Bundle Management Development 2 3## How do I determine whether an application is a system application? 4 5Applicable to: OpenHarmony 3.2 Beta5 (API version 9) 6 7**Solution** 8 9Use **bundleManager.getApplicationInfo** (available only for system applications) to obtain application information, and check the value of **systemApp** in the information. The application is a system application if the value is **true**. 10 11**Reference** 12 13[bundleManager](../reference/apis/js-apis-bundleManager.md) 14 15## How do I obtain the version code and version name of an application? 16 17Applicable to: OpenHarmony 3.2 Beta5 (API version 9) 18 19**Solution** 20 21Use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information, which contains the version code (specified by **BundleInfo.versionCode**) and version name (specified by **BundleInfo.versionName**) . 22 23**Example** 24 25``` 26import bundleManager from '@ohos.bundle.bundleManager'; 27import hilog from '@ohos.hilog'; 28let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; 29try { 30 bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { 31 const versionCode = data.versionCode; 32 const versionName = data.versionName; 33 hilog.info(0x0000, 'testTag', `successfully. versionCode: ${versionCode}, versionName: ${versionName}`); 34 }).catch(err => { 35 hilog.error(0x0000, 'testTag', 'failed. Cause: %{public}s', err.message); 36 }); 37} catch (err) { 38 hilog.error(0x0000, 'testTag', 'failed: %{public}s', err.message); 39} 40``` 41 42**Reference** 43 44[getBundleInfoForSelf](../reference/apis/js-apis-bundleManager.md#bundlemanagergetbundleinfoforself) 45 46## How do I obtain the bundle name of the current application? 47 48Applicable to: OpenHarmony 3.2 Beta5 (API version 9) 49 50**Solution** 51 52Obtain the bundle name from **UIAbilityContext.abilityInfo.bundleName**. 53 54**Example** 55 56``` 57import common from '@ohos.app.ability.common'; 58const context = getContext(this) as common.UIAbilityContext 59console.log(`bundleName: ${context.abilityInfo.bundleName}`) 60``` 61 62**Reference** 63 64[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontext) and [AbilityInfo](../reference/apis/js-apis-bundleManager-abilityInfo.md#abilityinfo) 65 66## How do I obtain the application version number, version name, and screen resolution? 67 68Applicable to: OpenHarmony 3.2 Beta5 69 70**Solution** 71 721. Obtain the bundle information from the **@ohos.bundle.bundleManager** module. 73 74 The bundle information contains the application version number and version name. 75 76 ``` 77 import bundleManager from '@ohos.bundle.bundleManager'; 78 ... 79 bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{ 80 let versionName = bundleInfo.versionName; // Application version name. 81 let versionNo = bundleInfo.versionCode; // Application version number. 82 }).catch((error)=>{ 83 console.error("get bundleInfo failed,error is "+error) 84 }) 85 ``` 86 872. Obtain **screenDensity** from the **@ohos.app.ability.Configuration** module. **screenDensity** contains the screen resolution information. 88 89 ``` 90 import common from '@ohos.app.ability.common'; 91 ... 92 let context = getContext(this) as common.UIAbilityContext; 93 let screenDensity = context.config.screenDensity; 94 ``` 95 96 97## How do I obtain the source file path of the current application? 98 99Applicable to: OpenHarmony 3.2 Beta5 (API version 9) 100 101**Solution** 102 103- Method 1: Use the application context to obtain the source file path. 104 105 ``` 106 this.uiAbilityContext.abilityInfo.applicationInfo.codePath 107 ``` 108 109- Method 2: Use **@ohos.bundle.bundleManager** to obtain the source file path. 110 111 1. Import the **@ohos.bundle.bundleManager** module and use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information. 112 2. Obtain the source file path from **bundleInfo.appInfo.codePath**. 113 114 ``` 115 import bundleManager from '@ohos.bundle.bundleManager'; 116 bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION).then((bundleInfo)=>{ 117 this.sourcePath = bundleInfo.appInfo.codePath; 118 }) 119 ``` 120 121 122## Can I obtain the HAP information of other applications from the current application? 123 124Applicable to: OpenHarmony 3.2 (API version 9) 125 126**Solution** 127 128Currently, only system applications can call the API to query information about other applications. 129 130- To query information about an application in the system, you must obtain the normal-level permission **ohos.permission.GET\_BUNDLE\_INFO** and call the **bundleManager.getApplicationInfo\(\)** API. 131 132- To query information about all applications in the system, you must obtain the system\_basic-level permission **ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED** and call the **bundleManager.getAllApplicationInfo\(\)** API. 133 134**Reference** 135 136[@ohos.bundle.bundleManager \(bundleManager\)](../reference/apis/js-apis-bundleManager.md) 137 138## How do I query the PID of a process? 139 140Applicable to: OpenHarmony 3.2 Beta (API version 9) 141 142**Solution** 143 144You can obtain the PID through the **@ohos.process** interface. 145 146**Example** 147 148``` 149import process from '@ohos.process'; 150private pid = process.pid; 151``` 152 153**Reference** 154 155[@ohos.process \ (Obtaining Process Information\)](../reference/apis/js-apis-process.md) 156 157## How do I disable the maximize button? 158 159Applicable to: OpenHarmony 3.2 Beta (API version 9) 160 161**Solution** 162 163You can use the **supportWindowModes** field to specify whether to display the maximize button. 164 165- **full\_screen** means that a window in full-screen mode is supported. 166 167- **split** means that a window in split-screen mode is supported. 168 169- **floating** means that a floating window is supported. 170 171**Example** 172 173``` 174"abilities": [ 175 { 176 "name": "EntryAbility", 177 "srcEntry": "./ets/entryability/EntryAbility.ts", 178 "description": "$string:EntryAbility_desc", 179 "icon": "$media:icon", 180 "label": "$string:EntryAbility_label", 181 "startWindowIcon": "$media:icon", 182 "startWindowBackground": "$color:start_window_background", 183 "exported": true, 184 "supportWindowMode": ["split", "floating"], 185 "skills": [ 186 { 187 "entities": [ 188 "entity.system.home" 189 ], 190 "actions": [ 191 "action.system.home" 192 ] 193 } 194 ] 195 } 196] 197``` 198 199**Reference** 200 201[supportWindowModes](../reference/apis/js-apis-bundleManager-abilityInfo.md) 202