接听挂断电话

This commit is contained in:
GYJ
2024-11-28 13:49:26 +08:00
parent 1da1683adc
commit b6cd0d0f2b
13 changed files with 305 additions and 13 deletions

View File

@@ -13,4 +13,34 @@ class ChannelManager {
yjPrint('$kGetCallLog 发生异常:$e');
}
}
static Future<void> acceptCall() async {
MethodChannel channel = MethodChannel(getChannelName(kAcceptCall));
try {
final result = await channel.invokeMethod(kAcceptCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kAcceptCall 发生异常:$e');
}
}
static Future<void> rejectCall() async {
MethodChannel channel = MethodChannel(getChannelName(kRejectCall));
try {
final result = await channel.invokeMethod(kRejectCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kRejectCall 发生异常:$e');
}
}
static Future<void> endCall() async {
MethodChannel channel = MethodChannel(getChannelName(kEndCall));
try {
final result = await channel.invokeMethod(kEndCall);
yjPrint(result);
} on PlatformException catch (e) {
yjPrint('$kEndCall 发生异常:$e');
}
}
}

View File

@@ -5,6 +5,9 @@ const String kGetCallLog = 'getCallLog';
const String kCallLogCallback = 'callLogCallback';
const String kCallStatusChange = 'callStatusChange';
const String kAcceptCall = 'acceptCall';
const String kEndCall = 'endCall';
const String kRejectCall = 'rejectCall';
String getChannelName(name) {
return kChannelBaseName + name;

View File

@@ -55,7 +55,15 @@ class GetCallLogEvent extends MyEvent {
}
class CallStatusChangeEvent extends MyEvent {
/// state = IncomingNumberReceived 来电接听
/// state = OutGoing 呼出
/// state = End 通话结束
/// state = Incoming 来电
CallStatusChangeModel model;
CallStatusChangeEvent({required this.model});
}
class CallReceivedEvent extends MyEvent {
CallReceivedEvent();
}