show an incoming call screen over the lockscreen, if the screen is off
This commit is contained in:
parent
4800ac3573
commit
8b3c08970c
|
@ -225,7 +225,8 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.DialerActivity"
|
android:name=".activities.DialerActivity"
|
||||||
android:label="@string/dialer"
|
android:label="@string/dialer"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask"
|
||||||
|
android:showOnLockScreen="true">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.CALL"/>
|
<action android:name="android.intent.action.CALL"/>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.os.PowerManager
|
||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import android.telecom.PhoneAccount
|
import android.telecom.PhoneAccount
|
||||||
import android.telecom.TelecomManager
|
import android.telecom.TelecomManager
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
|
@ -48,6 +49,11 @@ class DialerActivity : SimpleActivity(), SensorEventListener {
|
||||||
setContentView(R.layout.activity_dialer)
|
setContentView(R.layout.activity_dialer)
|
||||||
initProximityWakeLock()
|
initProximityWakeLock()
|
||||||
LocalBroadcastManager.getInstance(applicationContext).registerReceiver(messageReceiver, IntentFilter(DIALER_INTENT_FILTER))
|
LocalBroadcastManager.getInstance(applicationContext).registerReceiver(messageReceiver, IntentFilter(DIALER_INTENT_FILTER))
|
||||||
|
window.apply {
|
||||||
|
addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
|
||||||
|
addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
|
||||||
|
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
}
|
||||||
|
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
val extras = intent.extras
|
val extras = intent.extras
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
package com.simplemobiletools.contacts.pro.services
|
package com.simplemobiletools.contacts.pro.services
|
||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
|
import android.app.KeyguardManager
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import android.telecom.InCallService
|
import android.telecom.InCallService
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.simplemobiletools.contacts.pro.helpers.CALL_NUMBER
|
import com.simplemobiletools.contacts.pro.activities.DialerActivity
|
||||||
import com.simplemobiletools.contacts.pro.helpers.CALL_STATUS
|
import com.simplemobiletools.contacts.pro.helpers.*
|
||||||
import com.simplemobiletools.contacts.pro.helpers.DIALER_INTENT_FILTER
|
|
||||||
import com.simplemobiletools.contacts.pro.helpers.IS_INCOMING_CALL
|
|
||||||
import com.simplemobiletools.contacts.pro.objects.CallManager
|
import com.simplemobiletools.contacts.pro.objects.CallManager
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
@TargetApi(Build.VERSION_CODES.M)
|
||||||
|
@ -25,12 +27,24 @@ class MyIncomingCallService : InCallService() {
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||||
|
if (keyguardManager.isKeyguardLocked) {
|
||||||
|
Intent(this, DialerActivity::class.java).apply {
|
||||||
|
action = RESUME_DIALER
|
||||||
|
flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
putExtra(CALL_NUMBER, callerNumber)
|
||||||
|
putExtra(CALL_STATUS, call.state)
|
||||||
|
putExtra(IS_INCOMING_CALL, true)
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Intent(this, DialerCallService::class.java).apply {
|
Intent(this, DialerCallService::class.java).apply {
|
||||||
putExtra(CALL_STATUS, call.state)
|
putExtra(CALL_STATUS, call.state)
|
||||||
putExtra(CALL_NUMBER, callerNumber)
|
putExtra(CALL_NUMBER, callerNumber)
|
||||||
putExtra(IS_INCOMING_CALL, true)
|
putExtra(IS_INCOMING_CALL, true)
|
||||||
startService(this)
|
startService(this)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CallManager.updateCall(call)
|
CallManager.updateCall(call)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue