Skip to content

Commit 74bca4d

Browse files
authored
Merge branch 'main' into nav-cujs
2 parents faeb761 + 6f36723 commit 74bca4d

26 files changed

+2209
-3
lines changed

.github/workflows/apply_spotless.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
- name: Run spotlessApply for Misc
5151
run: ./gradlew :misc:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
5252

53+
- name: Run spotlessApply for XR
54+
run: ./gradlew :xr:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
55+
5356
- name: Auto-commit if spotlessApply has changes
5457
uses: stefanzweifel/git-auto-commit-action@v5
5558
with:

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ jobs:
4747
run: ./gradlew :wear:build
4848
- name: Build misc snippets
4949
run: ./gradlew :misc:build
50+
- name: Build XR snippets
51+
run: ./gradlew :xr:build

gradle/libs.versions.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ androidx-paging = "3.3.6"
2121
androidx-startup-runtime = "1.2.0"
2222
androidx-test = "1.6.1"
2323
androidx-test-espresso = "3.6.1"
24+
androidx-test-junit = "1.2.1"
2425
androidx-window = "1.4.0-rc01"
2526
androidx-window-core = "1.4.0-beta02"
2627
androidx-window-java = "1.3.0"
@@ -42,6 +43,8 @@ hilt = "2.55"
4243
horologist = "0.6.22"
4344
junit = "4.13.2"
4445
kotlin = "2.1.10"
46+
kotlinxCoroutinesGuava = "1.9.0"
47+
kotlinCoroutinesOkhttp = "1.0"
4548
kotlinxSerializationJson = "1.8.0"
4649
ksp = "2.1.10-1.0.30"
4750
maps-compose = "6.4.4"
@@ -55,13 +58,17 @@ playServicesWearable = "19.0.0"
5558
protolayout = "1.2.1"
5659
recyclerview = "1.4.0"
5760
# @keep
61+
androidx-xr = "1.0.0-alpha02"
5862
targetSdk = "34"
5963
tiles = "1.4.1"
6064
version-catalog-update = "0.8.5"
6165
wear = "1.3.0"
6266
wearComposeFoundation = "1.4.1"
6367
wearComposeMaterial = "1.4.1"
6468
wearToolingPreview = "1.0.0"
69+
activityKtx = "1.10.0"
70+
okHttp = "4.12.0"
71+
webkit = "1.13.0"
6572

6673
[libraries]
6774
accompanist-adaptive = { module = "com.google.accompanist:accompanist-adaptive", version.ref = "accompanist" }
@@ -125,6 +132,7 @@ androidx-startup-runtime = {module = "androidx.startup:startup-runtime", version
125132
androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" }
126133
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidx-test-espresso" }
127134
androidx-test-runner = "androidx.test:runner:1.6.2"
135+
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-test-junit" }
128136
androidx-tiles = { module = "androidx.wear.tiles:tiles", version.ref = "tiles" }
129137
androidx-tiles-renderer = { module = "androidx.wear.tiles:tiles-renderer", version.ref = "tiles" }
130138
androidx-tiles-testing = { module = "androidx.wear.tiles:tiles-testing", version.ref = "tiles" }
@@ -136,6 +144,9 @@ androidx-window = { module = "androidx.window:window", version.ref = "androidx-w
136144
androidx-window-core = { module = "androidx.window:window-core", version.ref = "androidx-window-core" }
137145
androidx-window-java = {module = "androidx.window:window-java", version.ref = "androidx-window-java" }
138146
androidx-work-runtime-ktx = "androidx.work:work-runtime-ktx:2.10.0"
147+
androidx-xr-arcore = { module = "androidx.xr.arcore:arcore", version.ref = "androidx-xr" }
148+
androidx-xr-compose = { module = "androidx.xr.compose:compose", version.ref = "androidx-xr" }
149+
androidx-xr-scenecore = { module = "androidx.xr.scenecore:scenecore", version.ref = "androidx-xr" }
139150
android-identity-googleid = {module = "com.google.android.libraries.identity.googleid:googleid", version.ref = "android-googleid"}
140151
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
141152
coil-kt-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
@@ -152,11 +163,16 @@ hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.re
152163
horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" }
153164
horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "horologist" }
154165
junit = { module = "junit:junit", version.ref = "junit" }
166+
kotlin-coroutines-okhttp = { module = "ru.gildor.coroutines:kotlin-coroutines-okhttp", version.ref = "kotlinCoroutinesOkhttp" }
155167
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
156168
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
169+
kotlinx-coroutines-guava = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-guava", version.ref = "kotlinxCoroutinesGuava" }
157170
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
158171
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
159172
play-services-wearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearable" }
173+
androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activityKtx" }
174+
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okHttp" }
175+
androidx-webkit = { group = "androidx.webkit", name = "webkit", version.ref = "webkit" }
160176

161177
[plugins]
162178
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }

identity/credentialmanager/build.gradle.kts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
alias(libs.plugins.android.application)
3+
// [START android_identity_fido2_migration_dependency]
34
alias(libs.plugins.kotlin.android)
5+
// [END android_identity_fido2_migration_dependency]
46
alias(libs.plugins.compose.compiler)
57
}
68

