1,本地持久化锁别名
2,对讲锁 新增本地通知用于设备处于后台及前台的呼叫提醒 3,解决接听成功后,超过六十秒的安全处理及逻辑优化
This commit is contained in:
parent
7917f585ab
commit
063e62d087
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
import 'app.dart';
|
||||
@ -17,6 +18,8 @@ FutureOr<void> main() async {
|
||||
// 设置国际化信息
|
||||
await _initTranslation();
|
||||
|
||||
initLocalNotification();
|
||||
|
||||
runApp(MyApp());
|
||||
|
||||
if (AppPlatform.isAndroid) {
|
||||
@ -45,3 +48,14 @@ Future _setCommonServices() async {
|
||||
}
|
||||
// Get.log(PlatformInfoService.to.info.version);
|
||||
}
|
||||
|
||||
initLocalNotification() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
final AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('app_icon');
|
||||
final InitializationSettings initializationSettings =
|
||||
InitializationSettings(android: initializationSettingsAndroid);
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
}
|
||||
|
||||
@ -724,6 +724,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 3 修改了锁名字
|
||||
state.lockAlias.value = event.setResult;
|
||||
state.keyInfos.value.lockAlias = event.setResult;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
} else if (event.type == 4) {
|
||||
// 4 更新了电量
|
||||
state.electricQuantity.value = int.parse(event.setResult);
|
||||
|
||||
@ -108,6 +108,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
|
||||
state.isOpenPassageMode.value = state.keyInfos.value.passageMode!;
|
||||
state.lockAlias.value = state.keyInfos.value.lockAlias!;
|
||||
Storage.setString(saveLockAlias, state.lockAlias.value);
|
||||
|
||||
BlueManage().connectDeviceName =
|
||||
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||
|
||||
@ -3,6 +3,7 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_voice_processor/flutter_voice_processor.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/talk/call/callTalk.dart';
|
||||
@ -43,36 +44,52 @@ class LockMonitoringLogic extends BaseGetXController {
|
||||
void _getUDPStatusRefreshUIAction() {
|
||||
_getUDPStatusRefreshUIEvent =
|
||||
eventBus.on<GetUDPStatusRefreshUI>().listen((event) {
|
||||
if (UDPTalkClass().isEndCall == true) {
|
||||
state.oneMinuteTimeTimer.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
state.udpStatus.value = event.udpStatus;
|
||||
if (state.udpStatus.value == 8) {
|
||||
if (state.oneMinuteTime.value >= 60) {
|
||||
// 超过60秒了
|
||||
_getUDPStatusRefreshUIEvent!.cancel();
|
||||
if (state.oneMinuteTimeTimer != null) {
|
||||
state.oneMinuteTimeTimer.cancel();
|
||||
}
|
||||
initiateUdpHangUpAction();
|
||||
print('输出挂断1');
|
||||
return;
|
||||
}
|
||||
// 接听成功了,然后刷新界面的时间 60秒以后自动挂断
|
||||
state.oneMinuteTimeTimer =
|
||||
Timer.periodic(const Duration(seconds: 1), (Timer t) async {
|
||||
state.oneMinuteTime.value++;
|
||||
// Get.log('state.oneMinuteTime.value:${state.oneMinuteTime.value}');
|
||||
if (UDPTalkClass().isEndCall == true) {
|
||||
return;
|
||||
}
|
||||
if (state.oneMinuteTime.value >= 60) {
|
||||
// 超过60秒了
|
||||
state.oneMinuteTimeTimer.cancel();
|
||||
state.oneMinuteTime.value = 0;
|
||||
print('输出挂断1');
|
||||
// 挂断
|
||||
UDPSenderManage.sendMainProtocol(
|
||||
command: 150,
|
||||
commandTypeIsCalling: 1,
|
||||
subCommand: 30,
|
||||
lockID: UDPManage().lockId,
|
||||
lockIP: UDPManage().host,
|
||||
userMobile: await state.userUid,
|
||||
userMobileIP: await state.userMobileIP,
|
||||
endData: []);
|
||||
// if (state.oneMinuteTime.value >= 60) {
|
||||
// // 超过60秒了
|
||||
// _getUDPStatusRefreshUIEvent!.cancel();
|
||||
// if (state.oneMinuteTimeTimer != null) {
|
||||
// state.oneMinuteTimeTimer.cancel();
|
||||
// }
|
||||
// initiateUdpHangUpAction();
|
||||
// print('输出挂断1');
|
||||
// state.oneMinuteTime.value = 0;
|
||||
// // 挂断
|
||||
// UDPSenderManage.sendMainProtocol(
|
||||
// command: 150,
|
||||
// commandTypeIsCalling: 1,
|
||||
// subCommand: 30,
|
||||
// lockID: UDPManage().lockId,
|
||||
// lockIP: UDPManage().host,
|
||||
// userMobile: await state.userUid,
|
||||
// userMobileIP: await state.userMobileIP,
|
||||
// endData: []);
|
||||
|
||||
CallTalk().stopPcmSound();
|
||||
// 关闭当前界面
|
||||
Get.back();
|
||||
}
|
||||
// CallTalk().stopPcmSound();
|
||||
// // 关闭当前界面
|
||||
// Get.back();
|
||||
// }
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -93,6 +110,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
||||
// 检查条件,如果达到6秒且未得到应答,则认为失败
|
||||
if (state.answerSeconds >= 6) {
|
||||
state.answerTimer.cancel();
|
||||
showToast("接听失败");
|
||||
initiateUdpHangUpAction();
|
||||
// UDPTalkClass().callNoAnswer();
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/talk/call/callTalk.dart';
|
||||
import 'package:star_lock/talk/udp/udp_talkClass.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../login/selectCountryRegion/common/index.dart';
|
||||
@ -25,8 +26,11 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initAsync();
|
||||
}
|
||||
|
||||
requestMicrophonePermission();
|
||||
Future<void> initAsync() async {
|
||||
await requestMicrophonePermission();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -196,6 +200,7 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
||||
state.isClickHangUp.value = true;
|
||||
} else {
|
||||
print('点了这里?');
|
||||
UDPTalkClass().stopLocalAudio();
|
||||
}
|
||||
}),
|
||||
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
|
||||
|
||||
@ -17,9 +17,7 @@ class CallTalk {
|
||||
static int ABUF_NUM = 100;
|
||||
static int FIRSTINDEX = 1;
|
||||
|
||||
int status = 0; // 假设有这个成员变量
|
||||
IframeInfo? iframe; // 假设有这个成员变量
|
||||
bool getFirstFrame = false; //是否得到了第一帧
|
||||
List<int> allDataBytes = <int>[]; //音频数据
|
||||
|
||||
CallTalk._init() {
|
||||
@ -105,15 +103,19 @@ class CallTalk {
|
||||
|
||||
// 如果是同一帧就添加起来
|
||||
if (getIframeIndex == iframe!.iframeIndex) {
|
||||
var getList = bb.sublist(77, bb.length);
|
||||
var getList = bb.sublist(POS_data, bb.length);
|
||||
iframe!.bb!.addAll(getList);
|
||||
}
|
||||
// print('iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
|
||||
// print(
|
||||
// 'iframe.bagNum: ${iframe!.bagNum} iframe.bagReceive: ${iframe!.bagReceive}');
|
||||
|
||||
// 如果收到的包数等于总包数,说明这一帧数据已经接收完毕
|
||||
if (iframe!.bagNum == iframe!.bagReceive) {
|
||||
if (iframe!.bagNum == iframe!.bagReceive &&
|
||||
getIframeIndex == iframe!.iframeIndex) {
|
||||
// print('播放第${iframe!.iframeIndex}帧 一帧图片的hexStringData: ${Uint8List.fromList(growableList)}');
|
||||
eventBus.fire(GetTVDataRefreshUI(iframe!.bb!));
|
||||
} else {
|
||||
// print('接收到的包数不等于总包数');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
class IframeInfo {
|
||||
int iframeIndex = -1;
|
||||
int iframeIndex = 0;
|
||||
int iframeTime = 0;
|
||||
int bagNum = 0;
|
||||
int bagReceive = 1;
|
||||
@ -12,7 +10,7 @@ class IframeInfo {
|
||||
int codecMode = 0;
|
||||
|
||||
IframeInfo() {
|
||||
iframeIndex = -1;
|
||||
iframeIndex = 0;
|
||||
bagNum = 0;
|
||||
bagReceive = 0;
|
||||
isFull = false;
|
||||
|
||||
@ -114,8 +114,6 @@ class CommandUDPReciverManager {
|
||||
//结束对讲反馈
|
||||
print("结束对讲反馈");
|
||||
}
|
||||
UDPTalkClass().isEndCall = true;
|
||||
LockMonitoringState().isClickHangUp.value = false;
|
||||
UDPTalkClass().callNoAnswer();
|
||||
// UDPTalkClass().status = 0;
|
||||
// UDPTalkClass().isBeCall = false;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:fast_gbk/fast_gbk.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_state.dart';
|
||||
import 'package:star_lock/talk/call/callTalk.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
@ -76,6 +77,10 @@ class UDPTalkClass {
|
||||
|
||||
Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
|
||||
}
|
||||
|
||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
_showNotification(flutterLocalNotificationsPlugin);
|
||||
playLocalAudio();
|
||||
|
||||
if (isEndCall == true) {
|
||||
@ -95,6 +100,22 @@ class UDPTalkClass {
|
||||
}
|
||||
}
|
||||
|
||||
//发送本地通知
|
||||
Future<void> _showNotification(
|
||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin) async {
|
||||
const AndroidNotificationDetails androidPlatformChannelSpecifics =
|
||||
AndroidNotificationDetails('your channel id', 'your channel name',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: 'ticker');
|
||||
const NotificationDetails platformChannelSpecifics =
|
||||
NotificationDetails(android: androidPlatformChannelSpecifics);
|
||||
var getLockName = await Storage.getString(saveLockAlias);
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
0, '呼叫提醒', '收到来自($getLockName)锁的呼叫。', platformChannelSpecifics,
|
||||
payload: 'item x');
|
||||
}
|
||||
|
||||
// 判断是否是call的本人
|
||||
Future<bool> isCallMe(List<int>? data) async {
|
||||
final loginData = await Storage.getLoginData();
|
||||
@ -156,7 +177,7 @@ class UDPTalkClass {
|
||||
CallTalk().stopPcmSound();
|
||||
status = 0;
|
||||
isBeCall = false;
|
||||
isEndCall = false;
|
||||
isEndCall = true;
|
||||
LockMonitoringState().isClickHangUp.value = false;
|
||||
|
||||
eventBus.fire(GetUDPStatusRefreshUI(status));
|
||||
|
||||
@ -6,7 +6,6 @@ import 'dart:convert';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../login/login/entity/LoginData.dart';
|
||||
import '../login/login/entity/LoginEntity.dart';
|
||||
|
||||
const saveBluePublicKey = "BluePublicKey";
|
||||
const saveBluePrivateKey = "BluePrivateKey";
|
||||
@ -20,6 +19,7 @@ const isAgreePosition = "isAgreePosition"; //是否同意获取位置弹窗
|
||||
const isAgreeCamera = "isAgreeCamera"; //是否同意获取相机/相册弹窗
|
||||
|
||||
const isShowUpdateVersion = "isShowUpdateVersion"; //是否更新弹窗
|
||||
const saveLockAlias = "saveLockAlias"; //锁别名
|
||||
|
||||
const saveUserLoginData = "userLoginData";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user