Skip to content

Commit

Permalink
refactor: move permission checks for phone call and bluetooth actions…
Browse files Browse the repository at this point in the history
… to ActionUtils
  • Loading branch information
sds100 committed Dec 21, 2024
1 parent 8fd8f66 commit ffa0926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ object ActionUtils {
ActionId.END_PHONE_CALL,
-> return listOf(Permission.ANSWER_PHONE_CALL)

ActionId.PHONE_CALL -> return listOf(Permission.CALL_PHONE)

ActionId.ENABLE_BLUETOOTH, ActionId.DISABLE_BLUETOOTH, ActionId.TOGGLE_BLUETOOTH ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return listOf(Permission.FIND_NEARBY_DEVICES)
}

else -> Unit
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ class GetActionErrorUseCaseImpl(
return Error.SdkVersionTooLow(Build.VERSION_CODES.N)
}

is ActionData.PhoneCall ->
if (!permissionAdapter.isGranted(Permission.CALL_PHONE)) {
return Error.PermissionDenied(Permission.CALL_PHONE)
}

is ActionData.Sound -> {
soundsManager.getSound(action.soundUid).onFailure { error ->
return error
Expand All @@ -130,13 +125,6 @@ class GetActionErrorUseCaseImpl(
return it
}

is ActionData.Bluetooth ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
!permissionAdapter.isGranted(Permission.FIND_NEARBY_DEVICES)
) {
return Error.PermissionDenied(Permission.FIND_NEARBY_DEVICES)
}

else -> Unit
}

Expand Down

0 comments on commit ffa0926

Please sign in to comment.