Skip to content

Commit

Permalink
Merge master branch into basic-workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
fynngodau committed Aug 26, 2024
2 parents a6d108f + 108bd88 commit 79099a2
Show file tree
Hide file tree
Showing 204 changed files with 6,812 additions and 1,633 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
distribution: "temurin"
java-version: "17"
- name: "Gradle Wrapper validation"
uses: gradle/actions/wrapper-validation@v3
uses: gradle/actions/wrapper-validation@v4
- name: "Setup Gradle"
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4
- name: "Setup matchers"
run: |
# Setting up matchers...
Expand Down
2 changes: 2 additions & 0 deletions firebase-auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ android {

dependencies {
api project(':play-services-basement')

annotationProcessor project(':safe-parcel-processor')
}
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,27 @@ class FirebaseAuthServiceImpl(private val context: Context, override val lifecyc
}

override fun signInWithCredential(request: SignInWithCredentialAidlRequest, callbacks: IFirebaseAuthCallbacks) {
Log.d(TAG, "Not yet implemented: signInWithCredential")
callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported"))
lifecycleScope.launchWhenStarted {
Log.d(TAG, "signInWithCredential request: ${request.request}")
try {
val tokenResult = client.verifyAssertion(request.request.requestUri, request.request.postBody, request.request.returnSecureToken, request.request.returnIdpCredential)
Log.d(TAG, "signInWithCredential callback: $tokenResult ")
val idToken = tokenResult.getString("idToken")
val refreshToken = tokenResult.getString("refreshToken")
val getTokenResponse = client.getTokenByRefreshToken(refreshToken).toGetTokenResponse()
val accountInfoResult = client.getAccountInfo(idToken = idToken).getJSONArray("users").getJSONObject(0).toGetAccountInfoUser()
Log.d(TAG, "signInWithCredential callback: onGetTokenResponseAndUser")
callbacks.onGetTokenResponseAndUser(getTokenResponse, accountInfoResult)
} catch (e: Exception) {
Log.w(TAG, "signInWithCredential callback: onFailure", e)
callbacks.onFailure(Status(CommonStatusCodes.INTERNAL_ERROR, e.message))
}
}
}

override fun signInWithCredentialCompat(verifyAssertionRequest: VerifyAssertionRequest, callbacks: IFirebaseAuthCallbacks) {
Log.d(TAG, "Not yet implemented: signInWithCredentialCompat")
callbacks.onFailure(Status(CommonStatusCodes.CANCELED, "Not supported"))
Log.d(TAG, "signInWithCredentialCompat verifyAssertionRequest: $verifyAssertionRequest")
signInWithCredential(SignInWithCredentialAidlRequest(verifyAssertionRequest), callbacks)
}

override fun signInWithCustomToken(request: SignInWithCustomTokenAidlRequest, callbacks: IFirebaseAuthCallbacks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ class IdentityToolkitClient(context: Context, private val apiKey: String, privat
.put("token", token)
.put("returnSecureToken", returnSecureToken))

suspend fun verifyAssertion(requestUri: String? = null, postBody: String? = null, returnSecureToken: Boolean = true, returnIdpCredential: Boolean = true): JSONObject =
request("verifyAssertion", JSONObject()
.put("requestUri", requestUri)
.put("postBody", postBody)
.put("returnSecureToken", returnSecureToken)
.put("returnIdpCredential", returnIdpCredential))

suspend fun verifyPassword(email: String? = null, password: String? = null, tenantId: String? = null, returnSecureToken: Boolean = true): JSONObject =
request("verifyPassword", JSONObject()
.put("email", email)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@

package com.google.firebase.auth.api.internal;

import org.microg.safeparcel.AutoSafeParcelable;
import android.os.Parcel;

import androidx.annotation.NonNull;

import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;

@SafeParcelable.Class
public class SignInWithCredentialAidlRequest extends AbstractSafeParcelable {

@Field(1)
public VerifyAssertionRequest request;

public SignInWithCredentialAidlRequest(VerifyAssertionRequest request) {
this.request = request;
}

public SignInWithCredentialAidlRequest() {
}

@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
CREATOR.writeToParcel(this, dest, flags);
}

public static final SafeParcelableCreatorAndWriter<SignInWithCredentialAidlRequest> CREATOR = findCreator(SignInWithCredentialAidlRequest.class);

public class SignInWithCredentialAidlRequest extends AutoSafeParcelable {
public static final Creator<SignInWithCredentialAidlRequest> CREATOR = new AutoCreator<>(SignInWithCredentialAidlRequest.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,55 @@

package com.google.firebase.auth.api.internal;

import org.microg.safeparcel.AutoSafeParcelable;
import android.os.Parcel;

import androidx.annotation.NonNull;

import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;

@SafeParcelable.Class
public class VerifyAssertionRequest extends AbstractSafeParcelable {

@Field(2)
public String requestUri;
@Field(3)
public String accessToken;
@Field(4)
public String idToken;
@Field(5)
public String instanceId;
@Field(6)
public String providerId;
@Field(7)
public String pendingIdToken;
@Field(8)
public String postBody;
@Field(9)
public String localId;
@Field(10)
public boolean returnIdpCredential;
@Field(11)
public boolean returnSecureToken;
@Field(12)
public String delegatedProjectNumber;
@Field(13)
public String sessionId;
@Field(14)
public String queryParameter;
@Field(15)
public String tenantId;
@Field(16)
public boolean returnRefreshToken;
@Field(17)
public String tenantProjectNumber;

@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
CREATOR.writeToParcel(this, dest, flags);
}

public static final SafeParcelableCreatorAndWriter<VerifyAssertionRequest> CREATOR = findCreator(VerifyAssertionRequest.class);

public class VerifyAssertionRequest extends AutoSafeParcelable {
public static final Creator<VerifyAssertionRequest> CREATOR = new AutoCreator<>(VerifyAssertionRequest.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import android.os.Bundle;
import android.net.Uri;
import org.microg.gms.utils.ToStringHelper;

public class DynamicLinkData extends AbstractSafeParcelable {
@Field(1)
Expand Down Expand Up @@ -43,6 +44,19 @@ public DynamicLinkData(@Param(1) String dynamicLink, @Param(2) String deepLink,
this.redirectUrl = redirectUrl;
}

@NonNull
@Override
public String toString() {
return ToStringHelper.name("DynamicLinkData")
.field("dynamicLink", dynamicLink)
.field("deepLink", deepLink)
.field("minVersion", minVersion)
.field("clickTimestamp", clickTimestamp)
.field("extensionBundle", extensionBundle)
.field("redirectUrl", redirectUrl)
.end();
}

@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
CREATOR.writeToParcel(this, dest, flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

public class CallerInfo extends AutoSafeParcelable {
@Field(1)
public String s1;
public String source;
@Field(2)
public String s2;
public String medium;
@Field(3)
public String s3;
public String campaign;
@Field(4)
public String s4;
public String content;

@NonNull
@Override
public String toString() {
return "CallerInfo(" + s1 + "," + s2 + "," + s3 + "," + s4 + ")";
return "CallerInfo(" + source + "," + medium + "," + campaign + "," + content + ")";
}

public static final Creator<CallerInfo> CREATOR = new AutoCreator<>(CallerInfo.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private const val TAG = "AppInviteService"
class AppInviteService : BaseService(TAG, GmsService.APP_INVITE) {
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) {
PackageUtils.getAndCheckCallingPackage(this, request.packageName)
Log.d(TAG, "callb: $callback ; req: $request ; serv: $service")
callback.onPostInitComplete(0, AppInviteServiceImpl(this, request.packageName, request.extras), null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ object SettingsContract {
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"

const val LICENSING = "vending_licensing"
const val LICENSING_PURCHASE_FREE_APPS = "vending_licensing_purchase_free_apps"
const val BILLING = "vending_billing"

val PROJECTION = arrayOf(
LICENSING,
LICENSING_PURCHASE_FREE_APPS,
BILLING,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class SettingsProvider : ContentProvider() {
private fun queryVending(p: Array<out String>): Cursor = MatrixCursor(p).addRow(p) { key ->
when (key) {
Vending.LICENSING -> getSettingsBoolean(key, false)
Vending.LICENSING_PURCHASE_FREE_APPS -> getSettingsBoolean(key, false)
Vending.BILLING -> getSettingsBoolean(key, false)
else -> throw IllegalArgumentException("Unknown key: $key")
}
Expand All @@ -357,6 +358,7 @@ class SettingsProvider : ContentProvider() {
values.valueSet().forEach { (key, value) ->
when (key) {
Vending.LICENSING -> editor.putBoolean(key, value as Boolean)
Vending.LICENSING_PURCHASE_FREE_APPS -> editor.putBoolean(key, value as Boolean)
Vending.BILLING -> editor.putBoolean(key, value as Boolean)
else -> throw IllegalArgumentException("Unknown key: $key")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.common.internal;

parcelable MethodInvocation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.common.internal;

parcelable TelemetryData;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.common.internal.service;

import com.google.android.gms.common.internal.TelemetryData;

interface IClientTelemetryService {
oneway void log(in TelemetryData data) = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class GoogleSignInOptions extends AutoSafeParcelable {
private String logSessionId;

private GoogleSignInOptions() {
this.scopes = new ArrayList<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.common.internal;

import android.os.Parcel;

import androidx.annotation.NonNull;

import androidx.annotation.Nullable;
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;

import org.microg.gms.utils.ToStringHelper;

@SafeParcelable.Class
public class MethodInvocation extends AbstractSafeParcelable {

@Field(1)
final int methodKey;
@Field(2)
final int resultStatusCode;
@Field(3)
final int connectionResultStatusCode;
@Field(4)
final long startTimeMillis;
@Field(5)
final long endTimeMillis;
@Field(6)
@Nullable
final String callingModuleId;
@Field(7)
@Nullable
final String callingEntryPoint;
@Field(8)
final int serviceId;
@Field(value = 9, defaultValue = "-1")
final int latencyMillis;

@Constructor
public MethodInvocation(@Param(1) int methodKey, @Param(2) int resultStatusCode, @Param(3) int connectionResultStatusCode, @Param(4) long startTimeMillis, @Param(5) long endTimeMillis, @Param(6) @Nullable String callingModuleId, @Param(7) @Nullable String callingEntryPoint, @Param(8) int serviceId, @Param(9) int latencyMillis) {
this.methodKey = methodKey;
this.resultStatusCode = resultStatusCode;
this.connectionResultStatusCode = connectionResultStatusCode;
this.startTimeMillis = startTimeMillis;
this.endTimeMillis = endTimeMillis;
this.callingModuleId = callingModuleId;
this.callingEntryPoint = callingEntryPoint;
this.serviceId = serviceId;
this.latencyMillis = latencyMillis;
}

@NonNull
@Override
public String toString() {
return ToStringHelper.name("MethodInvocation")
.field("methodKey", methodKey)
.field("resultStatusCode", resultStatusCode)
.field("connectionResultStatusCode", connectionResultStatusCode)
.field("startTimeMillis", startTimeMillis)
.field("endTimeMillis", endTimeMillis)
.field("callingModuleId", callingModuleId)
.field("callingEntryPoint", callingEntryPoint)
.field("serviceId", serviceId)
.field("latencyMillis", latencyMillis)
.end();
}

public static SafeParcelableCreatorAndWriter<MethodInvocation> CREATOR = findCreator(MethodInvocation.class);

@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
CREATOR.writeToParcel(this, dest, flags);
}
}
Loading

0 comments on commit 79099a2

Please sign in to comment.