Simplified screen lock handling

This commit is contained in:
Juha Heinanen
2022-01-14 09:57:57 +02:00
parent e1fd993f1f
commit e73be20160
2 changed files with 6 additions and 18 deletions

View File

@ -213,19 +213,11 @@ class BaresipService: Service() {
screenReceiver = object : BroadcastReceiver() {
override fun onReceive(contxt: Context, intent: Intent) {
when (intent.action) {
Intent.ACTION_SCREEN_ON ->
if (kgm.isKeyguardLocked) {
Log.d(TAG, "Screen on LOCKED")
if (Utils.isVisible()) {
val i = Intent("screen event")
i.putExtra("event", Intent.ACTION_SCREEN_ON)
LocalBroadcastManager.getInstance(this@BaresipService)
.sendBroadcast(i)
}
} else {
Log.d(TAG, "Screen on UNLOCKED")
}
if (kgm.isKeyguardLocked) {
Log.d(TAG, "Screen on when locked")
val i = Intent("screen event")
i.putExtra("event", Intent.ACTION_SCREEN_ON)
LocalBroadcastManager.getInstance(this@BaresipService).sendBroadcast(i)
}
}
}

View File

@ -170,11 +170,7 @@ class MainActivity : AppCompatActivity() {
screenEventReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val event = intent.getStringExtra("event")!!
if (event == Intent.ACTION_SCREEN_ON && Call.calls().size == 0) {
Log.d(TAG, "setShowWhenLocked == false")
Utils.setShowWhenLocked(this@MainActivity, false)
}
Utils.setShowWhenLocked(this@MainActivity, Call.calls().size > 0)
}
}