@@ -48,6 +50,11 @@ dependencies {
4850
implementation(libs.androidx.compose.ui.graphics)
4951
implementation(libs.androidx.compose.ui.tooling.preview)
5052
implementation(libs.androidx.compose.material3)
53+
54+
// [START android_identity_credman_dependency]
55+
implementation(libs.androidx.credentials)
56+
// [END android_identity_credman_dependency]
57+
5158
// [START android_identity_gradle_dependencies]
5259
implementation(libs.androidx.credentials)
5360

@@ -60,6 +67,9 @@ dependencies {
6067
implementation(libs.androidx.credentials.play.services.auth)
6168
implementation(libs.android.identity.googleid)
6269
// [END android_identity_siwg_gradle_dependencies]
70+
implementation(libs.okhttp)
71+
implementation(libs.kotlin.coroutines.okhttp)
72+
implementation(libs.androidx.webkit)
6373
debugImplementation(libs.androidx.compose.ui.tooling)
6474
debugImplementation(libs.androidx.compose.ui.test.manifest)
65-
}
75+
}

identity/credentialmanager/src/main/AndroidManifest.xml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
~ limitations under the License.
1616
-->
1717

18-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
<manifest xmlns:tools="http://schemas.android.com/tools"
19+
xmlns:android="http://schemas.android.com/apk/res/android">
1920

2021
<application
2122
android:allowBackup="true"
@@ -38,6 +39,24 @@
3839
<!-- // [START android_identity_assetlinks_manifest] -->
3940
<meta-data android:name="asset_statements" android:resource="@string/asset_statements" />
4041
<!-- // [END android_identity_assetlinks_manifest] -->
42+
43+
<!-- // [START android_identity_credential_provider_service_manifest] -->
44+
<service android:name=".MyCredentialProviderService"
45+
android:enabled="true"
46+
android:exported="true"
47+
android:label="My Credential Provider"
48+
android:icon="<any drawable icon>"
49+
android:permission="android.permission.BIND_CREDENTIAL_PROVIDER_SERVICE"
50+
tools:targetApi="upside_down_cake">
51+
<intent-filter>
52+
<action android:name="android.service.credentials.CredentialProviderService"/>
53+
</intent-filter>
54+
<meta-data
55+
android:name="android.credentials.provider"
56+
android:resource="@xml/provider"/>
57+
</service>
58+
<!-- // [END android_identity_credential_provider_service_manifest] -->
59+
4160
</application>
4261

43-
</manifest>
62+
</manifest>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.example.identity.credentialmanager
2+
3+
import android.app.Activity
4+
import android.util.Log
5+
import androidx.credentials.CreatePublicKeyCredentialRequest
6+
import androidx.credentials.CreatePublicKeyCredentialResponse
7+
import androidx.credentials.CredentialManager
8+
import androidx.credentials.GetCredentialRequest
9+
import androidx.credentials.GetCredentialResponse
10+
import androidx.credentials.GetPublicKeyCredentialOption
11+
import androidx.credentials.exceptions.CreateCredentialException
12+
import androidx.credentials.exceptions.GetCredentialException
13+
14+
// This class is mostly copied from https://github.com/android/identity-samples/blob/main/WebView/CredentialManagerWebView/CredentialManagerHandler.kt.
15+
class CredentialManagerHandler(private val activity: Activity) {
16+
private val mCredMan = CredentialManager.create(activity.applicationContext)
17+
private val TAG = "CredentialManagerHandler"
18+
/**
19+
* Encapsulates the create passkey API for credential manager in a less error-prone manner.
20+
*
21+
* @param request a create public key credential request JSON required by [CreatePublicKeyCredentialRequest].
22+
* @return [CreatePublicKeyCredentialResponse] containing the result of the credential creation.
23+
*/
24+
suspend fun createPasskey(request: String): CreatePublicKeyCredentialResponse {
25+
val createRequest = CreatePublicKeyCredentialRequest(request)
26+
try {
27+
return mCredMan.createCredential(activity, createRequest) as CreatePublicKeyCredentialResponse
28+
} catch (e: CreateCredentialException) {
29+
// For error handling use guidance from https://developer.android.com/training/sign-in/passkeys
30+
Log.i(TAG, "Error creating credential: ErrMessage: ${e.errorMessage}, ErrType: ${e.type}")
31+
throw e
32+
}
33+
}
34+
35+
/**
36+
* Encapsulates the get passkey API for credential manager in a less error-prone manner.
37+
*
38+
* @param request a get public key credential request JSON required by [GetCredentialRequest].
39+
* @return [GetCredentialResponse] containing the result of the credential retrieval.
40+
*/
41+
suspend fun getPasskey(request: String): GetCredentialResponse {
42+
val getRequest = GetCredentialRequest(listOf(GetPublicKeyCredentialOption(request, null)))
43+
try {
44+
return mCredMan.getCredential(activity, getRequest)
45+
} catch (e: GetCredentialException) {
46+
// For error handling use guidance from https://developer.android.com/training/sign-in/passkeys
47+
Log.i(TAG, "Error retrieving credential: ${e.message}")
48+
throw e
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)