Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CCT stay alive when activity is paused #121

Merged
merged 1 commit into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void run() {
final Intent intent = new CustomTabsIntent.Builder(session.get())
.build()
.intent;
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing does not cause any other issues? Only asking as issues that required this to fix in RNA.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CCT is not another tab that stays open on the browser, is more like an activity. By removing the flag you make the activity stay up after the app is paused/resumed. Yes, we should probably do the same for RNA and just keep that flag for browser (not CCT) authentication. I didn't do the PR yet because it's not just removing the flag.. CustomTabsIntent may fail to find a package that could "handle CCT and so default to use Browser. We must catch and add the flag to that case too.

intent.setData(uri);
try {
context.startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* It can use an external browser by sending the {@link android.content.Intent#ACTION_VIEW} intent or also the {@link WebAuthActivity}.
* This behaviour is changed using {@link WebAuthProvider.Builder#useBrowser(boolean)}, and defaults to use browser.
*/
@SuppressWarnings("WeakerAccess")
public class WebAuthProvider {

private static final String TAG = WebAuthProvider.class.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import java.util.ArrayList;
import java.util.List;

import static android.support.test.espresso.intent.matcher.IntentMatchers.hasFlag;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
Expand Down Expand Up @@ -162,7 +164,7 @@ public void shouldBindAndLaunchUri() throws Exception {
assertThat(intent.getAction(), is(Intent.ACTION_VIEW));
assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));
assertThat(intent.getData(), is(uri));
assertThat(intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(intent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
}

@Test
Expand All @@ -174,7 +176,8 @@ public void shouldFailToBindButLaunchUri() throws Exception {
Intent intent = launchIntentCaptor.getValue();
assertThat(intent.getAction(), is(Intent.ACTION_VIEW));
assertThat(intent.getData(), is(uri));
assertThat(intent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));
assertThat(intent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
}

@Test
Expand All @@ -198,13 +201,13 @@ public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() throws Exception
Intent customTabIntent = intents.get(0);
assertThat(customTabIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(customTabIntent.getData(), is(uri));
assertThat(customTabIntent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(customTabIntent, not(hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY)));
assertThat(customTabIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true));

Intent fallbackIntent = intents.get(1);
assertThat(fallbackIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(fallbackIntent.getData(), is(uri));
assertThat(fallbackIntent.getFlags() & Intent.FLAG_ACTIVITY_NO_HISTORY, is(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(fallbackIntent, hasFlag(Intent.FLAG_ACTIVITY_NO_HISTORY));
assertThat(fallbackIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(false));
}

Expand Down