Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hang up does not work #11

Open
s681562 opened this issue Dec 21, 2021 · 0 comments
Open

Hang up does not work #11

s681562 opened this issue Dec 21, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@s681562
Copy link

s681562 commented Dec 21, 2021

Describe the bug
FlutterIncomingCall.endAllCalls();
FlutterIncomingCall.endCall(...);

These functions are not canceling current (income) call.
The connection is still going, the phone call is still going.

To Reproduce
Call your phone or take a call with your phone.
Use FlutterIncomingCall.endAllCalls(); or FlutterIncomingCall.endCall(...);
Nothing is happen, the call is not finishing by FlutterIncomingCall code.

Expected behavior
Immediately stop the phone call programmatically.

Screenshots
nothing to show

Please complete the following information:

  • Device: Samsung
  • OS: android 11
  • dart 2.16
  • flutter 2.8

Additional context
Add any other context about the problem here.

I worked under Android native. Hang up a current phone call is working well by this code below.
My code in android java. Please fix your flutter plugin.

@RequiresApi(api = Build.VERSION_CODES.P)
public static void hangup(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        TelecomManager tcm = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
        if (tcm != null) {
            try {
                if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ANSWER_PHONE_CALLS)
                        != PackageManager.PERMISSION_GRANTED) {
                    return;
                }

                tcm.endCall();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    else {
        Class classTelephony = null;
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            classTelephony = Class.forName(telephonyManager.getClass().getName());
            Method methodGetITelephony = classTelephony.getDeclaredMethod("getITelephony");
            methodGetITelephony.setAccessible(true);
            Object telephonyInterface = methodGetITelephony.invoke(telephonyManager);
            Class telephonyInterfaceClass = Class.forName(telephonyInterface.getClass().getName());
            Method methodEndCall = telephonyInterfaceClass.getDeclaredMethod("endCall");
            methodEndCall.invoke(telephonyInterface);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
@s681562 s681562 added the bug Something isn't working label Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant