Skip to content

Commit 94a488b

Browse files
committed
Credential Manager
1 parent 587d693 commit 94a488b

44 files changed

Lines changed: 1572 additions & 101 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ buildscript {
1414
ext.appcompatVersion = '1.6.1'
1515
ext.biometricVersion = '1.1.0'
1616
ext.coreVersion = '1.12.0'
17+
ext.credentialsVersion = '1.2.0'
1718
ext.fragmentVersion = '1.6.2'
1819
ext.lifecycleVersion = '2.7.0'
1920
ext.loaderVersion = '1.1.0'
@@ -123,4 +124,3 @@ subprojects {
123124
if (hasModule("hms", false)) maven {url 'https://developer.huawei.com/repo/'}
124125
}
125126
}
126-

‎play-services-auth-api/src/main/java/com/google/android/gms/auth/api/identity/package-info.java‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎play-services-auth/src/main/java/com/google/android/gms/auth/api/identity/BeginSignInRequest.java‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,132 @@ public boolean isPreferImmediatelyAvailableCredentials() {
115115
return preferImmediatelyAvailableCredentials;
116116
}
117117

118+
/**
119+
* Builder for {@link BeginSignInRequest}.
120+
*/
118121
public static class Builder {
122+
private PasswordRequestOptions passwordRequestOptions;
123+
private GoogleIdTokenRequestOptions googleIdTokenRequestOptions;
124+
private String sessionId;
125+
private boolean autoSelectEnabled;
126+
private int theme;
127+
private PasskeysRequestOptions passkeysRequestOptions;
128+
private PasskeyJsonRequestOptions passkeyJsonRequestOptions;
129+
private boolean preferImmediatelyAvailableCredentials;
130+
131+
/**
132+
* Returns the built {@link BeginSignInRequest}.
133+
*/
134+
@NonNull
135+
public BeginSignInRequest build() {
136+
return new BeginSignInRequest(
137+
passwordRequestOptions,
138+
googleIdTokenRequestOptions,
139+
sessionId,
140+
autoSelectEnabled,
141+
theme,
142+
passkeysRequestOptions,
143+
passkeyJsonRequestOptions,
144+
preferImmediatelyAvailableCredentials
145+
);
146+
}
119147

148+
/**
149+
* Sets whether to enable auto-select for the credential.
150+
* <p>
151+
* If enabled and only one credential is available, it will be automatically selected.
152+
*
153+
* @param autoSelectEnabled whether to enable auto-select
154+
*/
155+
@NonNull
156+
public Builder setAutoSelectEnabled(boolean autoSelectEnabled) {
157+
this.autoSelectEnabled = autoSelectEnabled;
158+
return this;
159+
}
160+
161+
/**
162+
* Sets options for requesting Google ID token-backed credentials.
163+
*
164+
* @param googleIdTokenRequestOptions the Google ID token request options
165+
*/
166+
@NonNull
167+
public Builder setGoogleIdTokenRequestOptions(@Nullable GoogleIdTokenRequestOptions googleIdTokenRequestOptions) {
168+
this.googleIdTokenRequestOptions = googleIdTokenRequestOptions;
169+
return this;
170+
}
171+
172+
/**
173+
* Sets options for requesting passkey credentials using JSON format.
174+
*
175+
* @param passkeyJsonRequestOptions the passkey JSON request options
176+
*/
177+
@NonNull
178+
public Builder setPasskeyJsonRequestOptions(@Nullable PasskeyJsonRequestOptions passkeyJsonRequestOptions) {
179+
this.passkeyJsonRequestOptions = passkeyJsonRequestOptions;
180+
return this;
181+
}
182+
183+
/**
184+
* Sets options for requesting passkey credentials.
185+
*
186+
* @param passkeysRequestOptions the passkey request options
187+
* @deprecated Use {@link #setPasskeyJsonRequestOptions(PasskeyJsonRequestOptions)} instead
188+
*/
189+
@Deprecated
190+
@NonNull
191+
public Builder setPasskeysRequestOptions(@Nullable PasskeysRequestOptions passkeysRequestOptions) {
192+
this.passkeysRequestOptions = passkeysRequestOptions;
193+
return this;
194+
}
195+
196+
/**
197+
* Sets options for requesting password-backed credentials.
198+
*
199+
* @param passwordRequestOptions the password request options
200+
*/
201+
@NonNull
202+
public Builder setPasswordRequestOptions(@Nullable PasswordRequestOptions passwordRequestOptions) {
203+
this.passwordRequestOptions = passwordRequestOptions;
204+
return this;
205+
}
206+
207+
/**
208+
* Sets whether to prefer immediately available credentials.
209+
* <p>
210+
* If true, the API will only return credentials that are immediately available
211+
* without requiring user interaction.
212+
*
213+
* @param preferImmediatelyAvailableCredentials whether to prefer immediately available credentials
214+
*/
215+
@NonNull
216+
public Builder setPreferImmediatelyAvailableCredentials(boolean preferImmediatelyAvailableCredentials) {
217+
this.preferImmediatelyAvailableCredentials = preferImmediatelyAvailableCredentials;
218+
return this;
219+
}
220+
221+
/**
222+
* Sets the session ID for this sign-in request.
223+
*
224+
* @param sessionId the session ID
225+
*/
226+
@Hide
227+
@NonNull
228+
public Builder setSessionId(@Nullable String sessionId) {
229+
this.sessionId = sessionId;
230+
return this;
231+
}
232+
233+
/**
234+
* Sets the theme for the sign-in UI.
235+
*
236+
* @param theme the theme resource ID
237+
*/
238+
@Hide
239+
@NonNull
240+
public Builder setTheme(int theme) {
241+
this.theme = theme;
242+
return this;
243+
}
120244
}
121245

