This repository has been archived by the owner on Apr 6, 2024. It is now read-only.
forked from microg/GmsCore
-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from Oizaro/master
Update to latest upstream
- Loading branch information
Showing
11 changed files
with
289 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sat Mar 13 21:39:25 CET 2021 | ||
#Thu Apr 15 23:13:18 CEST 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/HintRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021, microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.auth.api.credentials; | ||
|
||
import org.microg.gms.common.PublicApi; | ||
import org.microg.safeparcel.AutoSafeParcelable; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Parameters for requesting the display of the hint picker, via {@link CredentalsApi#getHintPickerIntent()}. | ||
* Instances can be created using {@link HintRequest.Builder}. | ||
*/ | ||
@PublicApi | ||
public class HintRequest extends AutoSafeParcelable { | ||
@Field(1000) | ||
private int versionCode = 2; | ||
|
||
@Field(1) | ||
private CredentialPickerConfig hintPickerConfig; | ||
@Field(2) | ||
private boolean emailAddressIdentifierSupported; | ||
@Field(3) | ||
private boolean phoneNumberIdentifierSupported; | ||
@Field(4) | ||
private String[] accountTypes; | ||
@Field(5) | ||
private boolean idTokenRequested = true; | ||
@Field(6) | ||
private String serverClientId; | ||
@Field(7) | ||
private String idTokenNonce; | ||
|
||
private HintRequest() { | ||
} | ||
|
||
public HintRequest(CredentialPickerConfig hintPickerConfig, boolean emailAddressIdentifierSupported, boolean phoneNumberIdentifierSupported, String[] accountTypes, boolean idTokenRequested, String serverClientId, String idTokenNonce) { | ||
this.hintPickerConfig = hintPickerConfig; | ||
this.emailAddressIdentifierSupported = emailAddressIdentifierSupported; | ||
this.phoneNumberIdentifierSupported = phoneNumberIdentifierSupported; | ||
this.accountTypes = accountTypes; | ||
this.idTokenRequested = idTokenRequested; | ||
this.serverClientId = serverClientId; | ||
this.idTokenNonce = idTokenNonce; | ||
} | ||
|
||
public String[] getAccountTypes() { | ||
return accountTypes; | ||
} | ||
|
||
public CredentialPickerConfig getHintPickerConfig() { | ||
return hintPickerConfig; | ||
} | ||
|
||
public String getIdTokenNonce() { | ||
return idTokenNonce; | ||
} | ||
|
||
public String getServerClientId() { | ||
return serverClientId; | ||
} | ||
|
||
public boolean isEmailAddressIdentifierSupported() { | ||
return emailAddressIdentifierSupported; | ||
} | ||
|
||
public boolean isPhoneNumberIdentifierSupported() { | ||
return phoneNumberIdentifierSupported; | ||
} | ||
|
||
public boolean isIdTokenRequested() { | ||
return idTokenRequested; | ||
} | ||
|
||
public static final Creator<HintRequest> CREATOR = new AutoCreator<>(HintRequest.class); | ||
|
||
@Override | ||
public String toString() { | ||
return "HintRequest{" + | ||
"hintPickerConfig=" + hintPickerConfig + | ||
", emailAddressIdentifierSupported=" + emailAddressIdentifierSupported + | ||
", phoneNumberIdentifierSupported=" + phoneNumberIdentifierSupported + | ||
", accountTypes=" + Arrays.toString(accountTypes) + | ||
", idTokenRequested=" + idTokenRequested + | ||
", serverClientId='" + serverClientId + '\'' + | ||
", idTokenNonce='" + idTokenNonce + '\'' + | ||
'}'; | ||
} | ||
|
||
public static class Builder { | ||
private CredentialPickerConfig hintPickerConfig; | ||
private boolean emailAddressIdentifierSupported; | ||
private boolean phoneNumberIdentifierSupported; | ||
private String[] accountTypes; | ||
private boolean idTokenRequested = true; | ||
private String serverClientId; | ||
private String idTokenNonce; | ||
|
||
/** | ||
* Builds a {@link HintRequest}. | ||
*/ | ||
public HintRequest build() { | ||
return new HintRequest(hintPickerConfig, emailAddressIdentifierSupported, phoneNumberIdentifierSupported, accountTypes, idTokenRequested, serverClientId, idTokenNonce); | ||
} | ||
|
||
/** | ||
* Sets the account types (identity providers) that are accepted by this application. | ||
* It is strongly recommended that the strings listed in {@link IdentityProviders} be used for the most common | ||
* identity providers, and strings representing the login domain of the identity provider be used for any | ||
* others which are not listed. | ||
* | ||
* @param accountTypes The list of account types (identity providers) supported by the app. | ||
* typically in the form of the associated login domain for each identity provider. | ||
*/ | ||
public void setAccountTypes(String... accountTypes) { | ||
this.accountTypes = accountTypes.clone(); | ||
} | ||
|
||
/** | ||
* Enables returning {@link Credential} hints where the identifier is an email address, intended for use with a password chosen by the user. | ||
*/ | ||
public void setEmailAddressIdentifierSupported(boolean emailAddressIdentifierSupported) { | ||
this.emailAddressIdentifierSupported = emailAddressIdentifierSupported; | ||
} | ||
|
||
/** | ||
* Sets the configuration for the hint picker dialog. | ||
*/ | ||
public void setHintPickerConfig(CredentialPickerConfig hintPickerConfig) { | ||
this.hintPickerConfig = hintPickerConfig; | ||
} | ||
|
||
/** | ||
* Specify a nonce value that should be included in any generated ID token for this request. | ||
*/ | ||
public void setIdTokenNonce(String idTokenNonce) { | ||
this.idTokenNonce = idTokenNonce; | ||
} | ||
|
||
/** | ||
* Specify whether an ID token should be acquired for hints, if available for the selected credential identifier. | ||
* This is enabled by default; disable this if your app does not use ID tokens as part of authentication to decrease latency in retrieving credentials and credential hints. | ||
*/ | ||
public void setIdTokenRequested(boolean idTokenRequested) { | ||
this.idTokenRequested = idTokenRequested; | ||
} | ||
|
||
/** | ||
* Enables returning {@link Credential} hints where the identifier is a phone number, intended for use with a password chosen by the user or SMS verification. | ||
*/ | ||
public void setPhoneNumberIdentifierSupported(boolean phoneNumberIdentifierSupported) { | ||
this.phoneNumberIdentifierSupported = phoneNumberIdentifierSupported; | ||
} | ||
|
||
/** | ||
* Specify the server client ID for the backend associated with this app. | ||
* If a Google ID token can be generated for a retrieved credential or hint, and the specified server client ID is correctly configured to be associated with the app, then it will be used as the audience of the generated token. | ||
* If a null value is specified, the default audience will be used for the generated ID token. | ||
*/ | ||
public void setServerClientId(String serverClientId) { | ||
this.serverClientId = serverClientId; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ices-api/src/main/java/com/google/android/gms/auth/api/credentials/IdentityProviders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021, microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.auth.api.credentials; | ||
|
||
import android.accounts.Account; | ||
|
||
/** | ||
* Identity provider constants for use with {@link CredentialRequest.Builder#setAccountTypes(String...)} | ||
*/ | ||
public final class IdentityProviders { | ||
public static final String FACEBOOK = "//www.facebook.com"; | ||
public static final String GOOGLE = "//accounts.google.com"; | ||
public static final String LINKEDIN = "//www.linkedin.com"; | ||
public static final String MICROSOFT = "//login.live.com"; | ||
public static final String PAYPAL = "//www.paypal.com"; | ||
public static final String TWITTER = "//twitter.com"; | ||
public static final String YAHOO = "//login.yahoo.com"; | ||
|
||
/** | ||
* Attempts to translate the account type in the provided account into the string that should be used in the credentials API. | ||
* | ||
* @param account an account on the device. | ||
* @return The identity provider string for use with the Credentials API, or {@code null} if the account type is unknown. | ||
*/ | ||
public static String getIdentityProviderForAccount(Account account) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
play-services-core/src/main/kotlin/org/microg/gms/ui/CredentialPickerActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021, microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.microg.gms.ui | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import android.util.Log | ||
import com.google.android.gms.auth.api.credentials.CredentialRequest | ||
import com.google.android.gms.auth.api.credentials.HintRequest | ||
|
||
fun <T> Parcelable.Creator<T>.createFromBytes(bytes: ByteArray): T { | ||
val parcel = Parcel.obtain() | ||
parcel.unmarshall(bytes, 0, bytes.size) | ||
parcel.setDataPosition(0) | ||
try { | ||
return createFromParcel(parcel) | ||
} finally { | ||
parcel.recycle() | ||
} | ||
} | ||
|
||
class CredentialPickerActivity : Activity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val extras = intent.extras ?: Bundle() | ||
val callingPackage = callingActivity?.packageName?.takeIf { extras.getString("claimedCallingPackage", it) == it } | ||
val logSessionId = extras.getString("logSessionId") | ||
val credentialRequest = extras.getByteArray("credentialRequest")?.let { CredentialRequest.CREATOR.createFromBytes(it) } | ||
val hintRequest = extras.getByteArray("com.google.android.gms.credentials.HintRequest")?.let { HintRequest.CREATOR.createFromBytes(it) } | ||
Log.d("GmsCredentialPicker", "Not implemented. callingPackage=$callingPackage, logSessionId=$logSessionId, credentialsRequest=$credentialRequest, hintRequest=$hintRequest") | ||
finish() | ||
} | ||
} |
Oops, something went wrong.