diff --git a/play-services-auth/build.gradle b/play-services-auth/build.gradle index d95c5fa5c6..b10a6d0e50 100644 --- a/play-services-auth/build.gradle +++ b/play-services-auth/build.gradle @@ -43,4 +43,6 @@ dependencies { api project(':play-services-basement') api project(':play-services-fido') api project(':play-services-tasks') + + annotationProcessor project(':safe-parcel-processor') } diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInRequest.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInRequest.aidl new file mode 100644 index 0000000000..843cdbfaea --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInRequest.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +parcelable BeginSignInRequest; \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInResult.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInResult.aidl new file mode 100644 index 0000000000..994924a727 --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/BeginSignInResult.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +parcelable BeginSignInResult; \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.aidl new file mode 100644 index 0000000000..fc8071fc8b --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +parcelable GetPhoneNumberHintIntentRequest; \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.aidl new file mode 100644 index 0000000000..69650b8306 --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +parcelable GetSignInIntentRequest; \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/SignInCredential.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/SignInCredential.aidl new file mode 100644 index 0000000000..d2de274629 --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/SignInCredential.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +parcelable SignInCredential; \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IBeginSignInCallback.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IBeginSignInCallback.aidl new file mode 100644 index 0000000000..41b3e0065c --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IBeginSignInCallback.aidl @@ -0,0 +1,13 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity.internal; + +import com.google.android.gms.auth.api.identity.BeginSignInResult; +import com.google.android.gms.common.api.Status; + +interface IBeginSignInCallback { + void onResult(in Status status, in BeginSignInResult beginSignInResult); +} \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetPhoneNumberHintIntentCallback.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetPhoneNumberHintIntentCallback.aidl new file mode 100644 index 0000000000..a07988a2ac --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetPhoneNumberHintIntentCallback.aidl @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity.internal; + +import com.google.android.gms.common.api.Status; + +interface IGetPhoneNumberHintIntentCallback { + void onResult(in Status status, in PendingIntent pendingIntent); +} \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetSignInIntentCallback.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetSignInIntentCallback.aidl new file mode 100644 index 0000000000..ba6c5850c3 --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/IGetSignInIntentCallback.aidl @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity.internal; + +import com.google.android.gms.common.api.Status; + +interface IGetSignInIntentCallback { + void onResult(in Status status, in PendingIntent pendingIntent); +} \ No newline at end of file diff --git a/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/ISignInService.aidl b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/ISignInService.aidl new file mode 100644 index 0000000000..cbb5bb66e5 --- /dev/null +++ b/play-services-auth/src/main/aidl/com/google/android/gms/auth/api/identity/internal/ISignInService.aidl @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity.internal; + +import com.google.android.gms.common.api.internal.IStatusCallback; +import com.google.android.gms.auth.api.identity.internal.IBeginSignInCallback; +import com.google.android.gms.auth.api.identity.internal.IGetSignInIntentCallback; +import com.google.android.gms.auth.api.identity.internal.IGetPhoneNumberHintIntentCallback; +import com.google.android.gms.auth.api.identity.BeginSignInRequest; +import com.google.android.gms.auth.api.identity.GetSignInIntentRequest; +import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest; + +interface ISignInService { + void beginSignIn(in IBeginSignInCallback callback, in BeginSignInRequest request) = 0; + void signOut(in IStatusCallback callback, String userId) = 1; + void getSignInIntent(in IGetSignInIntentCallback callback, in GetSignInIntentRequest request) = 2; + void getPhoneNumberHintIntent(in IGetPhoneNumberHintIntentCallback callback, in GetPhoneNumberHintIntentRequest request) = 3; +} \ No newline at end of file diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInRequest.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInRequest.java new file mode 100644 index 0000000000..22d745161b --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInRequest.java @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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 BeginSignInRequest extends AbstractSafeParcelable { + @Field(1) + public PasswordRequestOptions passwordRequestOptions; + @Field(2) + public GoogleIdTokenRequestOptions googleIdTokenRequestOptions; + @Field(3) + public String score; + @Field(4) + public boolean isPrimary; + @Field(5) + public int code; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(BeginSignInRequest.class); +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInResult.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInResult.java new file mode 100644 index 0000000000..7c9b887d37 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInResult.java @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +import android.app.PendingIntent; +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 BeginSignInResult extends AbstractSafeParcelable { + @Field(1) + public PendingIntent pendingIntent; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(BeginSignInResult.class); +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.java new file mode 100644 index 0000000000..1134388646 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetPhoneNumberHintIntentRequest.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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 GetPhoneNumberHintIntentRequest extends AbstractSafeParcelable { + @Field(1) + public int code; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GetPhoneNumberHintIntentRequest.class); +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.java new file mode 100644 index 0000000000..bbb02c7844 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GetSignInIntentRequest.java @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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 GetSignInIntentRequest extends AbstractSafeParcelable { + @Field(1) + public String clientId; + @Field(2) + public String scope; + @Field(3) + public String requestTag; + @Field(4) + public String requestToken; + @Field(5) + public boolean isPrimary; + @Field(6) + public int code; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GetSignInIntentRequest.class); + +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GoogleIdTokenRequestOptions.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GoogleIdTokenRequestOptions.java new file mode 100644 index 0000000000..ffdf5c5ea8 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/GoogleIdTokenRequestOptions.java @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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; + +import java.util.ArrayList; + +@SafeParcelable.Class +public class GoogleIdTokenRequestOptions extends AbstractSafeParcelable { + @Field(1) + public boolean idTokenRequested; + @Field(2) + public String clientId; + @Field(3) + public String requestToken; + @Field(4) + public boolean serverAuthCodeRequested; + @Field(5) + public String serverClientId; + @Field(6) + public ArrayList scopes; + @Field(7) + public boolean forceCodeForRefreshToken; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(GoogleIdTokenRequestOptions.class); +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/PasswordRequestOptions.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/PasswordRequestOptions.java new file mode 100644 index 0000000000..dfca1e0652 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/PasswordRequestOptions.java @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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 PasswordRequestOptions extends AbstractSafeParcelable { + @Field(1) + public boolean primary; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(PasswordRequestOptions.class); +} diff --git a/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/SignInCredential.java b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/SignInCredential.java new file mode 100644 index 0000000000..5d4c8d38f6 --- /dev/null +++ b/play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/SignInCredential.java @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.identity; + +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 SignInCredential extends AbstractSafeParcelable { + @Field(1) + public String email; + @Field(2) + public String displayName; + @Field(3) + public String familyName; + @Field(4) + public String givenName; + @Field(5) + public String avatar; + @Field(6) + public String serverAuthCode; + @Field(7) + public String idToken; + @Field(8) + public String obfuscatedIdentifier; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + CREATOR.writeToParcel(this, dest, flags); + } + + public static final SafeParcelableCreatorAndWriter CREATOR = findCreator(SignInCredential.class); +} diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java index ec7d84d544..1ccf5ba182 100644 --- a/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java +++ b/play-services-basement/src/main/java/com/google/android/gms/common/internal/safeparcel/AbstractSafeParcelable.java @@ -21,4 +21,5 @@ public static SafeParcelableCreatorAndWriter< public int describeContents() { return 0; } + } diff --git a/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java b/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java index 2245272c27..7134310317 100644 --- a/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java +++ b/play-services-basement/src/main/java/org/microg/gms/auth/AuthConstants.java @@ -24,4 +24,12 @@ public class AuthConstants { public static final String PROVIDER_EXTRA_CLEAR_PASSWORD = "clear_password"; public static final String PROVIDER_EXTRA_ACCOUNTS = "accounts"; public static final String DEFAULT_ACCOUNT_TYPE = "com.google"; + public static final String GOOGLE_USER_ID = "GoogleUserId"; + public static final String GOOGLE_SIGN_IN_STATUS = "googleSignInStatus"; + public static final String GOOGLE_SIGN_IN_ACCOUNT = "googleSignInAccount"; + public static final String SIGN_IN_ACCOUNT = "signInAccount"; + public static final String ERROR_CODE = "errorCode"; + public static final String SIGN_IN_CREDENTIAL = "sign_in_credential"; + public static final String STATUS = "status"; + } diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 9512401b59..b1255e13a5 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -473,6 +473,12 @@ android:name="org.microg.gms.auth.signin.SignInConfigurationService" android:exported="false" /> + + + + + + - diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/identity/IdentitySignInService.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/identity/IdentitySignInService.kt new file mode 100644 index 0000000000..bf09ec5853 --- /dev/null +++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/identity/IdentitySignInService.kt @@ -0,0 +1,89 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.auth.credentials.identity + +import android.app.PendingIntent +import android.content.Context +import android.content.Intent +import android.util.Log +import com.google.android.gms.auth.api.identity.BeginSignInRequest +import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest +import com.google.android.gms.auth.api.identity.GetSignInIntentRequest +import com.google.android.gms.auth.api.identity.internal.IBeginSignInCallback +import com.google.android.gms.auth.api.identity.internal.IGetPhoneNumberHintIntentCallback +import com.google.android.gms.auth.api.identity.internal.IGetSignInIntentCallback +import com.google.android.gms.auth.api.identity.internal.ISignInService +import com.google.android.gms.auth.api.signin.GoogleSignInOptions +import com.google.android.gms.auth.api.signin.internal.SignInConfiguration +import com.google.android.gms.common.ConnectionResult +import com.google.android.gms.common.api.Status +import com.google.android.gms.common.api.internal.IStatusCallback +import com.google.android.gms.common.internal.ConnectionInfo +import com.google.android.gms.common.internal.GetServiceRequest +import com.google.android.gms.common.internal.IGmsCallbacks +import org.microg.gms.BaseService +import org.microg.gms.auth.credentials.FEATURES +import org.microg.gms.auth.signin.AuthSignInActivity +import org.microg.gms.common.Constants +import org.microg.gms.common.GmsService + +const val TAG = "IdentitySignInService" + +class IdentitySignInService : BaseService(TAG, GmsService.IDENTITY_SIGN_IN) { + + override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) { + val connectionInfo = ConnectionInfo() + connectionInfo.features = FEATURES + callback.onPostInitCompleteWithConnectionInfo( + ConnectionResult.SUCCESS, + IdentitySignInServiceImpl(this, request.packageName).asBinder(), + connectionInfo + ) + } +} + +class IdentitySignInServiceImpl(private val mContext: Context, private val clientPackageName: String) : + ISignInService.Stub() { + override fun beginSignIn(callback: IBeginSignInCallback, request: BeginSignInRequest) { + Log.d(TAG, "method 'beginSignIn' not fully implemented, return status is CANCELED") + callback.onResult(Status.CANCELED, null) + } + + override fun signOut(callback: IStatusCallback, requestTag: String) { + Log.d(TAG, "method signOut called, requestTag=$requestTag") + callback.onResult(Status.SUCCESS) + } + + override fun getSignInIntent( + callback: IGetSignInIntentCallback, + request: GetSignInIntentRequest + ) { + val signInConfiguration = SignInConfiguration().apply { + options = GoogleSignInOptions.Builder() + .requestIdToken(request.clientId) + .requestId() + .requestEmail() + .requestProfile() + .build() + packageName = clientPackageName + } + val intent = Intent(mContext, AuthSignInActivity::class.java).apply { + `package` = Constants.GMS_PACKAGE_NAME + putExtra("config", signInConfiguration) + } + val flags = PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_UPDATE_CURRENT + val activity = PendingIntent.getActivity(mContext, 0, intent, flags) + callback.onResult(Status.SUCCESS, activity) + } + + override fun getPhoneNumberHintIntent( + callback: IGetPhoneNumberHintIntentCallback, + request: GetPhoneNumberHintIntentRequest + ) { + Log.w(TAG, "method 'getPhoneNumberHintIntent' not fully implemented, return status is CANCELED.") + callback.onResult(Status.CANCELED, null) + } +} \ No newline at end of file diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInActivity.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInActivity.kt index b08a580709..c01034dff6 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInActivity.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInActivity.kt @@ -20,16 +20,19 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.getSystemService import androidx.lifecycle.lifecycleScope import com.google.android.gms.R +import com.google.android.gms.auth.api.identity.SignInCredential import com.google.android.gms.auth.api.signin.GoogleSignInAccount import com.google.android.gms.auth.api.signin.SignInAccount import com.google.android.gms.auth.api.signin.internal.SignInConfiguration import com.google.android.gms.common.Scopes import com.google.android.gms.common.api.CommonStatusCodes import com.google.android.gms.common.api.Status +import com.google.android.gms.common.internal.safeparcel.SafeParcelableSerializer import com.google.android.gms.databinding.SigninConfirmBinding import com.google.android.gms.databinding.SigninPickerBinding import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.microg.gms.auth.AuthConstants import org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT import org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE import org.microg.gms.auth.login.LoginActivity @@ -110,10 +113,11 @@ class AuthSignInActivity : AppCompatActivity() { val photo = PeopleManager.getOwnerAvatarBitmap(this@AuthSignInActivity, account.name, false) if (photo == null) { lifecycleScope.launchWhenStarted { - val bitmap = withContext(Dispatchers.IO) { + withContext(Dispatchers.IO) { PeopleManager.getOwnerAvatarBitmap(this@AuthSignInActivity, account.name, true) + }?.let { + updateAction(photoView, it) } - updateAction(photoView, bitmap) } } val displayName = getDisplayName(account) @@ -197,18 +201,36 @@ class AuthSignInActivity : AppCompatActivity() { private fun finishResult(statusCode: Int, message: String? = null, account: Account? = null, googleSignInAccount: GoogleSignInAccount? = null) { val data = Intent() - if (statusCode != CommonStatusCodes.SUCCESS) data.putExtra("errorCode", statusCode) - data.putExtra("googleSignInStatus", Status(statusCode, message)) - data.putExtra("googleSignInAccount", googleSignInAccount) + if (statusCode != CommonStatusCodes.SUCCESS) data.putExtra(AuthConstants.ERROR_CODE, statusCode) + data.putExtra(AuthConstants.GOOGLE_SIGN_IN_STATUS, Status(statusCode, message)) + data.putExtra(AuthConstants.GOOGLE_SIGN_IN_ACCOUNT, googleSignInAccount) + val bundle = Bundle() if (googleSignInAccount != null) { - data.putExtra("signInAccount", SignInAccount().apply { + val signInAccount = SignInAccount().apply { email = googleSignInAccount.email ?: account?.name this.googleSignInAccount = googleSignInAccount - userId = googleSignInAccount.id ?: getSystemService()?.getUserData(account, "GoogleUserId") - }) + userId = googleSignInAccount.id ?: getSystemService()?.getUserData( + account, + AuthConstants.GOOGLE_USER_ID + ) + } + data.putExtra(AuthConstants.SIGN_IN_ACCOUNT, signInAccount) + val credential = SignInCredential().apply { + email = googleSignInAccount.email + displayName = googleSignInAccount.displayName + familyName = googleSignInAccount.familyName + givenName = googleSignInAccount.givenName + idToken = googleSignInAccount.idToken + } + val credentialToBytes = SafeParcelableSerializer.serializeToBytes(credential) + bundle.putByteArray(AuthConstants.SIGN_IN_CREDENTIAL, credentialToBytes) + bundle.putByteArray(AuthConstants.STATUS, SafeParcelableSerializer.serializeToBytes(Status.SUCCESS)) + } else { + bundle.putByteArray(AuthConstants.STATUS, SafeParcelableSerializer.serializeToBytes(Status.CANCELED)) } + data.putExtras(bundle) Log.d(TAG, "Result: ${data.extras?.also { it.keySet() }}") - setResult(statusCode, data) + setResult(RESULT_OK, data) finish() }