feat: usb日志、轨迹拷入
This commit is contained in:
parent
4c81726cfe
commit
79c8cba21f
@ -40,6 +40,9 @@ async function compressFileToCache(input: string, output: string, context: commo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export class UsbUtils {
|
||||
private context: common.UIAbilityContext
|
||||
|
||||
@ -64,28 +67,38 @@ export class UsbUtils {
|
||||
async copyTrackToUsb() {
|
||||
let output = ""
|
||||
let temp = ""
|
||||
return this.getUsbDiskPath().then(path => {
|
||||
output = path
|
||||
return compressFileToCache('/data/log/duolun/logs', "track", this.context)
|
||||
}).then((trackPath) => {
|
||||
temp = trackPath
|
||||
return fs.copyFile(trackPath, output + '/' + "track.zip")
|
||||
}).then(() => {
|
||||
return fs.unlink(temp)
|
||||
})
|
||||
return this.getUsbDiskPath()
|
||||
.then(path => {
|
||||
output = path
|
||||
return compressFileToCache('/data/log/duolun/logs', "track", this.context)
|
||||
})
|
||||
.then((trackPath) => {
|
||||
temp = trackPath
|
||||
return fs.copyFile(trackPath, output + '/' + "track.zip")
|
||||
})
|
||||
.then(() => {
|
||||
return fs.unlink(temp)
|
||||
})
|
||||
.finally(() => {
|
||||
})
|
||||
}
|
||||
|
||||
async copyLogToUsb() {
|
||||
let output = ""
|
||||
let temp = ""
|
||||
return this.getUsbDiskPath().then(path => {
|
||||
output = path
|
||||
return compressFileToCache('/data/log/hilog', "log", this.context)
|
||||
}).then((trackPath) => {
|
||||
temp = trackPath
|
||||
return fs.copyFile(trackPath, output + '/' + "log.zip")
|
||||
}).then(() => {
|
||||
return fs.unlink(temp)
|
||||
})
|
||||
return this.getUsbDiskPath()
|
||||
.then(path => {
|
||||
output = path
|
||||
return compressFileToCache('/data/log/hilog', "log", this.context)
|
||||
})
|
||||
.then((trackPath) => {
|
||||
temp = trackPath
|
||||
return fs.copyFile(trackPath, output + '/' + "log.zip")
|
||||
})
|
||||
.then(() => {
|
||||
return fs.unlink(temp)
|
||||
})
|
||||
.finally(() => {
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,7 @@ import imageBtn from './compontents/imageBtn';
|
||||
import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
|
||||
import { updateModelAndCar } from '../common/autoUpdate/index'
|
||||
import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket';
|
||||
import { UsbUtils } from '../common/utils/UsbUtils';
|
||||
|
||||
|
||||
@Entry
|
||||
@ -61,6 +62,7 @@ struct Index {
|
||||
private avPlayer
|
||||
private context = getContext(this) as common.UIAbilityContext;
|
||||
private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket()
|
||||
private usbUtils: UsbUtils = new UsbUtils(this.context)
|
||||
|
||||
@Styles
|
||||
commStyle(){
|
||||
@ -218,6 +220,27 @@ struct Index {
|
||||
.fontColor('#CCAE7A')
|
||||
.fontSize(22 * globalThis.ratio)
|
||||
.margin({ right: 24 })
|
||||
.gesture(GestureGroup(GestureMode.Exclusive, TapGesture({ count: 2 }).onAction(() => {
|
||||
promptAction.showDialog({
|
||||
title: " U盘导出工具",
|
||||
buttons: [
|
||||
{
|
||||
text: '日志',
|
||||
color: '#000000'
|
||||
},
|
||||
{
|
||||
text: '轨迹',
|
||||
color: '#000000'
|
||||
}
|
||||
],
|
||||
}).then(res => {
|
||||
if (res.index === 0) {
|
||||
this.usbUtils.copyLogToUsb()
|
||||
} else {
|
||||
this.usbUtils.copyTrackToUsb()
|
||||
}
|
||||
})
|
||||
})))
|
||||
}
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user