Changes regarding incoming call notification & activity

This commit is contained in:
Sylvain Berfini 2022-03-08 14:01:53 +01:00
parent 94bc71932c
commit 8c71abb208
5 changed files with 23 additions and 11 deletions

View file

@ -121,16 +121,16 @@
android:windowSoftInputMode="adjustResize"/>
<activity android:name=".activities.call.CallActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:supportsPictureInPicture="true" />
<activity android:name=".activities.call.IncomingCallActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:noHistory="true" />
<activity android:name=".activities.call.OutgoingCallActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:noHistory="true" />
<activity

View file

@ -109,9 +109,8 @@ class CallActivity : ProximitySensorActivity() {
intent.setClass(this, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
} else {
finish()
}
finish()
} else {
coreContext.removeCallOverlay()
}

View file

@ -49,10 +49,10 @@ class IncomingCallActivity : GenericActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Compatibility.setShowWhenLocked(this, true)
Compatibility.setTurnScreenOn(this, true)
// Leaks on API 27+: https://stackoverflow.com/questions/60477120/keyguardmanager-memory-leak
Compatibility.requestDismissKeyguard(this)
Compatibility.setShowWhenLocked(this, true)
Compatibility.setTurnScreenOn(this, true)
binding = DataBindingUtil.setContentView(this, R.layout.call_incoming_activity)
binding.lifecycleOwner = this

View file

@ -101,9 +101,11 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
callsViewModel.noMoreCallEvent.observe(
viewLifecycleOwner
) {
it.consume {
Log.i("[Controls Fragment] No more call, finishing activity")
requireActivity().finish()
it.consume { noMoreCall ->
if (noMoreCall) {
Log.i("[Controls Fragment] No more call, finishing activity")
requireActivity().finish()
}
}
}

View file

@ -445,6 +445,17 @@ class NotificationsManager(private val context: Context) {
return
}
try {
val showLockScreenNotification = android.provider.Settings.Secure.getInt(
context.contentResolver,
"lock_screen_show_notifications",
0
)
Log.i("[Notifications Manager] Are notifications allowed on lock screen? ${showLockScreenNotification != 0} ($showLockScreenNotification)")
} catch (e: Exception) {
Log.e("[Notifications Manager] Failed to get android.provider.Settings.Secure.getInt(lock_screen_show_notifications): $e")
}
val notifiable = getNotifiableForCall(call)
if (notifiable.notificationId == currentForegroundServiceNotificationId) {
Log.e("[Notifications Manager] There is already a Service foreground notification for an incoming call, cancelling it")
@ -453,7 +464,7 @@ class NotificationsManager(private val context: Context) {
}
val incomingCallNotificationIntent = Intent(context, IncomingCallActivity::class.java)
incomingCallNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
incomingCallNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_USER_ACTION)
val pendingIntent = PendingIntent.getActivity(
context,
0,