android / wear-os-samples

Multiple samples showing best practices in app and watch face development on Wear OS.
https://developer.android.com/wear
Apache License 2.0
1.12k stars 572 forks source link

Wear OS PKCE approach problem #963

Closed kotya341 closed 10 months ago

kotya341 commented 10 months ago

I have installed your testing app and tried the PKCE approach with my setup Real Android device (Pixel5 Android 14) + paired Wear OS API 30 emulator. The flow seems to be correct till the last step with allow the button to come back to the watches. I'm stuck in allow screen and facing an exception on a phone.


 java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=com.google.android.wear:/... flg=0x10000000 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.authentication.AuthenticationRedirectActivity (has extras) } from ProcessRecord{92dda92 4023:org.mozilla.firefox/u0a39} (pid=4023, uid=10039) not exported from uid 10561
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
    at android.os.Parcel.createException(Parcel.java:3041)
    at android.os.Parcel.readException(Parcel.java:3024)
    at android.os.Parcel.readException(Parcel.java:2966)
    at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2110)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1873)
    at android.app.Activity.startActivityForResult(Activity.java:5589)
    at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:2)
    at android.app.Activity.startActivityForResult(Activity.java:5547)
    at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:1)
    at android.app.Activity.startActivity(Activity.java:6045)
    at android.app.Activity.startActivity(Activity.java:6012)
    at mozilla.components.feature.app.links.AppLinksUseCases$OpenAppLinkRedirect.invoke$default(AppLinksUseCases.kt:64)
    at mozilla.components.feature.app.links.AppLinksFeature$handleAppIntent$doOpenApp$1.invoke(AppLinksFeature.kt:14)
    at mozilla.components.feature.app.links.AppLinksFeature$start$1$3.emit(AppLinksFeature.kt:257)
    at kotlinx.coroutines.flow.DistinctFlowImpl$collect$2.emit(Distinct.kt:91)
    at mozilla.components.feature.app.links.AppLinksFeature$start$1$invokeSuspend$$inlined$mapNotNull$1$2.emit(Emitters.kt:67)
    at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:128)
    at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Channels.kt:12)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:112)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
 Caused by: android.os.RemoteException: Remote stack trace:
    at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1136)
    at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1069)
    at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:742)
    at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1288)
    at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1239)

Do you have any idea why it can happen? I believe its a problem with emulator, but want to hear an expects opinion

luizgrp commented 10 months ago

Thanks for reporting it!

I could reproduce the issue (with another sample app) using emulators Wear API 33 and Phone API 32. But the flow seems to work fine when pairing the same Phone API 32 with Wear API 30. I will check the logs to see if the stacktrace is the same.

Could you please raise an issue in the issue tracker? I also have an internal ticket, but I'm suggesting you to raise a public one so you can get updates.

kotya341 commented 10 months ago

@luizgrp thanks for your reply. I just created an issue does it mean that we can close this issue here?

luizgrp commented 10 months ago

yes, please! let's continue the discussion in the ticket in the issue tracker and keep the tickets here in github for issues specific to the sample code.

Thanks for the link I'm following it 👍