Authorization Management Activity
Stores state and handles events related to the authorization flow. It functions to control the back stack, ensuring that the authorization activity will not be reachable via the back button after the flow completes.
The following diagram illustrates the operation of the activity:
Back Stack Towards Top
+------------------------------------------>
+------------+ +---------------+ +----------------+ +--------------+
| | (1) | | (2) | | (S1) | |
| Initiating +----------->| Authorization +----->| Authorization +----->| Redirect URI |
| Activity | | Management | | Activity | | Receiver |
| | | Activity |<-----+ (e.g. browser) | | Activity |
| | | | (C1) | | | |
+------------+ +--+--------+-+-+ +----------------+ +------+-------+
| | | ^ |
| | | | (S2) |
+-------+ | | +---------------------------------------+
| | +--------------------+
| | (C2/S3) |
| v (S4) v
(C3) | +------------+ +--------+-----------+
| | | | |
| | Completion | | AuthResultLiveData |
| | Activity | | |
| | | +--------------------+
| +------------+
|
| +-------------+
| | |
+----->| Cancelation |
| Activity |
| |
+-------------+
The process begins with an activity requesting that an authorization flow be started.
Step 1: Using an intent derived from {@link #createStartIntent}, this activity is started. The state delivered in this intent is recorded for future use.
Step 2: The authorization intent, typically a browser tab, is started. At this point, depending on user action, we will either end up in a "completion" flow (S) or "cancelation flow" (C).
Cancelation (C) flow:
Step C1: If the user presses the back button or otherwise causes the authorization activity to finish, the AuthorizationManagementActivity will be recreated or restarted.
Step C2:
AuthResultLiveData
will be updated with {@link AuthError#CancelledByUser}.Step C3: The cancellation activity is invoked via the specified PendingIntent.
Completion (S) flow:
Step S1: The authorization activity completes with a success of failure, and sends this result to {@link RedirectUriReceiverActivity}.
Step S2: {@link RedirectUriReceiverActivity} extracts the forwarded data, and invokes AuthorizationManagementActivity using an intent derived from {@link #createResponseHandlingIntent}. This intent has flag CLEAR_TOP set, which will result in both the authorization activity and {@link RedirectUriReceiverActivity} being destroyed, if necessary, such that AuthorizationManagementActivity is once again at the top of the back stack.
Step S3:
AuthResultLiveData
will be updated with {@link User} object. The AuthorizationManagementActivity finishes, removing itself from the back stack.Step S4: The completion activity is invoked via the specified PendingIntent.