Skip to content

Commit

Permalink
take relevant advice, changed some one
Browse files Browse the repository at this point in the history
  • Loading branch information
DaVinci9196 committed Dec 25, 2023
1 parent 4364ed0 commit 0562150
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

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

import android.os.Parcel;

public abstract class AbstractSafeParcelable implements SafeParcelable {

@SuppressWarnings("unchecked")
Expand All @@ -24,12 +22,4 @@ public int describeContents() {
return 0;
}

public byte[] toByteArray() {
Parcel parcel = Parcel.obtain();
writeToParcel(parcel, 0);
byte[] arr_b = parcel.marshall();
parcel.recycle();
return arr_b;
}

}
2 changes: 1 addition & 1 deletion play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
android:name="org.microg.gms.auth.signin.SignInConfigurationService"
android:exported="false" />

<service android:name="org.microg.gms.auth.credentials.assistedsignin.AssistedSignInService">
<service android:name="org.microg.gms.auth.credentials.identity.IdentitySignInService">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.identity.service.signin.START" />
</intent-filter>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.microg.gms.auth.credentials.assistedsignin
package org.microg.gms.auth.credentials.identity

import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.RemoteException
import android.util.Log
import com.google.android.gms.auth.api.identity.BeginSignInRequest
import com.google.android.gms.auth.api.identity.GetPhoneNumberHintIntentRequest
Expand All @@ -19,12 +18,34 @@ import com.google.android.gms.auth.api.identity.internal.IGetSignInIntentCallbac
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

class AssistedSignInServiceImpl(private val mContext: Context, private val clientPackageName: String) :
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")
Expand Down Expand Up @@ -65,5 +86,4 @@ class AssistedSignInServiceImpl(private val mContext: Context, private val clien
Log.w(TAG, "method 'getPhoneNumberHintIntent' not fully implemented, return status is CANCELED.")
callback.onResult(Status.CANCELED, null)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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
Expand Down Expand Up @@ -205,28 +206,27 @@ class AuthSignInActivity : AppCompatActivity() {
data.putExtra(AuthConstants.GOOGLE_SIGN_IN_ACCOUNT, googleSignInAccount)
val bundle = Bundle()
if (googleSignInAccount != null) {
SignInAccount().apply {
val signInAccount = SignInAccount().apply {
email = googleSignInAccount.email ?: account?.name
this.googleSignInAccount = googleSignInAccount
userId = googleSignInAccount.id ?: getSystemService<AccountManager>()?.getUserData(
account,
AuthConstants.GOOGLE_USER_ID
)
}.let {
data.putExtra(AuthConstants.SIGN_IN_ACCOUNT, it)
}
SignInCredential().apply {
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
}.let {
bundle.putByteArray(AuthConstants.SIGN_IN_CREDENTIAL, it.toByteArray())
bundle.putByteArray(AuthConstants.STATUS, Status.SUCCESS.toByteArray())
}
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, Status.CANCELED.toByteArray())
bundle.putByteArray(AuthConstants.STATUS, SafeParcelableSerializer.serializeToBytes(Status.CANCELED))
}
data.putExtras(bundle)
Log.d(TAG, "Result: ${data.extras?.also { it.keySet() }}")
Expand Down

0 comments on commit 0562150

Please sign in to comment.