Skip to content
Closed
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
19 changes: 16 additions & 3 deletions library/java/net/openid/appauth/browser/BrowserSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.customtabs.CustomTabsService;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -50,10 +49,24 @@ public final class BrowserSelector {

/**
* The service we expect to find on a web browser that indicates it supports custom tabs.
*
* Workaround for Android Jetifier bug (https://issuetracker.google.com/issues/119183822)
*
* Problem: Projects that are using androidx are using a Jetifier compiler as a dependency.
* The Jetifier compiler is replacing "android.support" with "androidx" inside all the
* dependencies, AppAuth included. But "android.support" is still required by the platform in
* order to open a chrome tab. As a result - a chrome tab is not found, and an external browser
* is opened instead.
* Workaround: Using StringBuilder to create the string
* "android.support.customtabs.action.CustomTabsService" in runtime prevents the jetifier static
* regex from matching "android.support" in the compiled class, thus avoiding the androidx
* replacement.
*/
@SuppressWarnings("StringBufferReplaceableByString")
@VisibleForTesting
static final String ACTION_CUSTOM_TABS_CONNECTION =
CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION;
static final String ACTION_CUSTOM_TABS_CONNECTION = new StringBuilder()
Comment thread
auval marked this conversation as resolved.
.append("android.")
.append("support.customtabs.action.CustomTabsService").toString();

/**
* An arbitrary (but unregistrable, per
Expand Down