Add logs to debug next time notification request thrashes
Change-Id: I3613db1c5495549a0ea92ec96967b5c408c6aadb
This commit is contained in:
parent
2f5aff8fa5
commit
a5fa01d5bf
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## From https://developer.android.com/develop/ui/views/notifications/notification-permission#test
|
## From https://developer.android.com/develop/ui/views/notifications/notification-permission#test
|
||||||
|
|
||||||
PACKAGE_NAME=im.vector.app.debug
|
PACKAGE_NAME=de.spiritcroc.riotx.debug
|
||||||
|
|
||||||
# App is newly installed on a device that runs Android 13 or higher:
|
# App is newly installed on a device that runs Android 13 or higher:
|
||||||
|
|
||||||
|
|
|
@ -129,11 +129,13 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
||||||
get() = ViewModelProvider(this, viewModelFactory)
|
get() = ViewModelProvider(this, viewModelFactory)
|
||||||
|
|
||||||
fun <T : VectorViewEvents> VectorViewModel<*, *, T>.observeViewEvents(
|
fun <T : VectorViewEvents> VectorViewModel<*, *, T>.observeViewEvents(
|
||||||
|
logTag: String? = null,
|
||||||
observer: (T) -> Unit,
|
observer: (T) -> Unit,
|
||||||
) {
|
) {
|
||||||
val tag = this@VectorBaseActivity::class.simpleName.toString()
|
val tag = this@VectorBaseActivity::class.simpleName.toString()
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||||
|
logTag?.let { Timber.tag(it).i("observeViewEvents resumed - ${System.identityHashCode(this)}") }
|
||||||
viewEvents
|
viewEvents
|
||||||
.stream(tag)
|
.stream(tag)
|
||||||
.collect {
|
.collect {
|
||||||
|
|
|
@ -255,7 +255,8 @@ class HomeActivity :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
homeActivityViewModel.observeViewEvents {
|
Timber.tag("SC_NP_DBG").i("Starting home event observation")
|
||||||
|
homeActivityViewModel.observeViewEvents("SC_NP_DBG") {
|
||||||
when (it) {
|
when (it) {
|
||||||
is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it)
|
is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it)
|
||||||
is HomeActivityViewEvents.CurrentSessionNotVerified -> handleOnNewSession(it)
|
is HomeActivityViewEvents.CurrentSessionNotVerified -> handleOnNewSession(it)
|
||||||
|
@ -291,6 +292,7 @@ class HomeActivity :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleShowNotificationDialog() {
|
private fun handleShowNotificationDialog() {
|
||||||
|
Timber.tag("SC_NP_DBG").i("handleShowNotificationDialog")
|
||||||
notificationPermissionManager.eventuallyRequestPermission(this, postPermissionLauncher)
|
notificationPermissionManager.eventuallyRequestPermission(this, postPermissionLauncher)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ class HomeActivityViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
if (isInitialized) return
|
if (isInitialized) return
|
||||||
|
Timber.tag("SC_NP_DBG").i("Initialize homeActivity ${System.identityHashCode(this)}")
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
// Ensure Session is syncing
|
// Ensure Session is syncing
|
||||||
ensureSessionSyncingUseCase.execute()
|
ensureSessionSyncingUseCase.execute()
|
||||||
|
@ -189,6 +190,7 @@ class HomeActivityViewModel @AssistedInject constructor(
|
||||||
if (!didAskUser) {
|
if (!didAskUser) {
|
||||||
_viewEvents.post(HomeActivityViewEvents.ShowAnalyticsOptIn)
|
_viewEvents.post(HomeActivityViewEvents.ShowAnalyticsOptIn)
|
||||||
} else {
|
} else {
|
||||||
|
Timber.tag("SC_NP_DBG").i("didAskUser -> ask for notif permission")
|
||||||
_viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog)
|
_viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +212,7 @@ class HomeActivityViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Timber.tag("SC_NP_DBG").i("no analytics -> ask for notif permission")
|
||||||
_viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog)
|
_viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class NotificationPermissionManager @Inject constructor(
|
||||||
) {
|
) {
|
||||||
if (!sdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) return
|
if (!sdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) return
|
||||||
if (!vectorPreferences.areNotificationEnabledForDevice() && !ignorePreference) return
|
if (!vectorPreferences.areNotificationEnabledForDevice() && !ignorePreference) return
|
||||||
|
timber.log.Timber.tag("SC_NP_DBG").i("Checking notification permission")
|
||||||
checkPermissions(
|
checkPermissions(
|
||||||
listOf(Manifest.permission.POST_NOTIFICATIONS),
|
listOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
activity,
|
activity,
|
||||||
|
|
Loading…
Reference in New Issue