Skip to content

Commit

Permalink
fix: root: fixed crash on boot on Android 13 devices due to backgroun…
Browse files Browse the repository at this point in the history
…d restrictions
  • Loading branch information
timschneeb committed Mar 28, 2023
1 parent 0ff9b50 commit eaf9df7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,18 @@ class MainApplication : Application(), SharedPreferences.OnSharedPreferenceChang
addAction(Constants.ACTION_DISCARD_AUTHORIZATION)
})

if (!BuildConfig.ROOTLESS && isLegacyMode)
RootAudioProcessorService.updateLegacyMode(applicationContext, true)

try {
if (!BuildConfig.ROOTLESS && isLegacyMode)
RootAudioProcessorService.updateLegacyMode(applicationContext, true)
}
catch(ex: Exception) {
/* Throws ForegroundServiceStartNotAllowedException on Android 13 if
* the service cannot be started from this point and battery optimizations were not
* disabled. BootCompletedReceiver handles auto-start after boot.
*/
Timber.e("Failed to launch service in legacy mode on startup")
Timber.i(ex)
}
super.onCreate()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class BootCompletedReceiver : BroadcastReceiver(), KoinComponent {
!preferences.get<Boolean>(R.string.key_audioformat_processing)) {
RootAudioProcessorService.startServiceEnhanced(context)
}
else if(preferences.get<Boolean>(R.string.key_audioformat_processing))
RootAudioProcessorService.updateLegacyMode(context, true)
}
}
}

0 comments on commit eaf9df7

Please sign in to comment.