Skip to content

Commit

Permalink
[CAT-114] 잠금 상태 모니터 구현 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
HyomK committed Aug 1, 2024
1 parent b040120 commit 165da12
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 15 additions & 1 deletion data/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
<receiver
android:name="com.pomonyang.mohanyang.data.local.device.receiver.LockScreenBroadcastReceiver"
android:enabled="true"
android:exported="false"
tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF" />
<action android:name="android.intent.action.SCREEN_ON" />

</intent-filter>
</receiver>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.pomonyang.mohanyang.data.local.device.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent

class LockScreenBroadcastReceiver(
private var lockStateListener: (Boolean) -> Unit
) : BroadcastReceiver() {

override fun onReceive(context: Context?, intent: Intent?) {
if (intent == null) return
when (intent.action) {
Intent.ACTION_SCREEN_ON -> lockStateListener(false)
Intent.ACTION_SCREEN_OFF -> lockStateListener(true)
}
}
}

0 comments on commit 165da12

Please sign in to comment.