From API version 6.0.2 (22), the capability of setting and querying the deep freeze exemption list is supported.
Enterprise Space Kit provides the app exemption management capability for enterprise apps in deep freeze mode. You can set exempted apps so that they can run properly in the background. In addition, the list of apps exempted from deep freeze can be queried.
For details about these APIs, please refer to the API Reference.
| API | Description |
|---|---|
| setLockdownExemptionApps(appIds: string[], workspaceId?: number): Promise<void> | Sets the deep freeze exemption list. |
| getLockdownExemptionApps(workspaceId?: number): Promise<string[]> | Queries the deep freeze exemption list. |
import { spaceManager } from '@kit.EnterpriseSpaceKit';
import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG = '[Sample_SpaceManagerSample]';
const DOMAIN = 0xF811;
export class LockDownExemptionApi {
static async setLockdownExemptionApps(workspaceId: number, appIds: string[]): Promise<void> {
try {
await spaceManager.setLockdownExemptionApps(appIds, workspaceId);
hilog.info(DOMAIN, TAG, `Succeeded in setting lockdown exemption apps.`);
} catch (err) {
hilog.error(DOMAIN, TAG, `Failed to set lockdown exemption apps. Code: ${err?.code}, message: ${err?.message}`);
}
}
static async getLockdownExemptionApps(workspaceId: number): Promise<string[]> {
try {
const apps: string[] = await spaceManager.getLockdownExemptionApps(workspaceId);
hilog.info(DOMAIN, TAG, `Succeeded in getting lockdown exemption apps. apps:` + JSON.stringify(apps));
return apps;
} catch (err) {
hilog.error(DOMAIN, TAG, `Failed to get lockdown exemption apps. Code: ${err.code}, message: ${err.message}`);
return [];
}
}
} import { router } from '@kit.ArkUI';
import { LockDownExemptionApi } from '../api/LockDownExemptionApi' @Entry
@Component
struct LockDownExemptionPage {
async setLockdownExemptionApps() {
let workspaceId: number = 100; // Workspace ID, which is passed by the user.
let appIds: string[] = [
'com.example.test_BN************' // Unique ID of an app. Change it based on the actual situation.
]
LockDownExemptionApi.setLockdownExemptionApps(workspaceId, appIds);
}
async getLockdownExemptionApps() {
let workspaceId: number = 100; // Workspace ID, which is passed by the user.
let appIds: string[] = await LockDownExemptionApi.getLockdownExemptionApps(workspaceId);
// Process the post-logic after obtaining the apps exempted from deep freeze.
}
build() {
Column() {
Row() {
Button($r('app.string.setLockdownExemptionApps'))
.buttonCommonStyle()
.onClick(() => {
this.setLockdownExemptionApps();
})
}
Row() {
Button($r('app.string.getLockdownExemptionApps'))
.buttonCommonStyle()
.onClick(() => {
this.getLockdownExemptionApps();
})
}
Row() {
Button($r('app.string.back'))
.buttonCommonStyle()
.onClick(() => {
router.back();
})
}
}
}
}
@Extend(Button)
function buttonCommonStyle() {
.width(200)
.height(50)
.backgroundColor('#6366F1')
.fontColor('#FFFFFF')
.fontSize(14)
.margin({ left: 20, bottom: 5 })
}