Skip to content

Commit f241925

Browse files
authored
Merge branch 'master' into aar-extract-improvements
2 parents 712380e + eedc7cf commit f241925

File tree

8 files changed

+128
-102
lines changed

8 files changed

+128
-102
lines changed

build.gradle.kts

+32-32
Original file line numberDiff line numberDiff line change
@@ -107,41 +107,41 @@ publishing {
107107

108108
pom {
109109
name.set("firebase-java-sdk")
110-
description.set("The Firebase Java SDK is a pure java port of the Firebase Android SDK to run in clientside java environments such as the desktop.")
111-
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
112-
inceptionYear.set("2023")
113-
114-
scm {
115-
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
116-
connection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
117-
developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
118-
tag.set("HEAD")
119-
}
120-
121-
issueManagement {
122-
system.set("GitHub Issues")
123-
url.set("https://github.com/GitLiveApp/firebase-java-sdk/issues")
124-
}
125-
126-
developers {
127-
developer {
128-
name.set("Nicholas Bransby-Williams")
129-
email.set("[email protected]")
130-
}
131-
}
132-
133-
licenses {
134-
license {
135-
name.set("The Apache Software License, Version 2.0")
136-
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
137-
distribution.set("repo")
138-
comments.set("A business-friendly OSS license")
139-
}
140-
}
110+
description.set("The Firebase Java SDK is a pure java port of the Firebase Android SDK to run in clientside java environments such as the desktop.")
111+
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
112+
inceptionYear.set("2023")
113+
114+
scm {
115+
url.set("https://github.com/GitLiveApp/firebase-java-sdk")
116+
connection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
117+
developerConnection.set("scm:git:https://github.com/GitLiveApp/firebase-java-sdk.git")
118+
tag.set("HEAD")
119+
}
120+
121+
issueManagement {
122+
system.set("GitHub Issues")
123+
url.set("https://github.com/GitLiveApp/firebase-java-sdk/issues")
124+
}
125+
126+
developers {
127+
developer {
128+
name.set("Nicholas Bransby-Williams")
129+
email.set("[email protected]")
130+
}
131+
}
132+
133+
licenses {
134+
license {
135+
name.set("The Apache Software License, Version 2.0")
136+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
137+
distribution.set("repo")
138+
comments.set("A business-friendly OSS license")
139+
}
140+
}
141141
}
142142
}
143143
}
144-
}
144+
}
145145

