AppAuth-Android: PostAuth activity not getting called.

@iainmcgin Our qa finally got a phone into the right state for this to happen. Here’s the short version of the activity stack:

Running activities (most recent first):
  TaskRecord{e189f08 #3014 A=com.xfinity.digitalhome U=0 sz=2}
    Run #5: ActivityRecord{becfc11 u0 com.android.chrome/org.chromium.chrome.browser.customtabs.CustomTabActivity t3014}
    Run #4: ActivityRecord{a86dbf9 u0 com.xfinity.digitalhome/.auth.LoginActivity t3014}
  TaskRecord{eb020c6 #3012 A=com.google.android.gm U=0 sz=1}
    Run #3: ActivityRecord{db2673d u0 com.google.android.gm/.ConversationListActivityGmail t3012}
  TaskRecord{71ca3b4 #3008 A=com.google.android.apps.photos U=0 sz=3}
    Run #2: ActivityRecord{cb4ef2b u0 com.google.android.apps.photos/.localmedia.ui.LocalPhotosActivity t3008}
    Run #1: ActivityRecord{6a19a96 u0 com.google.android.apps.photos/.albums.grid.DeviceFoldersActivity t3008}
    Run #0: ActivityRecord{c47be97 u0 com.google.android.apps.photos/.home.HomeActivity t3008}

mResumedActivity: ActivityRecord{becfc11 u0 com.android.chrome/org.chromium.chrome.browser.customtabs.CustomTabActivity t3014}
mLastPausedActivity: ActivityRecord{ae0efd4 u0 com.xfinity.digitalhome/net.openid.appauth.AuthorizationManagementActivity t3014 f}

However, when the RedirectURIReceiverActivity is called, it’s interesting that the activity stack dump (via adb shell dumpsys activity activities) doesn’t even report AuthorizationManagementActivity as being alive anywhere. Hence it’s calling onCreate instead of Resuming it.

Running activities (most recent first):
  TaskRecord{e189f08 #3014 A=com.xfinity.digitalhome U=0 sz=3}
    Run #6: ActivityRecord{e8b4770 u0 com.xfinity.digitalhome/net.openid.appauth.RedirectUriReceiverActivity t3014}
    Run #5: ActivityRecord{becfc11 u0 com.android.chrome/org.chromium.chrome.browser.customtabs.CustomTabActivity t3014}
    Run #4: ActivityRecord{a86dbf9 u0 com.xfinity.digitalhome/.auth.LoginActivity t3014}
  TaskRecord{eb020c6 #3012 A=com.google.android.gm U=0 sz=1}
    Run #3: ActivityRecord{db2673d u0 com.google.android.gm/.ConversationListActivityGmail t3012}
  TaskRecord{71ca3b4 #3008 A=com.google.android.apps.photos U=0 sz=3}
    Run #2: ActivityRecord{cb4ef2b u0 com.google.android.apps.photos/.localmedia.ui.LocalPhotosActivity t3008}
    Run #1: ActivityRecord{6a19a96 u0 com.google.android.apps.photos/.albums.grid.DeviceFoldersActivity t3008}
    Run #0: ActivityRecord{c47be97 u0 com.google.android.apps.photos/.home.HomeActivity t3008}

mResumedActivity: ActivityRecord{e8b4770 u0 com.xfinity.digitalhome/net.openid.appauth.RedirectUriReceiverActivity t3014}
mLastPausedActivity: ActivityRecord{becfc11 u0 com.android.chrome/org.chromium.chrome.browser.customtabs.CustomTabActivity t3014}

I would have expected the AuthorizationManagementActivity to be in the same task record as my LoginActivity which is launching the authorization attempt. I have the full traces if you want them at 3 points in time:

  1. When on the custom tab
  2. When at a breakpoint in RedirectUriReceiverActivity before it sends the intent for AuthorizationManagementActivity
  3. When in the onCreate after that intent has been delivered.

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 36 (10 by maintainers)

Most upvoted comments

@iainmcgin I’ve been able now to produce this consistently. I installed an android 4.4.4 vm into genymotion. I also moved to the startActivityForResult/onActivityResult model, instead of using the service to start the activity.

However, when i call startActivityForResult, i get an immediate callback to onActivityResult, even before the onCreate of AuthorizationManagementActivity is called.

This seems to be due to the launchMode=“singleTask” present in the manifest.

Here’s a stack overflow post which points out the issue:

https://stackoverflow.com/questions/8960072/onactivityresult-with-launchmode-singletask

Changing that to launchMode=“singleTop” fixes things:

    <activity
        android:name="net.openid.appauth.AuthorizationManagementActivity"
        android:exported="false"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        tools:node="replace" />