Skip to content

Commit 69de793

Browse files
authored
Fix workflows for Firebase Sessions (#4841)
* Use googleServices.gradle * Move package level function to object to fix api surface check * Add android manifest file with versionName set to fix android tests * Update pinned deps * Make getApplicationInfo look leaner
1 parent f1c51b5 commit 69de793

File tree

6 files changed

+48
-20
lines changed

6 files changed

+48
-20
lines changed

firebase-sessions/firebase-sessions.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ android {
4242
}
4343

4444
dependencies {
45+
implementation("com.google.firebase:firebase-common-ktx:20.3.2")
46+
implementation("com.google.firebase:firebase-components:17.1.0")
47+
implementation("com.google.firebase:firebase-encoders-json:18.0.1")
4548
implementation("com.google.firebase:firebase-encoders:17.0.0")
46-
implementation(project(":encoders:firebase-encoders-json"))
4749
implementation("com.google.firebase:firebase-installations-interop:17.1.0")
48-
implementation("com.google.firebase:firebase-common-ktx:20.3.1")
49-
implementation("com.google.firebase:firebase-components:17.1.0")
5050
implementation(libs.androidx.annotation)
5151

5252
runtimeOnly("com.google.firebase:firebase-installations:17.1.3")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!--
2+
~ Copyright 2023 Google LLC
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
package="com.google.firebase.sessions.test"
19+
android:versionCode="1"
20+
android:versionName="1.0.0">
21+
22+
<application>
23+
24+
</application>
25+
26+
</manifest>

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/ApplicationInfo.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.firebase.sessions
1818

19-
import com.google.firebase.FirebaseApp
2019
import com.google.firebase.encoders.json.NumberedEnum
2120

2221
/** Enum denoting different development environments. */
@@ -58,17 +57,3 @@ internal data class ApplicationInfo(
5857
/** The android application information for the app. */
5958
val androidAppInfo: AndroidApplicationInfo,
6059
)
61-
62-
internal fun getApplicationInfo(firebaseApp: FirebaseApp): ApplicationInfo {
63-
val packageName = firebaseApp.applicationContext.packageName
64-
val packageInfo = firebaseApp.applicationContext.packageManager.getPackageInfo(packageName, 0)
65-
66-
return ApplicationInfo(
67-
appId = firebaseApp.options.applicationId,
68-
deviceModel = "",
69-
sessionSdkVersion = BuildConfig.VERSION_NAME,
70-
logEnvironment = LogEnvironment.LOG_ENVIRONMENT_PROD,
71-
androidAppInfo =
72-
AndroidApplicationInfo(packageName = packageName, versionName = packageInfo.versionName)
73-
)
74-
}

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SessionEvents.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,19 @@ internal object SessionEvents {
7474
),
7575
applicationInfo = getApplicationInfo(firebaseApp)
7676
)
77+
78+
fun getApplicationInfo(firebaseApp: FirebaseApp): ApplicationInfo {
79+
val context = firebaseApp.applicationContext
80+
val packageName = context.packageName
81+
val packageInfo = context.packageManager.getPackageInfo(packageName, 0)
82+
83+
return ApplicationInfo(
84+
appId = firebaseApp.options.applicationId,
85+
deviceModel = "",
86+
sessionSdkVersion = BuildConfig.VERSION_NAME,
87+
logEnvironment = LogEnvironment.LOG_ENVIRONMENT_PROD,
88+
androidAppInfo =
89+
AndroidApplicationInfo(packageName = packageName, versionName = packageInfo.versionName)
90+
)
91+
}
7792
}

firebase-sessions/src/test/kotlin/com/google/firebase/sessions/ApplicationInfoTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ApplicationInfoTest {
3131

3232
@Test
3333
fun applicationInfo_populatesInfoCorrectly() {
34-
val applicationInfo = getApplicationInfo(FakeFirebaseApp.fakeFirebaseApp())
34+
val applicationInfo = SessionEvents.getApplicationInfo(FakeFirebaseApp.fakeFirebaseApp())
3535
assertThat(applicationInfo)
3636
.isEqualTo(
3737
ApplicationInfo(

firebase-sessions/test-app/test-app.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
plugins {
1818
id("com.android.application")
1919
id("org.jetbrains.kotlin.android")
20-
id("com.google.gms.google-services")
2120
}
2221

2322
android {
@@ -47,3 +46,6 @@ dependencies {
4746
implementation("androidx.core:core-ktx:1.9.0")
4847
implementation("com.google.android.material:material:1.8.0")
4948
}
49+
50+
extra["packageName"] = "com.google.firebase.testing.sessions"
51+
apply(from = "../../gradle/googleServices.gradle")

0 commit comments

Comments
 (0)