1717
1818import android .app .Activity ;
1919import android .app .AlertDialog ;
20- import android .content .ActivityNotFoundException ;
2120import android .content .ComponentName ;
2221import android .content .Context ;
2322import android .content .Intent ;
2625import android .net .Uri ;
2726import android .util .Log ;
2827
29- import com .google .androidbrowserhelper .trusted .splashscreens .SplashScreenStrategy ;
30-
28+ import androidx .annotation .NonNull ;
3129import androidx .annotation .Nullable ;
30+ import androidx .annotation .VisibleForTesting ;
3231import androidx .browser .customtabs .CustomTabsCallback ;
3332import androidx .browser .customtabs .CustomTabsClient ;
3433import androidx .browser .customtabs .CustomTabsIntent ;
4039import androidx .browser .trusted .TokenStore ;
4140import androidx .browser .trusted .TrustedWebActivityIntent ;
4241import androidx .browser .trusted .TrustedWebActivityIntentBuilder ;
43- import com .google .androidbrowserhelper .R ;
44- import java .util .List ;
4542
4643import com .google .androidbrowserhelper .BuildConfig ;
47- import androidx .annotation .VisibleForTesting ;
44+ import com .google .androidbrowserhelper .R ;
45+ import com .google .androidbrowserhelper .trusted .splashscreens .SplashScreenStrategy ;
46+
47+ import java .util .List ;
4848
4949/**
5050 * Encapsulates the steps necessary to launch a Trusted Web Activity, such as establishing a
@@ -135,7 +135,7 @@ public static void setDialogStrategyForTesting(BrowserUnavailableDialogStrategy
135135 @ Nullable
136136 private CustomTabsSession mSession ;
137137
138- private TokenStore mTokenStore ;
138+ private final TokenStore mTokenStore ;
139139
140140 private boolean mDestroyed ;
141141
@@ -248,7 +248,7 @@ public void launch(TrustedWebActivityIntentBuilder twaBuilder,
248248
249249 // Remember who we connect to as the package that is allowed to delegate notifications
250250 // to us.
251- if (!ChromeOsSupport .isRunningOnArc (mContext .getPackageManager ())) {
251+ if (!ChromeOsSupport .isRunningOnArc (mContext .getPackageManager ()) && mProviderPackage != null ) {
252252 // Since ChromeOS may not follow this path when launching a TWA, we set the verified
253253 // provider in DelegationService instead.
254254 mTokenStore .store (Token .create (mProviderPackage , mContext .getPackageManager ()));
@@ -413,7 +413,7 @@ private static void showBrowserUnavailableDialog(Activity activity) {
413413 private class TwaCustomTabsServiceConnection extends CustomTabsServiceConnection {
414414 private Runnable mOnSessionCreatedRunnable ;
415415 private Runnable mOnSessionCreationFailedRunnable ;
416- private CustomTabsCallback mCustomTabsCallback ;
416+ private final CustomTabsCallback mCustomTabsCallback ;
417417
418418 TwaCustomTabsServiceConnection (CustomTabsCallback callback ) {
419419 mCustomTabsCallback = callback ;
@@ -426,8 +426,8 @@ private void setSessionCreationRunnables(@Nullable Runnable onSuccess,
426426 }
427427
428428 @ Override
429- public void onCustomTabsServiceConnected (ComponentName componentName ,
430- CustomTabsClient client ) {
429+ public void onCustomTabsServiceConnected (@ NonNull ComponentName componentName ,
430+ @ NonNull CustomTabsClient client ) {
431431 if (!ChromeLegacyUtils
432432 .supportsLaunchWithoutWarmup (mContext .getPackageManager (), mProviderPackage )) {
433433 client .warmup (0 );
0 commit comments