2025-03-04 21:34:34 +08:00
|
|
|
import UIAbility from '@ohos.app.ability.UIAbility';
|
|
|
|
|
import hilog from '@ohos.hilog';
|
|
|
|
|
import window from '@ohos.window';
|
|
|
|
|
import { makedir } from '../common/service/fileService'
|
|
|
|
|
import { Array2Byte } from '../common/utils/tools'
|
|
|
|
|
import { GlobalConfig } from '../config/global'
|
|
|
|
|
import { TempLogger } from '../common/utils/TempLogger';
|
|
|
|
|
import DB from '../common/database/DbSql';
|
|
|
|
|
import { initTable } from '../common/service/initable';
|
2025-03-05 16:22:24 +08:00
|
|
|
import Want from '@ohos.app.ability.Want';
|
2025-04-16 14:24:53 +08:00
|
|
|
import { examJudgeVersion, examPeerOccupy } from '../pages/judgeSDK/api';
|
2025-03-04 21:34:34 +08:00
|
|
|
|
|
|
|
|
export default class EntryAbility extends UIAbility {
|
|
|
|
|
async onCreate(want, launchParam) {
|
|
|
|
|
try {
|
|
|
|
|
console.log("sql first")
|
|
|
|
|
await DB.init(this.context)
|
|
|
|
|
// 创建一个user表
|
|
|
|
|
await initTable()
|
|
|
|
|
console.log("sql first success")
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('sql first error', e)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-05 16:22:24 +08:00
|
|
|
async onDestroy() {
|
2025-03-04 21:34:34 +08:00
|
|
|
const arrClose = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00]
|
|
|
|
|
const arrCloseBuffer = Array2Byte(arrClose).buffer
|
|
|
|
|
globalThis?.lightLineUdp?.send(arrCloseBuffer);
|
2025-03-05 16:22:24 +08:00
|
|
|
let want: Want = {
|
|
|
|
|
deviceId: '',
|
|
|
|
|
bundleName: 'com.oh.dts',
|
|
|
|
|
abilityName: 'ServiceExtAbility'
|
|
|
|
|
};
|
|
|
|
|
await this.context.stopServiceExtensionAbility(want)
|
2025-03-04 21:34:34 +08:00
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onWindowStageCreate(windowStage: window.WindowStage) {
|
|
|
|
|
// this.context
|
|
|
|
|
// Main window is created, set main page for this ability
|
|
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
2025-04-01 17:53:30 +08:00
|
|
|
setInterval(() => {
|
|
|
|
|
console.log("examPeerOccupy", examPeerOccupy())
|
2025-04-02 18:04:24 +08:00
|
|
|
}, 5000)
|
2025-03-04 21:34:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
globalThis.carInfo = {}
|
|
|
|
|
globalThis.examinerInfo = {}
|
|
|
|
|
globalThis.deviceNo = '';
|
|
|
|
|
globalThis.hasAuth = false
|
|
|
|
|
|
|
|
|
|
globalThis.version = GlobalConfig.version.jn.km3[0];
|
2025-04-17 15:01:19 +08:00
|
|
|
globalThis.judgeVersion = GlobalConfig.version.jn.km3[1];
|
2025-03-04 21:34:34 +08:00
|
|
|
globalThis.tcpSendNum = 0
|
|
|
|
|
globalThis.videoVersion = '1.0'
|
|
|
|
|
|
|
|
|
|
//视频遮挡
|
|
|
|
|
globalThis.spzd = {
|
|
|
|
|
spzd1: false,
|
|
|
|
|
spzd2: false,
|
|
|
|
|
spzd3: false,
|
|
|
|
|
spzd4: false,
|
|
|
|
|
}
|
|
|
|
|
globalThis.signNum = 0 //心跳指令编号
|
|
|
|
|
globalThis.lsh = '0000000000000' //学员流水号
|
|
|
|
|
globalThis.ratio = 1700 / 960 //适配比例
|
|
|
|
|
globalThis.statue = 1 //考试状态
|
|
|
|
|
globalThis.pathDir = this.context.filesDir;
|
|
|
|
|
globalThis.context = this.context;
|
|
|
|
|
globalThis.isJudgeInitBool = false
|
|
|
|
|
console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir);
|
|
|
|
|
// this.requestPermission(this.context)
|
|
|
|
|
// this.featureAbilityAuth()
|
|
|
|
|
|
|
|
|
|
const windowClass = await windowStage.getMainWindow();
|
|
|
|
|
globalThis.windowClass = windowClass
|
|
|
|
|
// await windowClass.setWindowLayoutFullScreen(true)
|
|
|
|
|
await windowClass.setWindowSystemBarEnable([]) //全屏
|
|
|
|
|
// await windowClass.setWindowSystemBarEnable(['navi gation'])
|
|
|
|
|
|
|
|
|
|
windowStage.loadContent('pages/Index', (err, data) => {
|
|
|
|
|
if (err.code) {
|
|
|
|
|
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.creatFiles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onWindowStageDestroy() {
|
|
|
|
|
// Main window is destroyed, release UI related resources
|
|
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onForeground() {
|
|
|
|
|
// Ability has brought to foreground
|
|
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackground() {
|
|
|
|
|
// Ability has back to background
|
|
|
|
|
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
creatFiles() {
|
|
|
|
|
makedir('/testFile');
|
|
|
|
|
}
|
|
|
|
|
}
|