Make sure PermissionHelper singleton is created

This commit is contained in:
Sylvain Berfini 2021-11-02 12:40:54 +01:00
parent 7e0322abb5
commit 19b15e2b3b
2 changed files with 2 additions and 4 deletions

View file

@ -299,7 +299,6 @@ class CoreContext(val context: Context, coreConfig: Config) {
Log.i("=========================================") Log.i("=========================================")
core = Factory.instance().createCoreWithConfig(coreConfig, context) core = Factory.instance().createCoreWithConfig(coreConfig, context)
stopped = false stopped = false
Log.i("[Context] Ready") Log.i("[Context] Ready")
} }
@ -419,7 +418,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
/* Call related functions */ /* Call related functions */
fun initPhoneStateListener() { fun initPhoneStateListener() {
if (PermissionHelper.get().hasReadPhoneStatePermission()) { if (PermissionHelper.required(context).hasReadPhoneStatePermission()) {
try { try {
phoneStateListener = phoneStateListener =
Compatibility.createPhoneListener(context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager) Compatibility.createPhoneListener(context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager)

View file

@ -98,8 +98,7 @@ class TelecomHelper private constructor(context: Context) {
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
fun findExistingAccount(context: Context): PhoneAccount? { fun findExistingAccount(context: Context): PhoneAccount? {
if (!PermissionHelper.exists()) PermissionHelper.create(context) if (PermissionHelper.required(context).hasReadPhoneStateOrPhoneNumbersPermission()) {
if (PermissionHelper.get().hasReadPhoneStateOrPhoneNumbersPermission()) {
var account: PhoneAccount? = null var account: PhoneAccount? = null
val phoneAccountHandleList: List<PhoneAccountHandle> = val phoneAccountHandleList: List<PhoneAccountHandle> =
telecomManager.selfManagedPhoneAccounts telecomManager.selfManagedPhoneAccounts