mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-05 10:49:26 +02:00
Add option to show exception from the background task logic main loop
This commit is contained in:
parent
422e823c29
commit
6dbb7579e8
5 changed files with 29 additions and 0 deletions
|
@ -49,6 +49,7 @@ import java.util.*
|
|||
|
||||
class BackgroundTaskLogic(val appLogic: AppLogic) {
|
||||
var pauseBackgroundLoop = false
|
||||
val lastLoopException = MutableLiveData<Exception?>().apply { value = null }
|
||||
|
||||
companion object {
|
||||
private const val CHECK_PERMISSION_INTERVAL = 10 * 1000L // all 10 seconds
|
||||
|
@ -531,6 +532,7 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
}
|
||||
} catch (ex: SecurityException) {
|
||||
// this is handled by an other main loop (with a delay)
|
||||
lastLoopException.postValue(ex)
|
||||
|
||||
appLogic.platformIntegration.setAppStatusMessage(AppStatusMessage(
|
||||
appLogic.context.getString(R.string.background_logic_error),
|
||||
|
@ -542,6 +544,8 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
Log.w(LOG_TAG, "exception during running main loop", ex)
|
||||
}
|
||||
|
||||
lastLoopException.postValue(ex)
|
||||
|
||||
appLogic.platformIntegration.setAppStatusMessage(AppStatusMessage(
|
||||
appLogic.context.getString(R.string.background_logic_error),
|
||||
appLogic.context.getString(R.string.background_logic_error_internal)
|
||||
|
|
|
@ -20,15 +20,18 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.navigation.Navigation
|
||||
import io.timelimit.android.R
|
||||
import io.timelimit.android.databinding.FragmentDiagnoseMainBinding
|
||||
import io.timelimit.android.extensions.safeNavigate
|
||||
import io.timelimit.android.logic.DefaultAppLogic
|
||||
|
||||
class DiagnoseMainFragment : Fragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
val binding = FragmentDiagnoseMainBinding.inflate(inflater, container, false)
|
||||
val navigation = Navigation.findNavController(container!!)
|
||||
val logic = DefaultAppLogic.with(context!!)
|
||||
|
||||
binding.diagnoseClockButton.setOnClickListener {
|
||||
navigation.safeNavigate(
|
||||
|
@ -65,6 +68,17 @@ class DiagnoseMainFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
|
||||
logic.backgroundTaskLogic.lastLoopException.observe(this, Observer { ex ->
|
||||
if (ex != null) {
|
||||
binding.diagnoseBgTaskLoopExButton.isEnabled = true
|
||||
binding.diagnoseBgTaskLoopExButton.setOnClickListener {
|
||||
DiagnoseExceptionDialogFragment.newInstance(ex).show(fragmentManager!!)
|
||||
}
|
||||
} else {
|
||||
binding.diagnoseBgTaskLoopExButton.isEnabled = false
|
||||
}
|
||||
})
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/diagnose_bg_task_loop_ex_button"
|
||||
android:text="@string/diagnose_bg_task_loop_ex"
|
||||
android:enabled="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
|
|
@ -56,4 +56,6 @@
|
|||
<string name="diagnose_exf_lom">Sperrung nach Manipulationen deaktivieren</string>
|
||||
<string name="diagnose_exf_slb">Apps auf Systemebene sperren</string>
|
||||
<string name="diagnose_exf_mau">Nutzer nach Manipulation nerven</string>
|
||||
|
||||
<string name="diagnose_bg_task_loop_ex">Hintergrundaufgabenschleifenfehler</string>
|
||||
</resources>
|
||||
|
|
|
@ -56,4 +56,6 @@
|
|||
<string name="diagnose_exf_lom">Disable locking after manipulations</string>
|
||||
<string name="diagnose_exf_slb">Block Apps at system level</string>
|
||||
<string name="diagnose_exf_mau">Annoy user after manipulation</string>
|
||||
|
||||
<string name="diagnose_bg_task_loop_ex">Background task loop exception</string>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue