Skip to content

Commit c265898

Browse files
authored
Merge c9fb592 into df07a40
2 parents df07a40 + c9fb592 commit c265898

File tree

9 files changed

+278
-0
lines changed

9 files changed

+278
-0
lines changed

firebase-sessions/api.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Signature format: 2.0
2+
package com.google.firebase.sessions {
3+
4+
public final class FirebaseSessions {
5+
method @NonNull public static com.google.firebase.sessions.FirebaseSessions getInstance();
6+
method @NonNull public static com.google.firebase.sessions.FirebaseSessions getInstance(@NonNull com.google.firebase.FirebaseApp app);
7+
method @Discouraged(message="This will be replaced with a real API.") @NonNull public String greeting();
8+
property @NonNull public static final com.google.firebase.sessions.FirebaseSessions instance;
9+
field @NonNull public static final com.google.firebase.sessions.FirebaseSessions.Companion Companion;
10+
}
11+
12+
public static final class FirebaseSessions.Companion {
13+
method @NonNull public com.google.firebase.sessions.FirebaseSessions getInstance();
14+
method @NonNull public com.google.firebase.sessions.FirebaseSessions getInstance(@NonNull com.google.firebase.FirebaseApp app);
15+
property @NonNull public final com.google.firebase.sessions.FirebaseSessions instance;
16+
}
17+
18+
}
19+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
plugins {
16+
id("firebase-library")
17+
id("kotlin-android")
18+
}
19+
20+
firebaseLibrary {
21+
testLab.enabled = true
22+
publishSources = true
23+
}
24+
25+
android {
26+
val targetSdkVersion: Int by rootProject
27+
compileSdk = targetSdkVersion
28+
defaultConfig {
29+
minSdk = 16
30+
targetSdk = targetSdkVersion
31+
multiDexEnabled = true
32+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
33+
}
34+
compileOptions {
35+
sourceCompatibility = JavaVersion.VERSION_1_8
36+
targetCompatibility = JavaVersion.VERSION_1_8
37+
}
38+
kotlinOptions { jvmTarget = "1.8" }
39+
testOptions.unitTests.isIncludeAndroidResources = true
40+
}
41+
42+
dependencies {
43+
implementation(project(":firebase-common"))
44+
implementation(project(":firebase-common:ktx"))
45+
implementation(project(":firebase-components"))
46+
implementation(libs.androidx.annotation)
47+
48+
testImplementation(libs.junit)
49+
testImplementation(libs.truth)
50+
51+
androidTestImplementation(libs.androidx.test.junit)
52+
androidTestImplementation(libs.androidx.test.runner)
53+
androidTestImplementation(libs.truth)
54+
}

firebase-sessions/gradle.properties

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
version=0.1.0
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.sessions
16+
17+
import androidx.test.core.app.ApplicationProvider
18+
import androidx.test.ext.junit.runners.AndroidJUnit4
19+
import com.google.common.truth.Truth.assertThat
20+
import com.google.firebase.FirebaseApp
21+
import com.google.firebase.FirebaseOptions
22+
import com.google.firebase.ktx.Firebase
23+
import com.google.firebase.ktx.initialize
24+
import org.junit.After
25+
import org.junit.Before
26+
import org.junit.Test
27+
import org.junit.runner.RunWith
28+
29+
/**
30+
* Instrumented test, which will execute on an Android device.
31+
*
32+
* See [testing documentation](http://d.android.com/tools/testing).
33+
*/
34+
@RunWith(AndroidJUnit4::class)
35+
class FirebaseSessionsTests {
36+
@Before
37+
fun setUp() {
38+
Firebase.initialize(
39+
ApplicationProvider.getApplicationContext(),
40+
FirebaseOptions.Builder().setApplicationId("APP_ID").build()
41+
)
42+
}
43+
44+
@After
45+
fun cleanUp() {
46+
FirebaseApp.clearInstancesForTest()
47+
}
48+
49+
@Test
50+
fun mattDoesDayHi() {
51+
// This will be replaced with real tests.
52+
assertThat(FirebaseSessions.instance.greeting()).isEqualTo("Matt says hi!")
53+
}
54+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
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+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17+
package="com.google.firebase.sessions">
18+
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds-->
19+
<!--<uses-sdk android:minSdkVersion="16"/>-->
20+
21+
<application>
22+
<service android:name="com.google.firebase.components.ComponentDiscoveryService"
23+
android:exported="false">
24+
<meta-data
25+
android:name="com.google.firebase.components:com.google.firebase.sessions.FirebaseSessionsRegistrar"
26+
android:value="com.google.firebase.components.ComponentRegistrar" />
27+
</service>
28+
</application>
29+
</manifest>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.sessions
16+
17+
import androidx.annotation.Discouraged
18+
import com.google.firebase.FirebaseApp
19+
import com.google.firebase.ktx.Firebase
20+
import com.google.firebase.ktx.app
21+
22+
class FirebaseSessions internal constructor() {
23+
@Discouraged(message = "This will be replaced with a real API.")
24+
fun greeting(): String = "Matt says hi!"
25+
26+
companion object {
27+
@JvmStatic
28+
val instance: FirebaseSessions
29+
get() = getInstance(Firebase.app)
30+
31+
@JvmStatic
32+
fun getInstance(app: FirebaseApp): FirebaseSessions = app.get(FirebaseSessions::class.java)
33+
}
34+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.sessions
16+
17+
import androidx.annotation.Keep
18+
import com.google.firebase.components.Component
19+
import com.google.firebase.components.ComponentRegistrar
20+
import com.google.firebase.platforminfo.LibraryVersionComponent
21+
22+
/**
23+
* [ComponentRegistrar] for setting up [FirebaseSessions].
24+
*
25+
* @hide
26+
*/
27+
@Keep
28+
internal class FirebaseSessionsRegistrar : ComponentRegistrar {
29+
override fun getComponents() =
30+
listOf(
31+
Component.builder(FirebaseSessions::class.java)
32+
.name(LIBRARY_NAME)
33+
.factory { FirebaseSessions() }
34+
.build(),
35+
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME)
36+
)
37+
38+
companion object {
39+
private const val LIBRARY_NAME = "fire-ses"
40+
}
41+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.sessions
16+
17+
import com.google.common.truth.Truth.assertThat
18+
import org.junit.Test
19+
20+
/**
21+
* Example local unit test, which will execute on the development machine (host).
22+
*
23+
* See [testing documentation](http://d.android.com/tools/testing).
24+
*/
25+
class FirebaseSessionsTest {
26+
@Test
27+
fun mattDoesDayHi() {
28+
// This will be replaced with real tests.
29+
assertThat(FirebaseSessions().greeting()).isEqualTo("Matt says hi!")
30+
}
31+
}

subprojects.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ firebase-perf:ktx
5151
firebase-perf:dev-app
5252
firebase-perf:e2e-app
5353
# firebase-segmentation
54+
firebase-sessions
5455
firebase-storage
5556
firebase-storage:ktx
5657
protolite-well-known-types

0 commit comments

Comments
 (0)