|
|
@ -8,6 +8,7 @@ import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
|
|
|
|
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/utils/user_tool.dart';
|
|
|
|
import 'package:telephony/telephony.dart';
|
|
|
|
import 'package:telephony/telephony.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +54,7 @@ void onStart(ServiceInstance service ) async {
|
|
|
|
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
|
|
|
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
|
|
|
CallState state = await Telephony.instance.callState;
|
|
|
|
CallState state = await Telephony.instance.callState;
|
|
|
|
callState = state.name;
|
|
|
|
callState = state.name;
|
|
|
|
// print(callState!+" $flag");
|
|
|
|
print(123);
|
|
|
|
if (callState == "IDLE") {
|
|
|
|
if (callState == "IDLE") {
|
|
|
|
if (flag != 0) {
|
|
|
|
if (flag != 0) {
|
|
|
|
flag = 0;
|
|
|
|
flag = 0;
|
|
|
@ -68,7 +69,7 @@ void onStart(ServiceInstance service ) async {
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了");
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了");
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
print("没接通");
|
|
|
|
print("没接通");
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "没接通");
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: UserTool.userProvider.contentCon);
|
|
|
|
// print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//拨通时间
|
|
|
|
// print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//拨通时间
|
|
|
|
// print("你好$phoneNum");
|
|
|
|
// print("你好$phoneNum");
|
|
|
|
// // final inbox = telephony.getInboxSms();
|
|
|
|
// // final inbox = telephony.getInboxSms();
|
|
|
@ -83,6 +84,7 @@ void onStart(ServiceInstance service ) async {
|
|
|
|
// print('flag $flag');
|
|
|
|
// print('flag $flag');
|
|
|
|
} else if (callState == "OFFHOOK") {
|
|
|
|
} else if (callState == "OFFHOOK") {
|
|
|
|
flag++;
|
|
|
|
flag++;
|
|
|
|
|
|
|
|
flag*=-1;
|
|
|
|
// print('flag $flag');
|
|
|
|
// print('flag $flag');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|