dismiss keyguard for CallNotificationActivity (WIP, see TODO)

Whenever i click the button to accept the call, CallActivity is started by intent.
CallActivity itself has the same logic to dismiss the keyguard.

The problem is: When switching from CallNotificationActivity to CallActivity the lockscreen is shown indeed!
So i guess Android recognizes "oh, CallNotificationActivity is gone. Let's show the lockscreen" before it recognizes that
the new activity also dismiss the lockscreen ?!

I fear for this scenario it was not the best idea to have 2 different activies.. (before it was only 1 activity and 2 condcutor controllers..)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-10-28 16:26:03 +02:00
parent e05334cb9a
commit 57804c8d62
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 25 additions and 3 deletions

View File

@ -129,7 +129,8 @@
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:launchMode="singleTask"
android:taskAffinity=".call"
android:excludeFromRecents="true" />
android:excludeFromRecents="true"
android:showOnLockScreen="true"/>
<activity
android:name=".activities.CallNotificationActivity"
@ -138,7 +139,8 @@
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:launchMode="singleTask"
android:taskAffinity=".call"
android:excludeFromRecents="true" />
android:excludeFromRecents="true"
android:showOnLockScreen="true" />
<activity
android:name=".activities.FullScreenImageActivity"

View File

@ -21,6 +21,7 @@
package com.nextcloud.talk.activities;
import android.annotation.SuppressLint;
import android.app.KeyguardManager;
import android.app.PictureInPictureParams;
import android.content.Context;
import android.content.Intent;
@ -39,6 +40,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.Rational;
import android.view.View;
import android.view.WindowManager;
import com.bluelinelabs.logansquare.LoganSquare;
import com.facebook.common.executors.UiThreadImmediateExecutorService;
@ -130,6 +132,10 @@ public class CallNotificationActivity extends BaseActivity {
super.onCreate(savedInstanceState);
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
dismissKeyguard();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
eventBus.post(new CallNotificationClick());
binding = CallNotificationActivityBinding.inflate(getLayoutInflater());
@ -489,7 +495,6 @@ public class CallNotificationActivity extends BaseActivity {
}
void enterPipMode() {
// enableKeyguard();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
enterPictureInPictureMode(getPipParams());
} else {
@ -526,4 +531,19 @@ public class CallNotificationActivity extends BaseActivity {
binding.callAnswerButtons.setVisibility(View.VISIBLE);
binding.incomingCallRelativeLayout.setVisibility(View.VISIBLE);
}
// TODO: dismiss keyguard works, but whenever accepting the call and switch to CallActivity by intent, the
// lockscreen is shown (although CallActivity also dismisses the keyguard in the same way.)
private void dismissKeyguard() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true);
setTurnScreenOn(true);
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
keyguardManager.requestDismissKeyguard(this, null);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}
}