-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SessionMaintainerFollower
and create in FirebaseSessions
when…
#5368
base: session-maintainer
Are you sure you want to change the base?
Conversation
Per [b/302184829](https://b.corp.google.com/issues/302184829), This configures the newly added [post release cleanup workflow](https://github.com/firebase/firebase-android-sdk/blob/master/.github/workflows/post_release_cleanup.yml) to add `NO_RELEASE_CHANGE` to the PR's body by default.
… we're a follower process.
Coverage Report 1This report is too large (214,739 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
Size Report 1Affected Products
Test Logs |
|
||
override val isForegroundProcess: Boolean | ||
get() { | ||
val runningAppProcessInfo = RunningAppProcessInfo() | ||
ActivityManager.getMyMemoryState(runningAppProcessInfo) | ||
return runningAppProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND | ||
return runningAppProcessInfo.importance <= RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go back to runningAppProcessInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND
because IMPORTANCE_FOREGROUND_SERVICE
is only available after a specific api level, and it'll make our logic complicated to also count services as leaders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the one integration test fails if we don't consider foreground services to be foreground processes https://github.com/firebase/firebase-android-sdk/blob/master/firebase-sessions/test-app/src/androidTest/kotlin/com/google/firebase/testing/sessions/FirebaseSessionsTest.kt
That suggests to me that we may need it. Thoughts?
SessionMaintainer { | ||
val tag = "SessionMaintainerFollow" | ||
|
||
override fun register(subscriber: SessionSubscriber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can say = Unit
instead of an empty body. Looks better in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a no-op the right thing to do for followers? Should they still notify the subscribers on register?
Perf relies on the AQS session id being set before the call to firebaseSessions.register
returns. Crashlytics is ok without an AQS session id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. We can force a lookup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I'm unsure. We notify subscribers on init, and getRegisteredSusbscribers
claims that it blocks until all subscribers are registered. Seems this should be okay, no?
Log.e(tag, "Error reading stored session data.", exception) | ||
emit(emptyPreferences()) | ||
} | ||
.map { preferences -> mapSessionsData(preferences) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be something like .map(::mapSessionsData)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that didn't work
FirebaseSessionsData(preferences[FirebaseSessionDataKeys.SESSION_ID]) | ||
} | ||
|
||
const val SESSION_CONFIGS_NAME = "firebase_session_settings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting top level constants directly in the file will cause the Firebase API check to complain, because it will generate a public class to put this in for Java. Maybe this and the FirebaseSessionDataKeys can go in a companion object instead.
@@ -22,4 +22,6 @@ import com.google.firebase.sessions.ProcessDetails | |||
class FakeProcessDetails( | |||
override val isDefaultProcess: Boolean = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have the process name and default process name in the interface, do we need this isDefaultProcess anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove.
data class FirebaseSessionsData(val sessionId: String?) | ||
|
||
/** Persists session data that needs to be synchronized across processes */ | ||
class SessionsDataRepository(private val context: Context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes should all be internal
visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
… we're a follower process.