数据安全使用教程
功能概述
数据安全功能提供无人机和遥控器的日志清除能力,帮助用户在需要时清理设备中的飞行日志和操作记录。适用于对数据隐私有要求的行业应用场景。
主要功能
- 清除无人机 ROS 日志
- 清除遥控器 ROS 日志
- 操作确认对话框
- 飞行状态检查(飞行中禁止清除)
- 操作结果日志记录
核心 SDK 接口
清除无人机日志
通过无人机的 KeyManager 调用 HardwareDataSecurityKey.KeyLogClear:
val drone = DeviceManager.getDeviceManager().getFirstDroneDevice()
val keyManager = drone?.getKeyManager() ?: return
val key = KeyTools.createKey(HardwareDataSecurityKey.KeyLogClear)
keyManager.performAction(key, null,
object : CommonCallbacks.CompletionCallbackWithParam<Boolean> {
override fun onSuccess(t: Boolean?) {
// 无人机日志清除成功
}
override fun onFailure(error: IAutelCode, msg: String?) {
// 清除失败
}
})
清除遥控器日志
通过遥控器的 KeyManager(注意:使用 getLocalRemoteDevice() 而非飞机设备):
val rc = DeviceManager.getDeviceManager().getLocalRemoteDevice()
val keyManager = rc?.getKeyManager() ?: return
val key = KeyTools.createKey(RemoteControllerKey.KeyLogClear)
keyManager.performAction(key, null,
object : CommonCallbacks.CompletionCallbackWithParam<Boolean> {
override fun onSuccess(t: Boolean?) {
// 遥控器日志清除成功
}
override fun onFailure(error: IAutelCode, msg: String?) {
// 清除失败
}
})
飞行状态检查
在执行日志清除操作前,需检查飞机是否在飞行中(使用缓存值快速判断):
fun isDroneFlying(drone: IAutelDroneDevice): Boolean {
return try {
val km = drone.getKeyManager()
val key = KeyTools.createKey(CommonKey.KeyMissionHeartbeatStatusReport)
val fcsFlightMode = km.getCacheValue(key)?.fcsFlightMode ?: return false
fcsFlightMode.isFlying()
} catch (_: Throwable) {
false
}
}
// 使用示例
val drone = DeviceManager.getDeviceManager().getFirstDroneDevice()
if (drone != null && isDroneFlying(drone)) {
// 飞行中,禁止清除日志
} else {
// 非飞行状态,可以执行清除
clearDroneLogs()
}
注意事项
- 飞行状态保护:飞行中禁止执行日志清除操作,以避免影响飞行安全
- 操作不可逆:日志清除后无法恢复,建议在清除前先进行确认
- 日志类型:当前支持清除 ROS 系统日志,不包含 SD 卡中的媒体文件
- 无人机和遥控器日志需分别清除