Skip to content

Commit

Permalink
handle nullable RestrictionsManager
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 5, 2024
1 parent 1f2d28f commit 0c8642c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.owncloud.android.datamodel.ReceiverFlag
import com.owncloud.android.utils.appConfig.AppConfigKeys

fun <T : Any> Context.getRestriction(appConfigKey: AppConfigKeys, defaultValue: T): T {
val restrictionsManager = getSystemService(Context.RESTRICTIONS_SERVICE) as RestrictionsManager
return restrictionsManager.getRestriction(appConfigKey.key, defaultValue)
val restrictionsManager = getSystemService(Context.RESTRICTIONS_SERVICE) as? RestrictionsManager
return restrictionsManager?.getRestriction(appConfigKey.key, defaultValue) ?: defaultValue
}

@Suppress("UNCHECKED_CAST")
Expand Down

0 comments on commit 0c8642c

Please sign in to comment.