146146
dependencies {
147147
compileOnly("org.robolectric:android-all:12.1-robolectric-8229987")

src/main/java/android/content/Context.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ open class Context {
5858
override fun getString(key: String, defaultValue: String?): String? {
5959
return when {
6060
key == "last-used-date" -> FirebasePlatform.firebasePlatform.retrieve(key) ?: defaultValue
61-
key.contains("|T|") -> null
61+
key.contains("|T|") -> null
6262
key.startsWith("com.google.firebase.auth.FIREBASE_USER") ->
6363
FirebasePlatform.firebasePlatform.retrieve(key) ?: defaultValue
6464
else -> throw IllegalArgumentException(key)
@@ -89,7 +89,7 @@ open class Context {
8989
override fun putString(key: String?, value: String?): Editor {
9090
when (key) {
9191
"last-used-date" -> FirebasePlatform.firebasePlatform.store(key, value.toString())
92-
else -> if(key?.startsWith("com.google.firebase.auth.FIREBASE_USER") == true) {
92+
else -> if (key?.startsWith("com.google.firebase.auth.FIREBASE_USER") == true) {
9393
FirebasePlatform.firebasePlatform.store(key, value.toString())
9494
} else {
9595
throw IllegalArgumentException(key)

src/main/java/android/net/Uri.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package android.net
22

33
import java.net.URI
4-
import java.util.*
4+
import java.util.Collections
55

66
class Uri(private val uri: URI) {
77

@@ -47,8 +47,8 @@ class Uri(private val uri: URI) {
4747
if (separator > end || separator == -1) {
4848
separator = end
4949
}
50-
if (separator - start == key.length
51-
&& query.regionMatches(start, key, 0, key.length)
50+
if (separator - start == key.length &&
51+
query.regionMatches(start, key, 0, key.length)
5252
) {
5353
if (separator == end) {
5454
return ""
@@ -64,4 +64,5 @@ class Uri(private val uri: URI) {
6464
}
6565
} while (true)
6666
return null
67-
}}
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package android.os
22

3-
class OperationCanceledException : RuntimeException()
3+
class OperationCanceledException : RuntimeException()

src/main/java/com/google/firebase/auth/FirebaseAuth.kt

+51-25
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,29 @@ import kotlinx.coroutines.GlobalScope
1515
import kotlinx.coroutines.launch
1616
import kotlinx.serialization.Serializable
1717
import kotlinx.serialization.Transient
18-
import kotlinx.serialization.json.*
19-
import okhttp3.*
18+
import kotlinx.serialization.json.Json
19+
import kotlinx.serialization.json.JsonArray
20+
import kotlinx.serialization.json.JsonElement
21+
import kotlinx.serialization.json.JsonNull
22+
import kotlinx.serialization.json.JsonObject
23+
import kotlinx.serialization.json.JsonPrimitive
24+
import kotlinx.serialization.json.booleanOrNull
25+
import kotlinx.serialization.json.contentOrNull
26+
import kotlinx.serialization.json.doubleOrNull
27+
import kotlinx.serialization.json.int
28+
import kotlinx.serialization.json.intOrNull
29+
import kotlinx.serialization.json.jsonObject
30+
import kotlinx.serialization.json.jsonPrimitive
31+
import kotlinx.serialization.json.longOrNull
32+
import okhttp3.Call
33+
import okhttp3.Callback
34+
import okhttp3.MediaType
35+
import okhttp3.OkHttpClient
36+
import okhttp3.Request
37+
import okhttp3.RequestBody
38+
import okhttp3.Response
2039
import java.io.IOException
21-
import java.util.*
40+
import java.util.Base64
2241
import java.util.concurrent.CopyOnWriteArrayList
2342
import java.util.concurrent.TimeUnit
2443

@@ -54,7 +73,7 @@ class FirebaseUserImpl private constructor(
5473
.orEmpty()
5574
}
5675

57-
val JsonElement.value get(): Any? = when(this) {
76+
val JsonElement.value get(): Any? = when (this) {
5877
is JsonNull -> null
5978
is JsonArray -> map { it.value }
6079
is JsonObject -> jsonObject.mapValues { (_, it) -> it.value }
@@ -79,10 +98,12 @@ class FirebaseUserImpl private constructor(
7998
override fun onResponse(call: Call, response: Response) {
8099
if (!response.isSuccessful) {
81100
FirebaseAuth.getInstance(app).signOut()
82-
source.setException(FirebaseAuthInvalidUserException(
83-
response.message(),
84-
FirebaseAuth.getInstance(app).formatErrorMessage("deleteAccount", request, response)
85-
))
101+
source.setException(
102+
FirebaseAuthInvalidUserException(
103+
response.message(),
104+
FirebaseAuth.getInstance(app).formatErrorMessage("deleteAccount", request, response)
105+
)
106+
)
86107
} else {
87108
source.setResult(null)
88109
}
@@ -98,7 +119,6 @@ class FirebaseUserImpl private constructor(
98119
}
99120

100121
override fun getIdToken(forceRefresh: Boolean) = FirebaseAuth.getInstance(app).getAccessToken(forceRefresh)
101-
102122
}
103123

104124
class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
@@ -126,7 +146,7 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
126146
val currentUser: FirebaseUser?
127147
get() = user
128148

129-
val FirebaseApp.key get() = "com.google.firebase.auth.FIREBASE_USER${"[${name}]".takeUnless { isDefaultApp }.orEmpty()}"
149+
val FirebaseApp.key get() = "com.google.firebase.auth.FIREBASE_USER${"[$name]".takeUnless { isDefaultApp }.orEmpty()}"
130150

131151
private var user: FirebaseUserImpl? = FirebasePlatform.firebasePlatform
132152
.runCatching { retrieve(app.key)?.let { FirebaseUserImpl(app, jsonParser.parseToJsonElement(it).jsonObject) } }
@@ -155,7 +175,7 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
155175
Log.i("FirebaseAuth", "Calling onIdTokenChanged for ${value?.uid} on listener $listener")
156176
listener.onIdTokenChanged(result)
157177
}
158-
for(listener in idTokenListeners) {
178+
for (listener in idTokenListeners) {
159179
listener.onIdTokenChanged(this@FirebaseAuth)
160180
}
161181
}
@@ -179,10 +199,12 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
179199
@Throws(IOException::class)
180200
override fun onResponse(call: Call, response: Response) {
181201
if (!response.isSuccessful) {
182-
source.setException(FirebaseAuthInvalidUserException(
183-
response.message(),
184-
formatErrorMessage("accounts:signUp", request, response)
185-
))
202+
source.setException(
203+
FirebaseAuthInvalidUserException(
204+
response.message(),
205+
formatErrorMessage("accounts:signUp", request, response)
206+
)
207+
)
186208
} else {
187209
val body = response.body()!!.use { it.string() }
188210
user = FirebaseUserImpl(app, jsonParser.parseToJsonElement(body).jsonObject, true)
@@ -212,10 +234,12 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
212234
@Throws(IOException::class)
213235
override fun onResponse(call: Call, response: Response) {
214236
if (!response.isSuccessful) {
215-
source.setException(FirebaseAuthInvalidUserException(
216-
response.message(),
217-
formatErrorMessage("verifyCustomToken", request, response)
218-
))
237+
source.setException(
238+
FirebaseAuthInvalidUserException(
239+
response.message(),
240+
formatErrorMessage("verifyCustomToken", request, response)
241+
)
242+
)
219243
} else {
220244
val body = response.body()!!.use { it.string() }
221245
val user = FirebaseUserImpl(app, jsonParser.parseToJsonElement(body).jsonObject)
@@ -245,10 +269,12 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
245269
@Throws(IOException::class)
246270
override fun onResponse(call: Call, response: Response) {
247271
if (!response.isSuccessful) {
248-
source.setException(FirebaseAuthInvalidUserException(
249-
response.message(),
250-
formatErrorMessage("verifyPassword", request, response)
251-
))
272+
source.setException(
273+
FirebaseAuthInvalidUserException(
274+
response.message(),
275+
formatErrorMessage("verifyPassword", request, response)
276+
)
277+
)
252278
} else {
253279
val body = response.body()!!.use { it.string() }
254280
val user = FirebaseUserImpl(app, jsonParser.parseToJsonElement(body).jsonObject)
@@ -266,14 +292,14 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
266292
}
267293

268294
fun signOut() {
269-
//todo cancel token refresher
295+
// todo cancel token refresher
270296
user = null
271297
}
272298

273299
override fun getAccessToken(forceRefresh: Boolean): Task<GetTokenResult> {
274300
val user = user ?: return Tasks.forException(FirebaseNoSignedInUserException("Please sign in before trying to get a token."))
275301

276-
if (!forceRefresh && user.createdAt + user.expiresIn*1000 - 5*60*1000 > System.currentTimeMillis() ) {
302+
if (!forceRefresh && user.createdAt + user.expiresIn * 1000 - 5 * 60 * 1000 > System.currentTimeMillis()) {
277303
// Log.i("FirebaseAuth", "returning existing token for user ${user.uid} from getAccessToken")
278304
return Tasks.forResult(GetTokenResult(user.idToken, user.claims))
279305
}

0 commit comments

Comments
 (0)