Update to latest upstream

This commit is contained in:
Oizaro 2021-04-15 23:35:47 +02:00
parent d01b6cd40e
commit 540bbb94f6
11 changed files with 289 additions and 19 deletions

View File

@ -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

View File

@ -16,21 +16,23 @@
package com.google.android.gms.auth.api.credentials;
import org.microg.gms.common.PublicApi;
import org.microg.safeparcel.AutoSafeParcelable;
import org.microg.safeparcel.SafeParceled;
@PublicApi
public class CredentialPickerConfig extends AutoSafeParcelable {
@SafeParceled(1000)
@Field(1000)
private int versionCode = 1;
@SafeParceled(1)
@Field(1)
private boolean showAddAccountButton;
@SafeParceled(2)
@Field(2)
private boolean showCancelButton;
@SafeParceled(3)
@Field(3)
private boolean forNewAccount;
private CredentialPickerConfig() {
@ -42,6 +44,10 @@ public class CredentialPickerConfig extends AutoSafeParcelable {
this.forNewAccount = forNewAccount;
}
/**
* @deprecated It was determined that this method was not useful for developers.
*/
@Deprecated
public boolean isForNewAccount() {
return forNewAccount;
}
@ -54,6 +60,14 @@ public class CredentialPickerConfig extends AutoSafeParcelable {
return showCancelButton;
}
@Override
public String toString() {
return "CredentialPickerConfig{" +
"showAddAccountButton=" + showAddAccountButton +
", showCancelButton=" + showCancelButton +
'}';
}
public static class Builder {
private boolean showAddAccountButton;
private boolean showCancelButton;

View File

@ -25,19 +25,19 @@ import org.microg.safeparcel.SafeParceled;
*/
public class CredentialRequest extends AutoSafeParcelable {
@SafeParceled(1000)
@Field(1000)
private int versionCode = 1;
@SafeParceled(1)
@Field(1)
private boolean passwordLoginSupported;
@SafeParceled(2)
@Field(2)
private String[] accountTypes;
@SafeParceled(3)
@Field(3)
private CredentialPickerConfig credentialPickerConfig;
@SafeParceled(4)
@Field(4)
private CredentialPickerConfig credentialHintPickerConfig;
public CredentialRequest(boolean passwordLoginSupported, String[] accountTypes, CredentialPickerConfig credentialPickerConfig, CredentialPickerConfig credentialHintPickerConfig) {
@ -72,4 +72,15 @@ public class CredentialRequest extends AutoSafeParcelable {
}
public static final Creator<CredentialRequest> CREATOR = new AutoCreator<>(CredentialRequest.class);
public static class Builder {
private boolean passwordLoginSupported;
private String[] accountTypes;
private CredentialPickerConfig credentialPickerConfig;
private CredentialPickerConfig credentialHintPickerConfig;
public void setAccountTypes(String... accountTypes) {
this.accountTypes = accountTypes.clone();
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -39,6 +39,6 @@ dependencies {
api project(':play-services-tasks')
api project(':play-services-base-api')
implementation "androidx.fragment:fragment:1.3.1"
implementation 'androidx.fragment:fragment:1.3.2'
implementation 'com.google.android.gms:play-services-base:17.6.0'
}

View File

@ -20,7 +20,7 @@ apply plugin: 'kotlin-android'
dependencies {
api "org.microg:safe-parcel:1.7.0"
implementation "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.annotation:annotation:1.2.0"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.31'
}

View File

@ -37,14 +37,14 @@ dependencies {
implementation "androidx.preference:preference-ktx:$preferenceVersion"
implementation "org.microg.gms:conscrypt-gmscore:2.5.1"
implementation "androidx.annotation:annotation:$annotationVersion"
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
implementation "androidx.annotation:annotation:1.2.0"
implementation "androidx.lifecycle:lifecycle-service:2.3.1"
// Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-service:2.3.1"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.31'
api project(':play-services-basement')

View File

@ -271,6 +271,15 @@
android:authorities="com.mgoogle.android.gms.auth.accounts"
android:exported="true" />
<activity
android:name="org.microg.gms.ui.CredentialPickerActivity"
android:process=":ui">
<intent-filter>
<action android:name="com.google.android.gms.auth.api.credentials.PICKER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Cast -->
<service android:name="com.google.android.gms.cast.media.CastMediaRouteProviderService">

View File

@ -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()
}
}

View File

@ -36,5 +36,5 @@ dependencies {
api project(':play-services-base')
api project(':play-services-location-api')
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.annotation:annotation:1.2.0'
}