element-hq / riot-android

A glossy Matrix collaboration client for Android
Apache License 2.0
1.4k stars 394 forks source link

Audio and Video Call don't unlock the screen #3491

Open facb69 opened 4 years ago

facb69 commented 4 years ago

I've been trying to use Riot for almost a year but I'm about to give up. I have a self hosted Matrix server but also tried Matrix.org and I'm stuck on the same problem: the audio or video calls don't unlock the screen! Sometimes not even a single message shows up as push notification. Tried official Android 10 and Android 9 and Lineage OS 7.1.2 and unless the screen is unlock all I get is the audio ring so I must unlock the phone to answer. Also tried F-Droid and Google Play versions combined or not. Using my home server (which is poor on hardware) and with unlocked screen I have an almost instant response so the problem is not the Matrix server. I like the whole idea and that's why I have installed it on my server but it's impossible to get other people to use it when it doesn't do what others like WhatsApp do. I searched for an answer on this issues area but I cannot find a definitive one. And all information is outdated. I tried the community on Matrix too but got nothing, not even the courtesy of an answer. Can somebody, please, point me to the right directions? Thanks for the attention.

microchipster commented 4 years ago

Possibly related: https://github.com/vector-im/riot-android/issues/3446

EsmaeeilMoradi commented 4 years ago

1-Add this permission in the manifest:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

2-Handel and receive ACTION_MANAGE_OVERLAY_PERMISSION permission in activity class via Alert Dialog: (I Handeled in Vector home activity)

          if (!Settings.canDrawOverlays(this)) {
                new AlertDialog.Builder(VectorHomeActivity.this)
                        .setMessage(Html.fromHtml(getString(R.string.saba_receiving_a_permission_desc), Html.FROM_HTML_MODE_COMPACT))
                        .setPositiveButton(R.string.saba_receiving_a_permission, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                if (!Settings.canDrawOverlays(VectorHomeActivity.this)) {
                                    Intent intentTest = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
                                    startActivityForResult(intentTest, 0);
                                }
                            }
                        })
                        .setNegativeButton("", null)
                        .setCancelable(false)
                        .show();
            }

3-Add in VectorCallActivity

        Window winManager = getWindow();
        winManager.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        winManager.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        winManager.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
immanuelfodor commented 4 years ago

This is really needed. Do I understand it correctly that the above comment holds the solution to the wake up issue? Why not open a pull request to merge it soon?