Skip to content

Commit 6873d14

Browse files
committed
Only request screening role with Android Q or higher
1 parent 2e5a6f0 commit 6873d14

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/src/main/java/com/addev/listaspam/MainActivity.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class MainActivity : AppCompatActivity() {
118118
/**
119119
* Requests the call screening role.
120120
*/
121+
@RequiresApi(Build.VERSION_CODES.Q)
121122
private fun requestCallScreeningRole() {
122123
val telecomManager = ContextCompat.getSystemService(this, TelecomManager::class.java)
123124

@@ -142,4 +143,20 @@ class MainActivity : AppCompatActivity() {
142143
showToast(this, getString(R.string.call_screening_role_prompt), Toast.LENGTH_LONG)
143144
}
144145
}
146+
147+
/*
148+
/**
149+
* Requests the call screening role for Android P (API level 28) and below.
150+
* @param telecomManager The TelecomManager for managing telecom services.
151+
*/
152+
private fun requestRoleForBelowQ(telecomManager: TelecomManager) {
153+
if (telecomManager.defaultDialerPackage == packageName) {
154+
showToast(this, getString(R.string.call_screening_role_already_granted))
155+
} else {
156+
val intent = Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
157+
startActivity(intent)
158+
showToast(this, getString(R.string.call_screening_role_prompt), Toast.LENGTH_LONG)
159+
}
160+
}
161+
*/
145162
}

0 commit comments

Comments
 (0)