122246
/**

‎play-services-core/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ dependencies {
103103
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
104104
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
105105

106+
implementation "androidx.credentials:credentials:$credentialsVersion"
106107
implementation "androidx.work:work-runtime-ktx:$workVersion"
107108
}
108109

‎play-services-core/src/main/AndroidManifest.xml‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
148148
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
149149
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
150+
<uses-permission android:name="android.permission.PROVIDE_REMOTE_CREDENTIALS" />
151+
<uses-permission android:name="android.permission.PROVIDE_DEFAULT_ENABLED_CREDENTIAL_SERVICE"/>
150152
<uses-permission android:name="android.permission.WAKE_LOCK" />
151153
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
152154
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
@@ -185,6 +187,7 @@
185187
tools:overrideLibrary="androidx.compose.ui.tooling,
186188
androidx.compose.material3,
187189
androidx.activity.compose,
190+
androidx.credentials,
188191
androidx.compose.material.icons,
189192
androidx.compose.material.ripple,
190193
androidx.compose.foundation,
@@ -674,6 +677,70 @@
674677
android:exported="true"
675678
android:theme="@style/Theme.LoginBlue"/>
676679

680+
<!-- Credential Provider Services -->
681+
<service
682+
android:name="com.google.android.gms.auth.api.credentials.credman.service.PasswordAndPasskeyService"
683+
android:exported="true"
684+
android:permission="android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
685+
tools:targetApi="34">
686+
<intent-filter>
687+
<action android:name="android.service.credentials.CredentialProviderService"/>
688+
</intent-filter>
689+
<meta-data
690+
android:name="android.credentials.provider"
691+
android:resource="@xml/credentials_provider_passkey" />
692+
</service>
693+
694+
<service
695+
android:name="com.google.android.gms.auth.api.credentials.credman.service.RemoteService"
696+
android:exported="true"
697+
android:permission="android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
698+
tools:targetApi="34">
699+
<intent-filter>
700+
<action android:name="android.service.credentials.system.CredentialProviderService"/>
701+
</intent-filter>
702+
<meta-data
703+
android:name="android.credentials.provider"
704+
android:resource="@xml/credentials_provider_remote" />
705+
</service>
706+
707+
<service
708+
android:name="com.google.android.gms.auth.api.credentials.credman.service.GoogleIdService"
709+
android:exported="true"
710+
android:icon="@drawable/ic_google_logo"
711+
android:label="@string/credentials_service_sign_in_with_google_label"
712+
android:permission="android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
713+
tools:targetApi="34">
714+
<intent-filter>
715+
<action android:name="android.service.credentials.system.CredentialProviderService"/>
716+
</intent-filter>
717+
<meta-data
718+
android:name="android.credentials.provider"
719+
android:resource="@xml/credentials_provider_google_id" />
720+
</service>
721+
722+
723+
<activity
724+
android:name="org.microg.gms.auth.credentials.provider.PublicKeyProxyActivity"
725+
android:exported="false"
726+
android:process=":ui"
727+
android:theme="@style/Theme.App.Translucent"
728+
android:excludeFromRecents="true"
729+
tools:targetApi="34" />
730+
731+
<activity
732+
android:name="org.microg.gms.auth.credentials.provider.SignInProxyActivity"
733+
android:exported="false"
734+
android:process=":ui"
735+
android:theme="@style/Theme.App.Translucent"
736+
android:excludeFromRecents="true"
737+
tools:targetApi="34">
738+
<intent-filter>
739+
<action android:name="org.microg.gms.auth.credentials.GOOGLE_ID_PROXY_INTENT"/>
740+
<category android:name="android.intent.category.DEFAULT"/>
741+
</intent-filter>
742+
</activity>
743+
677744
<!-- Games -->
678745

679746
<activity
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 microG Project Team
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package com.google.android.gms.auth.api.credentials.credman.service
7+
8+
import org.microg.gms.auth.credentials.provider.GoogleIdService
9+
10+
class GoogleIdService : GoogleIdService()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 microG Project Team
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package com.google.android.gms.auth.api.credentials.credman.service
7+
8+
import org.microg.gms.auth.credentials.provider.PasswordAndPasskeyService
9+
10+
class PasswordAndPasskeyService : PasswordAndPasskeyService()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 microG Project Team
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package com.google.android.gms.auth.api.credentials.credman.service
7+
8+
import org.microg.gms.auth.credentials.provider.RemoteService
9+
10+
class RemoteService : RemoteService()

‎play-services-core/src/main/kotlin/org/microg/gms/auth/credentials/identity/IdentityFidoProxyActivity.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ import com.google.android.gms.fido.Fido.FIDO2_KEY_CREDENTIAL_EXTRA
1616
import com.google.android.gms.fido.fido2.api.common.AuthenticatorErrorResponse
1717
import com.google.android.gms.fido.fido2.api.common.PublicKeyCredential
1818
import org.microg.gms.auth.AuthConstants
19+
import org.microg.gms.fido.core.ui.ACTION_FIDO_AUTHENTICATE
1920
import org.microg.gms.fido.core.ui.AuthenticatorActivity.Companion.KEY_CALLER
2021

2122
private const val REQUEST_CODE = 1586077619
2223

2324
class IdentityFidoProxyActivity : AppCompatActivity() {
2425
override fun onCreate(savedInstanceState: Bundle?) {
2526
super.onCreate(savedInstanceState)
26-
startActivityForResult(Intent("org.microg.gms.fido.AUTHENTICATE").apply {
27+
startActivityForResult(Intent(ACTION_FIDO_AUTHENTICATE).apply {
2728
`package` = packageName
2829
putExtras(intent.extras ?: Bundle())
2930
putExtra(KEY_CALLER, callingActivity?.packageName)

0 commit comments

Comments
 (0)