1e41f4b71Sopenharmony_ci# Window Subsystem Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.window.1 New Error Code Added for setWindowPrivacyMode 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Access Level** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciPublic API 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Reason for Change** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciAccording to the API reference of **setWindowPrivacyMode**, the **ohos.permission.PRIVACY_WINDOW** permission is required for calling this API. However, if the permission is not carried, error code 201 is not returned. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci**Change Impact** 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ciThis change is a non-compatible change. When an application calls **setWindowPrivacyMode** without requesting the **ohos.permission.PRIVACY_WINDOW** permission, error code 201 is returned. The application needs to handle the error. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Start API Level** 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci9 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Change Since** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciOpenHarmony SDK 4.1.6.5 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Key API/Component Changes** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciBefore the change, if the application calls **setWindowPrivacyMode** without carrying the **ohos.permission.PRIVACY_WINDOW** permission, no error code indicating permission verification failure is returned. However, the setting fails. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ciAfter the change, if the application calls **setWindowPrivacyMode** without carrying the **ohos.permission.PRIVACY_WINDOW** permission, error code 201 indicating permission verification failure is returned, and the setting fails. 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Adaptation Guide** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciIf the **ohos.permission.PRIVACY_WINDOW** permission is not configured when the application calls **setWindowPrivacyMode**, error code 201 is returned through the callback. Handle the error. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci``` 36e41f4b71Sopenharmony_ciimport { UIAbility }from '@kit.AbilityKit'; 37e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI'; 38e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 41e41f4b71Sopenharmony_ci onWindowStageCreate(windowStage: window.WindowStage): void { 42e41f4b71Sopenharmony_ci console.log('onWindowStageCreate'); 43e41f4b71Sopenharmony_ci let promise = windowStage.getMainWindow(); 44e41f4b71Sopenharmony_ci promise.then((windowClass: window.Window)=>{ 45e41f4b71Sopenharmony_ci windowClass.setWindowPrivacyMode(true, (err: BusinessError)=> { 46e41f4b71Sopenharmony_ci if (err.code) { 47e41f4b71Sopenharmony_ci console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); 48e41f4b71Sopenharmony_ci return; 49e41f4b71Sopenharmony_ci } 50e41f4b71Sopenharmony_ci console.info('Succeeded in setting the window to privacy mode.'); 51e41f4b71Sopenharmony_ci }); 52e41f4b71Sopenharmony_ci }).catch((err: BusinessError)=>{ 53e41f4b71Sopenharmony_ci console.log("Failed to get main window. Cause:" + JSON.stringify(err)); 54e41f4b71Sopenharmony_ci }) 55e41f4b71Sopenharmony_ci } 56e41f4b71Sopenharmony_ci}; 57e41f4b71Sopenharmony_ci``` 58