Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e1a507a authored by Joshua Trask's avatar Joshua Trask Committed by Android (Google) Code Review
Browse files

Merge "Fix (still-disabled) sharesheet "token flow.""

parents 10c94353 2ed0753a
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1163,8 +1163,10 @@ public class ChooserActivity extends ResolverActivity implements
                            -1);
                    // Action bar is user-independent, always start as primary
                    safelyStartActivityAsUser(ti, getPersonalProfileUserHandle());
                    if (!mAwaitingDelegateResponse) {
                        finish();
                    }
                }
        );
        b.setId(R.id.chooser_nearby_button);
        return b;
@@ -1185,8 +1187,10 @@ public class ChooserActivity extends ResolverActivity implements
                            -1);
                    // Action bar is user-independent, always start as primary
                    safelyStartActivityAsUser(ti, getPersonalProfileUserHandle());
                    if (!mAwaitingDelegateResponse) {
                        finish();
                    }
                }
        );
        b.setId(R.id.chooser_edit_button);
        return b;
@@ -2212,7 +2216,9 @@ public class ChooserActivity extends ResolverActivity implements
            TargetInfo clonedTarget = selectedTarget.cloneFilledIn(matchingIntent, 0);
            if (super.onTargetSelected(clonedTarget, false)) {
                updateModelAndChooserCounts(clonedTarget);
                if (!mAwaitingDelegateResponse) {
                    finish();
                }
                return;
            }
        }
+32 −6
Original line number Diff line number Diff line
@@ -152,6 +152,8 @@ public class ResolverActivity extends Activity implements
    /** See {@link #setRetainInOnStop}. */
    private boolean mRetainInOnStop;

    private static final int REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER = 20;

    private static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args";
    private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
    private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state";
@@ -203,6 +205,8 @@ public class ResolverActivity extends Activity implements

    private UserHandle mWorkProfileUserHandle;

    protected boolean mAwaitingDelegateResponse;

    /**
     * Get the string resource to be used as a label for the link to the resolver activity for an
     * action.
@@ -584,8 +588,10 @@ public class ResolverActivity extends Activity implements
        mProfileSwitchMessageId = -1;

        onTargetSelected(dri, false);
        if (!mAwaitingDelegateResponse) {
            finish();
        }
    }

    /**
     * Numerous layouts are supported, each with optional ViewGroups.
@@ -1026,9 +1032,11 @@ public class ResolverActivity extends Activity implements
                    mMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem()
                            ? MetricsProto.MetricsEvent.ACTION_HIDE_APP_DISAMBIG_APP_FEATURED
                            : MetricsProto.MetricsEvent.ACTION_HIDE_APP_DISAMBIG_NONE_FEATURED);
            if (!mAwaitingDelegateResponse) {
                finish();
            }
        }
    }

    /**
     * Replace me in subclasses!
@@ -1354,15 +1362,31 @@ public class ResolverActivity extends Activity implements
            chooserIntent.putExtra(ActivityTaskManager.EXTRA_IGNORE_TARGET_SECURITY,
                    ignoreTargetSecurity);
            chooserIntent.putExtra(Intent.EXTRA_USER_ID, userId);
            chooserIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
            startActivity(chooserIntent);
            chooserIntent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);

            // Don't close until the delegate finishes, or the token will be invalidated.
            mAwaitingDelegateResponse = true;

            startActivityForResult(chooserIntent, REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER);
        } catch (RemoteException e) {
            Log.e(TAG, e.toString());
        }
        return true;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case REQUEST_CODE_RETURN_FROM_DELEGATE_CHOOSER:
                // Repeat the delegate's result as our own.
                setResult(resultCode, data);
                finish();
                break;
            default:
                super.onActivityResult(requestCode, resultCode, data);
        }
    }

    public void onActivityStarted(TargetInfo cti) {
        // Do nothing
    }
@@ -2152,11 +2176,13 @@ public class ResolverActivity extends Activity implements
                        .getItem(selections[0].getIndex());
                if (ra.onTargetSelected(ti, false)) {
                    ra.mPickOptionRequest = null;
                    if (!ra.mAwaitingDelegateResponse) {
                        ra.finish();
                    }
                }
            }
        }
    }

    protected void maybeLogProfileChange() {}
}