Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
package androidx.browser;
/* loaded from: classes.dex */
public final class R {
public static final class color {
public static int browser_actions_bg_grey = 0x7f060048;
public static int browser_actions_divider_color = 0x7f060049;
public static int browser_actions_text_color = 0x7f06004a;
public static int browser_actions_title_color = 0x7f06004b;
private color() {
}
}
public static final class dimen {
public static int browser_actions_context_menu_max_width = 0x7f070080;
public static int browser_actions_context_menu_min_padding = 0x7f070081;
private dimen() {
}
}
public static final class id {
public static int browser_actions_header_text = 0x7f0a0094;
public static int browser_actions_menu_item_icon = 0x7f0a0095;
public static int browser_actions_menu_item_text = 0x7f0a0096;
public static int browser_actions_menu_items = 0x7f0a0097;
public static int browser_actions_menu_view = 0x7f0a0098;
private id() {
}
}
public static final class layout {
public static int browser_actions_context_menu_page = 0x7f0d002b;
public static int browser_actions_context_menu_row = 0x7f0d002c;
private layout() {
}
}
public static final class string {
public static int copy_toast_msg = 0x7f1200b2;
public static int fallback_menu_item_copy_link = 0x7f120101;
public static int fallback_menu_item_open_in_browser = 0x7f120102;
public static int fallback_menu_item_share_link = 0x7f120103;
private string() {
}
}
public static final class xml {
public static int image_share_filepaths = 0x7f150008;
private xml() {
}
}
private R() {
}
}

View File

@@ -0,0 +1,79 @@
package androidx.browser.browseractions;
import android.app.PendingIntent;
import android.net.Uri;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
@Deprecated
/* loaded from: classes.dex */
public class BrowserActionItem {
@Nullable
private final PendingIntent mAction;
@DrawableRes
private int mIconId;
@Nullable
private Uri mIconUri;
@Nullable
private Runnable mRunnableAction;
private final String mTitle;
public int getIconId() {
return this.mIconId;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Uri getIconUri() {
return this.mIconUri;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Runnable getRunnableAction() {
return this.mRunnableAction;
}
@NonNull
public String getTitle() {
return this.mTitle;
}
public BrowserActionItem(@NonNull String str, @NonNull PendingIntent pendingIntent, @DrawableRes int i) {
this.mTitle = str;
this.mAction = pendingIntent;
this.mIconId = i;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public BrowserActionItem(@NonNull String str, @NonNull PendingIntent pendingIntent, @NonNull Uri uri) {
this.mTitle = str;
this.mAction = pendingIntent;
this.mIconUri = uri;
}
public BrowserActionItem(@NonNull String str, @NonNull Runnable runnable) {
this.mTitle = str;
this.mAction = null;
this.mRunnableAction = runnable;
}
public BrowserActionItem(@NonNull String str, @NonNull PendingIntent pendingIntent) {
this(str, pendingIntent, 0);
}
@NonNull
public PendingIntent getAction() {
PendingIntent pendingIntent = this.mAction;
if (pendingIntent != null) {
return pendingIntent;
}
throw new IllegalStateException("Can't call getAction on BrowserActionItem with null action.");
}
}

View File

@@ -0,0 +1,109 @@
package androidx.browser.browseractions;
import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.browser.R;
import androidx.core.content.res.ResourcesCompat;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@Deprecated
/* loaded from: classes.dex */
class BrowserActionsFallbackMenuAdapter extends BaseAdapter {
private final Context mContext;
private final List<BrowserActionItem> mMenuItems;
@Override // android.widget.Adapter
public long getItemId(int i) {
return i;
}
public BrowserActionsFallbackMenuAdapter(List<BrowserActionItem> list, Context context) {
this.mMenuItems = list;
this.mContext = context;
}
@Override // android.widget.Adapter
public int getCount() {
return this.mMenuItems.size();
}
@Override // android.widget.Adapter
public Object getItem(int i) {
return this.mMenuItems.get(i);
}
@Override // android.widget.Adapter
public View getView(int i, View view, ViewGroup viewGroup) {
final ViewHolderItem viewHolderItem;
BrowserActionItem browserActionItem = this.mMenuItems.get(i);
if (view == null) {
view = LayoutInflater.from(this.mContext).inflate(R.layout.browser_actions_context_menu_row, (ViewGroup) null);
ImageView imageView = (ImageView) view.findViewById(R.id.browser_actions_menu_item_icon);
TextView textView = (TextView) view.findViewById(R.id.browser_actions_menu_item_text);
if (imageView == null || textView == null) {
throw new IllegalStateException("Browser Actions fallback UI does not contain necessary Views.");
}
viewHolderItem = new ViewHolderItem(imageView, textView);
view.setTag(viewHolderItem);
} else {
viewHolderItem = (ViewHolderItem) view.getTag();
}
final String title = browserActionItem.getTitle();
viewHolderItem.mText.setText(title);
if (browserActionItem.getIconId() != 0) {
viewHolderItem.mIcon.setImageDrawable(ResourcesCompat.getDrawable(this.mContext.getResources(), browserActionItem.getIconId(), null));
} else if (browserActionItem.getIconUri() != null) {
final ListenableFuture loadBitmap = BrowserServiceFileProvider.loadBitmap(this.mContext.getContentResolver(), browserActionItem.getIconUri());
loadBitmap.addListener(new Runnable() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuAdapter.1
@Override // java.lang.Runnable
public void run() {
Bitmap bitmap;
if (TextUtils.equals(title, viewHolderItem.mText.getText())) {
try {
bitmap = (Bitmap) loadBitmap.get();
} catch (InterruptedException | ExecutionException unused) {
bitmap = null;
}
if (bitmap != null) {
viewHolderItem.mIcon.setVisibility(0);
viewHolderItem.mIcon.setImageBitmap(bitmap);
} else {
viewHolderItem.mIcon.setVisibility(4);
viewHolderItem.mIcon.setImageBitmap(null);
}
}
}
}, new Executor() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuAdapter.2
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
runnable.run();
}
});
} else {
viewHolderItem.mIcon.setImageBitmap(null);
viewHolderItem.mIcon.setVisibility(4);
}
return view;
}
public static class ViewHolderItem {
final ImageView mIcon;
final TextView mText;
public ViewHolderItem(ImageView imageView, TextView textView) {
this.mIcon = imageView;
this.mText = textView;
}
}
}

View File

@@ -0,0 +1,61 @@
package androidx.browser.browseractions;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.MotionEvent;
import android.view.View;
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator;
@Deprecated
/* loaded from: classes.dex */
class BrowserActionsFallbackMenuDialog extends Dialog {
private static final long ENTER_ANIMATION_DURATION_MS = 250;
private static final long EXIT_ANIMATION_DURATION_MS = 150;
private final View mContentView;
public BrowserActionsFallbackMenuDialog(Context context, View view) {
super(context);
this.mContentView = view;
}
@Override // android.app.Dialog
public void show() {
getWindow().setBackgroundDrawable(new ColorDrawable(0));
startAnimation(true);
super.show();
}
@Override // android.app.Dialog
public boolean onTouchEvent(MotionEvent motionEvent) {
if (motionEvent.getAction() != 0) {
return false;
}
dismiss();
return true;
}
@Override // android.app.Dialog, android.content.DialogInterface
public void dismiss() {
startAnimation(false);
}
private void startAnimation(final boolean z) {
float f = z ? 0.0f : 1.0f;
float f2 = z ? 1.0f : 0.0f;
long j = z ? ENTER_ANIMATION_DURATION_MS : EXIT_ANIMATION_DURATION_MS;
this.mContentView.setScaleX(f);
this.mContentView.setScaleY(f);
this.mContentView.animate().scaleX(f2).scaleY(f2).setDuration(j).setInterpolator(new LinearOutSlowInInterpolator()).setListener(new AnimatorListenerAdapter() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuDialog.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
if (z) {
return;
}
BrowserActionsFallbackMenuDialog.super.dismiss();
}
}).start();
}
}

View File

@@ -0,0 +1,155 @@
package androidx.browser.browseractions;
import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.browser.R;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import androidx.core.widget.TextViewCompat;
import java.util.ArrayList;
import java.util.List;
@Deprecated
/* loaded from: classes.dex */
class BrowserActionsFallbackMenuUi implements AdapterView.OnItemClickListener {
private static final String TAG = "BrowserActionskMenuUi";
@Nullable
private BrowserActionsFallbackMenuDialog mBrowserActionsDialog;
final Context mContext;
private final List<BrowserActionItem> mMenuItems;
@Nullable
BrowserActionsFallMenuUiListener mMenuUiListener;
final Uri mUri;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public interface BrowserActionsFallMenuUiListener {
void onMenuShown(View view);
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public void setMenuUiListener(@Nullable BrowserActionsFallMenuUiListener browserActionsFallMenuUiListener) {
this.mMenuUiListener = browserActionsFallMenuUiListener;
}
public BrowserActionsFallbackMenuUi(@NonNull Context context, @NonNull Uri uri, @NonNull List<BrowserActionItem> list) {
this.mContext = context;
this.mUri = uri;
this.mMenuItems = buildFallbackMenuItemList(list);
}
@NonNull
private List<BrowserActionItem> buildFallbackMenuItemList(List<BrowserActionItem> list) {
ArrayList arrayList = new ArrayList();
arrayList.add(new BrowserActionItem(this.mContext.getString(R.string.fallback_menu_item_open_in_browser), buildOpenInBrowserAction()));
arrayList.add(new BrowserActionItem(this.mContext.getString(R.string.fallback_menu_item_copy_link), buildCopyAction()));
arrayList.add(new BrowserActionItem(this.mContext.getString(R.string.fallback_menu_item_share_link), buildShareAction()));
arrayList.addAll(list);
return arrayList;
}
private PendingIntent buildOpenInBrowserAction() {
return PendingIntent.getActivity(this.mContext, 0, new Intent("android.intent.action.VIEW", this.mUri), AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL);
}
private PendingIntent buildShareAction() {
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.TEXT", this.mUri.toString());
intent.setType("text/plain");
return PendingIntent.getActivity(this.mContext, 0, intent, AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL);
}
private Runnable buildCopyAction() {
return new Runnable() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuUi.1
@Override // java.lang.Runnable
public void run() {
((ClipboardManager) BrowserActionsFallbackMenuUi.this.mContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("url", BrowserActionsFallbackMenuUi.this.mUri.toString()));
Toast.makeText(BrowserActionsFallbackMenuUi.this.mContext, BrowserActionsFallbackMenuUi.this.mContext.getString(R.string.copy_toast_msg), 0).show();
}
};
}
public void displayMenu() {
final View inflate = LayoutInflater.from(this.mContext).inflate(R.layout.browser_actions_context_menu_page, (ViewGroup) null);
BrowserActionsFallbackMenuDialog browserActionsFallbackMenuDialog = new BrowserActionsFallbackMenuDialog(this.mContext, initMenuView(inflate));
this.mBrowserActionsDialog = browserActionsFallbackMenuDialog;
browserActionsFallbackMenuDialog.setContentView(inflate);
if (this.mMenuUiListener != null) {
this.mBrowserActionsDialog.setOnShowListener(new DialogInterface.OnShowListener() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuUi.2
@Override // android.content.DialogInterface.OnShowListener
public void onShow(DialogInterface dialogInterface) {
BrowserActionsFallMenuUiListener browserActionsFallMenuUiListener = BrowserActionsFallbackMenuUi.this.mMenuUiListener;
if (browserActionsFallMenuUiListener == null) {
Log.e(BrowserActionsFallbackMenuUi.TAG, "Cannot trigger menu item listener, it is null");
} else {
browserActionsFallMenuUiListener.onMenuShown(inflate);
}
}
});
}
this.mBrowserActionsDialog.show();
}
private BrowserActionsFallbackMenuView initMenuView(View view) {
BrowserActionsFallbackMenuView browserActionsFallbackMenuView = (BrowserActionsFallbackMenuView) view.findViewById(R.id.browser_actions_menu_view);
final TextView textView = (TextView) view.findViewById(R.id.browser_actions_header_text);
textView.setText(this.mUri.toString());
textView.setOnClickListener(new View.OnClickListener() { // from class: androidx.browser.browseractions.BrowserActionsFallbackMenuUi.3
@Override // android.view.View.OnClickListener
public void onClick(View view2) {
if (TextViewCompat.getMaxLines(textView) == Integer.MAX_VALUE) {
textView.setMaxLines(1);
textView.setEllipsize(TextUtils.TruncateAt.END);
} else {
textView.setMaxLines(Integer.MAX_VALUE);
textView.setEllipsize(null);
}
}
});
ListView listView = (ListView) view.findViewById(R.id.browser_actions_menu_items);
listView.setAdapter((ListAdapter) new BrowserActionsFallbackMenuAdapter(this.mMenuItems, this.mContext));
listView.setOnItemClickListener(this);
return browserActionsFallbackMenuView;
}
@Override // android.widget.AdapterView.OnItemClickListener
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
BrowserActionItem browserActionItem = this.mMenuItems.get(i);
if (browserActionItem.getAction() != null) {
try {
browserActionItem.getAction().send();
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "Failed to send custom item action", e);
}
} else if (browserActionItem.getRunnableAction() != null) {
browserActionItem.getRunnableAction().run();
}
BrowserActionsFallbackMenuDialog browserActionsFallbackMenuDialog = this.mBrowserActionsDialog;
if (browserActionsFallbackMenuDialog == null) {
Log.e(TAG, "Cannot dismiss dialog, it has already been dismissed.");
} else {
browserActionsFallbackMenuDialog.dismiss();
}
}
}

View File

@@ -0,0 +1,28 @@
package androidx.browser.browseractions;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.browser.R;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@Deprecated
/* loaded from: classes.dex */
public class BrowserActionsFallbackMenuView extends LinearLayout {
private final int mBrowserActionsMenuMaxWidthPx;
private final int mBrowserActionsMenuMinPaddingPx;
public BrowserActionsFallbackMenuView(@NonNull Context context, @NonNull AttributeSet attributeSet) {
super(context, attributeSet);
this.mBrowserActionsMenuMinPaddingPx = getResources().getDimensionPixelOffset(R.dimen.browser_actions_context_menu_min_padding);
this.mBrowserActionsMenuMaxWidthPx = getResources().getDimensionPixelOffset(R.dimen.browser_actions_context_menu_max_width);
}
@Override // android.widget.LinearLayout, android.view.View
public void onMeasure(int i, int i2) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(Math.min(getResources().getDisplayMetrics().widthPixels - (this.mBrowserActionsMenuMinPaddingPx * 2), this.mBrowserActionsMenuMaxWidthPx), 1073741824), i2);
}
}

View File

@@ -0,0 +1,268 @@
package androidx.browser.browseractions;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Deprecated
/* loaded from: classes.dex */
public class BrowserActionsIntent {
public static final String ACTION_BROWSER_ACTIONS_OPEN = "androidx.browser.browseractions.browser_action_open";
public static final String EXTRA_APP_ID = "androidx.browser.browseractions.APP_ID";
public static final String EXTRA_MENU_ITEMS = "androidx.browser.browseractions.extra.MENU_ITEMS";
public static final String EXTRA_SELECTED_ACTION_PENDING_INTENT = "androidx.browser.browseractions.extra.SELECTED_ACTION_PENDING_INTENT";
public static final String EXTRA_TYPE = "androidx.browser.browseractions.extra.TYPE";
public static final int ITEM_COPY = 3;
public static final int ITEM_DOWNLOAD = 2;
public static final int ITEM_INVALID_ITEM = -1;
public static final int ITEM_OPEN_IN_INCOGNITO = 1;
public static final int ITEM_OPEN_IN_NEW_TAB = 0;
public static final int ITEM_SHARE = 4;
public static final String KEY_ACTION = "androidx.browser.browseractions.ACTION";
public static final String KEY_ICON_ID = "androidx.browser.browseractions.ICON_ID";
private static final String KEY_ICON_URI = "androidx.browser.browseractions.ICON_URI";
public static final String KEY_TITLE = "androidx.browser.browseractions.TITLE";
@SuppressLint({"MinMaxConstant"})
public static final int MAX_CUSTOM_ITEMS = 5;
private static final String TAG = "BrowserActions";
private static final String TEST_URL = "https://www.example.com";
public static final int URL_TYPE_AUDIO = 3;
public static final int URL_TYPE_FILE = 4;
public static final int URL_TYPE_IMAGE = 1;
public static final int URL_TYPE_NONE = 0;
public static final int URL_TYPE_PLUGIN = 5;
public static final int URL_TYPE_VIDEO = 2;
@Nullable
private static BrowserActionsFallDialogListener sDialogListenter;
@NonNull
private final Intent mIntent;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public interface BrowserActionsFallDialogListener {
void onDialogShown();
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public @interface BrowserActionsItemId {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public @interface BrowserActionsUrlType {
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public static void setDialogShownListenter(BrowserActionsFallDialogListener browserActionsFallDialogListener) {
sDialogListenter = browserActionsFallDialogListener;
}
@NonNull
public Intent getIntent() {
return this.mIntent;
}
public BrowserActionsIntent(@NonNull Intent intent) {
this.mIntent = intent;
}
public static final class Builder {
private Context mContext;
private Uri mUri;
private final Intent mIntent = new Intent(BrowserActionsIntent.ACTION_BROWSER_ACTIONS_OPEN);
private int mType = 0;
private ArrayList<Bundle> mMenuItems = new ArrayList<>();
@Nullable
private PendingIntent mOnItemSelectedPendingIntent = null;
private List<Uri> mImageUris = new ArrayList();
@NonNull
public Builder setOnItemSelectedAction(@NonNull PendingIntent pendingIntent) {
this.mOnItemSelectedPendingIntent = pendingIntent;
return this;
}
@NonNull
public Builder setUrlType(int i) {
this.mType = i;
return this;
}
public Builder(@NonNull Context context, @NonNull Uri uri) {
this.mContext = context;
this.mUri = uri;
}
@NonNull
public Builder setCustomItems(@NonNull ArrayList<BrowserActionItem> arrayList) {
if (arrayList.size() > 5) {
throw new IllegalStateException("Exceeded maximum toolbar item count of 5");
}
for (int i = 0; i < arrayList.size(); i++) {
if (TextUtils.isEmpty(arrayList.get(i).getTitle()) || arrayList.get(i).getAction() == null) {
throw new IllegalArgumentException("Custom item should contain a non-empty title and non-null intent.");
}
this.mMenuItems.add(getBundleFromItem(arrayList.get(i)));
if (arrayList.get(i).getIconUri() != null) {
this.mImageUris.add(arrayList.get(i).getIconUri());
}
}
return this;
}
@NonNull
public Builder setCustomItems(@NonNull BrowserActionItem... browserActionItemArr) {
return setCustomItems(new ArrayList<>(Arrays.asList(browserActionItemArr)));
}
@NonNull
private Bundle getBundleFromItem(@NonNull BrowserActionItem browserActionItem) {
Bundle bundle = new Bundle();
bundle.putString(BrowserActionsIntent.KEY_TITLE, browserActionItem.getTitle());
bundle.putParcelable(BrowserActionsIntent.KEY_ACTION, browserActionItem.getAction());
if (browserActionItem.getIconId() != 0) {
bundle.putInt(BrowserActionsIntent.KEY_ICON_ID, browserActionItem.getIconId());
}
if (browserActionItem.getIconUri() != null) {
bundle.putParcelable(BrowserActionsIntent.KEY_ICON_URI, browserActionItem.getIconUri());
}
return bundle;
}
@NonNull
public BrowserActionsIntent build() {
this.mIntent.setData(this.mUri);
this.mIntent.putExtra(BrowserActionsIntent.EXTRA_TYPE, this.mType);
this.mIntent.putParcelableArrayListExtra(BrowserActionsIntent.EXTRA_MENU_ITEMS, this.mMenuItems);
this.mIntent.putExtra(BrowserActionsIntent.EXTRA_APP_ID, PendingIntent.getActivity(this.mContext, 0, new Intent(), AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL));
PendingIntent pendingIntent = this.mOnItemSelectedPendingIntent;
if (pendingIntent != null) {
this.mIntent.putExtra(BrowserActionsIntent.EXTRA_SELECTED_ACTION_PENDING_INTENT, pendingIntent);
}
BrowserServiceFileProvider.grantReadPermission(this.mIntent, this.mImageUris, this.mContext);
return new BrowserActionsIntent(this.mIntent);
}
}
public static void openBrowserAction(@NonNull Context context, @NonNull Uri uri) {
launchIntent(context, new Builder(context, uri).build().getIntent());
}
public static void openBrowserAction(@NonNull Context context, @NonNull Uri uri, int i, @NonNull ArrayList<BrowserActionItem> arrayList, @NonNull PendingIntent pendingIntent) {
launchIntent(context, new Builder(context, uri).setUrlType(i).setCustomItems(arrayList).setOnItemSelectedAction(pendingIntent).build().getIntent());
}
public static void launchIntent(@NonNull Context context, @NonNull Intent intent) {
launchIntent(context, intent, getBrowserActionsIntentHandlers(context));
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public static void launchIntent(Context context, Intent intent, List<ResolveInfo> list) {
if (list == null || list.size() == 0) {
openFallbackBrowserActionsMenu(context, intent);
return;
}
int i = 0;
if (list.size() == 1) {
intent.setPackage(list.get(0).activityInfo.packageName);
} else {
ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(new Intent("android.intent.action.VIEW", Uri.parse(TEST_URL)), 65536);
if (resolveActivity != null) {
String str = resolveActivity.activityInfo.packageName;
while (true) {
if (i >= list.size()) {
break;
}
if (str.equals(list.get(i).activityInfo.packageName)) {
intent.setPackage(str);
break;
}
i++;
}
}
}
ContextCompat.startActivity(context, intent, null);
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static List<ResolveInfo> getBrowserActionsIntentHandlers(@NonNull Context context) {
return context.getPackageManager().queryIntentActivities(new Intent(ACTION_BROWSER_ACTIONS_OPEN, Uri.parse(TEST_URL)), 131072);
}
private static void openFallbackBrowserActionsMenu(Context context, Intent intent) {
Uri data = intent.getData();
ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra(EXTRA_MENU_ITEMS);
openFallbackBrowserActionsMenu(context, data, parcelableArrayListExtra != null ? parseBrowserActionItems(parcelableArrayListExtra) : null);
}
private static void openFallbackBrowserActionsMenu(Context context, Uri uri, List<BrowserActionItem> list) {
new BrowserActionsFallbackMenuUi(context, uri, list).displayMenu();
BrowserActionsFallDialogListener browserActionsFallDialogListener = sDialogListenter;
if (browserActionsFallDialogListener != null) {
browserActionsFallDialogListener.onDialogShown();
}
}
@NonNull
public static List<BrowserActionItem> parseBrowserActionItems(@NonNull ArrayList<Bundle> arrayList) {
BrowserActionItem browserActionItem;
ArrayList arrayList2 = new ArrayList();
for (int i = 0; i < arrayList.size(); i++) {
Bundle bundle = arrayList.get(i);
String string = bundle.getString(KEY_TITLE);
PendingIntent pendingIntent = (PendingIntent) bundle.getParcelable(KEY_ACTION);
int i2 = bundle.getInt(KEY_ICON_ID);
Uri uri = (Uri) bundle.getParcelable(KEY_ICON_URI);
if (!TextUtils.isEmpty(string) && pendingIntent != null) {
if (i2 != 0) {
browserActionItem = new BrowserActionItem(string, pendingIntent, i2);
} else {
browserActionItem = new BrowserActionItem(string, pendingIntent, uri);
}
arrayList2.add(browserActionItem);
} else {
throw new IllegalArgumentException("Custom item should contain a non-empty title and non-null intent.");
}
}
return arrayList2;
}
@Nullable
public static String getUntrustedCreatorPackageName(@NonNull Intent intent) {
PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra(EXTRA_APP_ID);
if (pendingIntent != null) {
return pendingIntent.getTargetPackage();
}
return null;
}
@Nullable
@Deprecated
public static String getCreatorPackageName(@NonNull Intent intent) {
return getUntrustedCreatorPackageName(intent);
}
}

View File

@@ -0,0 +1,228 @@
package androidx.browser.browseractions;
import android.content.ClipData;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.core.content.FileProvider;
import androidx.core.util.AtomicFile;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
@RestrictTo({RestrictTo.Scope.LIBRARY})
@Deprecated
/* loaded from: classes.dex */
public final class BrowserServiceFileProvider extends FileProvider {
private static final String AUTHORITY_SUFFIX = ".image_provider";
private static final String CLIP_DATA_LABEL = "image_provider_uris";
private static final String CONTENT_SCHEME = "content";
private static final String FILE_EXTENSION = ".png";
private static final String FILE_SUB_DIR = "image_provider";
private static final String FILE_SUB_DIR_NAME = "image_provider_images/";
private static final String LAST_CLEANUP_TIME_KEY = "last_cleanup_time";
private static final String TAG = "BrowserServiceFP";
static Object sFileCleanupLock = new Object();
public static class FileCleanupTask extends AsyncTask<Void, Void, Void> {
private static final long CLEANUP_REQUIRED_TIME_SPAN;
private static final long DELETION_FAILED_REATTEMPT_DURATION;
private static final long IMAGE_RETENTION_DURATION;
private final Context mAppContext;
static {
TimeUnit timeUnit = TimeUnit.DAYS;
IMAGE_RETENTION_DURATION = timeUnit.toMillis(7L);
CLEANUP_REQUIRED_TIME_SPAN = timeUnit.toMillis(7L);
DELETION_FAILED_REATTEMPT_DURATION = timeUnit.toMillis(1L);
}
public FileCleanupTask(Context context) {
this.mAppContext = context.getApplicationContext();
}
@Override // android.os.AsyncTask
public Void doInBackground(Void... voidArr) {
long currentTimeMillis;
SharedPreferences sharedPreferences = this.mAppContext.getSharedPreferences(this.mAppContext.getPackageName() + BrowserServiceFileProvider.AUTHORITY_SUFFIX, 0);
if (!shouldCleanUp(sharedPreferences)) {
return null;
}
synchronized (BrowserServiceFileProvider.sFileCleanupLock) {
try {
File file = new File(this.mAppContext.getFilesDir(), BrowserServiceFileProvider.FILE_SUB_DIR);
if (!file.exists()) {
return null;
}
File[] listFiles = file.listFiles();
long currentTimeMillis2 = System.currentTimeMillis() - IMAGE_RETENTION_DURATION;
boolean z = true;
for (File file2 : listFiles) {
if (isImageFile(file2) && file2.lastModified() < currentTimeMillis2 && !file2.delete()) {
Log.e(BrowserServiceFileProvider.TAG, "Fail to delete image: " + file2.getAbsoluteFile());
z = false;
}
}
if (z) {
currentTimeMillis = System.currentTimeMillis();
} else {
currentTimeMillis = (System.currentTimeMillis() - CLEANUP_REQUIRED_TIME_SPAN) + DELETION_FAILED_REATTEMPT_DURATION;
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putLong(BrowserServiceFileProvider.LAST_CLEANUP_TIME_KEY, currentTimeMillis);
edit.apply();
return null;
} catch (Throwable th) {
throw th;
}
}
}
private static boolean isImageFile(File file) {
return file.getName().endsWith("..png");
}
private static boolean shouldCleanUp(SharedPreferences sharedPreferences) {
return System.currentTimeMillis() > sharedPreferences.getLong(BrowserServiceFileProvider.LAST_CLEANUP_TIME_KEY, System.currentTimeMillis()) + CLEANUP_REQUIRED_TIME_SPAN;
}
}
public static class FileSaveTask extends AsyncTask<String, Void, Void> {
private final Context mAppContext;
private final Bitmap mBitmap;
private final Uri mFileUri;
private final String mFilename;
private final ResolvableFuture<Uri> mResultFuture;
public FileSaveTask(Context context, String str, Bitmap bitmap, Uri uri, ResolvableFuture<Uri> resolvableFuture) {
this.mAppContext = context.getApplicationContext();
this.mFilename = str;
this.mBitmap = bitmap;
this.mFileUri = uri;
this.mResultFuture = resolvableFuture;
}
@Override // android.os.AsyncTask
public Void doInBackground(String... strArr) {
saveFileIfNeededBlocking();
return null;
}
@Override // android.os.AsyncTask
public void onPostExecute(Void r3) {
new FileCleanupTask(this.mAppContext).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, new Void[0]);
}
private void saveFileIfNeededBlocking() {
File file = new File(this.mAppContext.getFilesDir(), BrowserServiceFileProvider.FILE_SUB_DIR);
synchronized (BrowserServiceFileProvider.sFileCleanupLock) {
try {
if (!file.exists() && !file.mkdir()) {
this.mResultFuture.setException(new IOException("Could not create file directory."));
return;
}
File file2 = new File(file, this.mFilename + BrowserServiceFileProvider.FILE_EXTENSION);
if (file2.exists()) {
this.mResultFuture.set(this.mFileUri);
} else {
saveFileBlocking(file2);
}
file2.setLastModified(System.currentTimeMillis());
} catch (Throwable th) {
throw th;
}
}
}
private void saveFileBlocking(File file) {
FileOutputStream fileOutputStream;
AtomicFile atomicFile = new AtomicFile(file);
try {
fileOutputStream = atomicFile.startWrite();
} catch (IOException e) {
e = e;
fileOutputStream = null;
}
try {
this.mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.close();
atomicFile.finishWrite(fileOutputStream);
this.mResultFuture.set(this.mFileUri);
} catch (IOException e2) {
e = e2;
atomicFile.failWrite(fileOutputStream);
this.mResultFuture.setException(e);
}
}
}
@NonNull
@UiThread
public static ResolvableFuture<Uri> saveBitmap(@NonNull Context context, @NonNull Bitmap bitmap, @NonNull String str, int i) {
String str2 = str + "_" + Integer.toString(i);
Uri generateUri = generateUri(context, str2);
ResolvableFuture<Uri> create = ResolvableFuture.create();
new FileSaveTask(context, str2, bitmap, generateUri, create).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new String[0]);
return create;
}
private static Uri generateUri(Context context, String str) {
return new Uri.Builder().scheme("content").authority(context.getPackageName() + AUTHORITY_SUFFIX).path(FILE_SUB_DIR_NAME + str + FILE_EXTENSION).build();
}
public static void grantReadPermission(@NonNull Intent intent, @Nullable List<Uri> list, @NonNull Context context) {
if (list == null || list.size() == 0) {
return;
}
ContentResolver contentResolver = context.getContentResolver();
intent.addFlags(1);
ClipData newUri = ClipData.newUri(contentResolver, CLIP_DATA_LABEL, list.get(0));
for (int i = 1; i < list.size(); i++) {
newUri.addItem(new ClipData.Item(list.get(i)));
}
intent.setClipData(newUri);
}
@NonNull
public static ListenableFuture loadBitmap(@NonNull final ContentResolver contentResolver, @NonNull final Uri uri) {
final ResolvableFuture create = ResolvableFuture.create();
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() { // from class: androidx.browser.browseractions.BrowserServiceFileProvider.1
@Override // java.lang.Runnable
public void run() {
try {
ParcelFileDescriptor openFileDescriptor = contentResolver.openFileDescriptor(uri, "r");
if (openFileDescriptor == null) {
create.setException(new FileNotFoundException());
return;
}
Bitmap decodeFileDescriptor = BitmapFactory.decodeFileDescriptor(openFileDescriptor.getFileDescriptor());
openFileDescriptor.close();
if (decodeFileDescriptor == null) {
create.setException(new IOException("File could not be decoded."));
} else {
create.set(decodeFileDescriptor);
}
} catch (IOException e) {
create.setException(e);
}
}
});
return create;
}
}

View File

@@ -0,0 +1,19 @@
package androidx.browser.customtabs;
import android.os.Bundle;
import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
@RequiresApi(33)
/* loaded from: classes.dex */
class Api33Impl {
private Api33Impl() {
}
@DoNotInline
public static <T> T getParcelable(@NonNull Bundle bundle, @Nullable String str, @NonNull Class<T> cls) {
return (T) bundle.getParcelable(str, cls);
}
}

View File

@@ -0,0 +1,133 @@
package androidx.browser.customtabs;
import android.os.Bundle;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
/* loaded from: classes.dex */
public final class CustomTabColorSchemeParams {
@Nullable
@ColorInt
public final Integer navigationBarColor;
@Nullable
@ColorInt
public final Integer navigationBarDividerColor;
@Nullable
@ColorInt
public final Integer secondaryToolbarColor;
@Nullable
@ColorInt
public final Integer toolbarColor;
public CustomTabColorSchemeParams(@Nullable @ColorInt Integer num, @Nullable @ColorInt Integer num2, @Nullable @ColorInt Integer num3, @Nullable @ColorInt Integer num4) {
this.toolbarColor = num;
this.secondaryToolbarColor = num2;
this.navigationBarColor = num3;
this.navigationBarDividerColor = num4;
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
Integer num = this.toolbarColor;
if (num != null) {
bundle.putInt(CustomTabsIntent.EXTRA_TOOLBAR_COLOR, num.intValue());
}
Integer num2 = this.secondaryToolbarColor;
if (num2 != null) {
bundle.putInt(CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_COLOR, num2.intValue());
}
Integer num3 = this.navigationBarColor;
if (num3 != null) {
bundle.putInt(CustomTabsIntent.EXTRA_NAVIGATION_BAR_COLOR, num3.intValue());
}
Integer num4 = this.navigationBarDividerColor;
if (num4 != null) {
bundle.putInt(CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR, num4.intValue());
}
return bundle;
}
@NonNull
public static CustomTabColorSchemeParams fromBundle(@Nullable Bundle bundle) {
if (bundle == null) {
bundle = new Bundle(0);
}
return new CustomTabColorSchemeParams((Integer) bundle.get(CustomTabsIntent.EXTRA_TOOLBAR_COLOR), (Integer) bundle.get(CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_COLOR), (Integer) bundle.get(CustomTabsIntent.EXTRA_NAVIGATION_BAR_COLOR), (Integer) bundle.get(CustomTabsIntent.EXTRA_NAVIGATION_BAR_DIVIDER_COLOR));
}
@NonNull
public CustomTabColorSchemeParams withDefaults(@NonNull CustomTabColorSchemeParams customTabColorSchemeParams) {
Integer num = this.toolbarColor;
if (num == null) {
num = customTabColorSchemeParams.toolbarColor;
}
Integer num2 = this.secondaryToolbarColor;
if (num2 == null) {
num2 = customTabColorSchemeParams.secondaryToolbarColor;
}
Integer num3 = this.navigationBarColor;
if (num3 == null) {
num3 = customTabColorSchemeParams.navigationBarColor;
}
Integer num4 = this.navigationBarDividerColor;
if (num4 == null) {
num4 = customTabColorSchemeParams.navigationBarDividerColor;
}
return new CustomTabColorSchemeParams(num, num2, num3, num4);
}
public static final class Builder {
@Nullable
@ColorInt
private Integer mNavigationBarColor;
@Nullable
@ColorInt
private Integer mNavigationBarDividerColor;
@Nullable
@ColorInt
private Integer mSecondaryToolbarColor;
@Nullable
@ColorInt
private Integer mToolbarColor;
@NonNull
public Builder setToolbarColor(@ColorInt int i) {
this.mToolbarColor = Integer.valueOf(i | ViewCompat.MEASURED_STATE_MASK);
return this;
}
@NonNull
public Builder setSecondaryToolbarColor(@ColorInt int i) {
this.mSecondaryToolbarColor = Integer.valueOf(i);
return this;
}
@NonNull
public Builder setNavigationBarColor(@ColorInt int i) {
this.mNavigationBarColor = Integer.valueOf(i | ViewCompat.MEASURED_STATE_MASK);
return this;
}
@NonNull
public Builder setNavigationBarDividerColor(@ColorInt int i) {
this.mNavigationBarDividerColor = Integer.valueOf(i);
return this;
}
@NonNull
public CustomTabColorSchemeParams build() {
return new CustomTabColorSchemeParams(this.mToolbarColor, this.mSecondaryToolbarColor, this.mNavigationBarColor, this.mNavigationBarDividerColor);
}
}
}

View File

@@ -0,0 +1,71 @@
package androidx.browser.customtabs;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.Dimension;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes.dex */
public class CustomTabsCallback {
public static final int ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET = 1;
public static final int ACTIVITY_LAYOUT_STATE_BOTTOM_SHEET_MAXIMIZED = 2;
public static final int ACTIVITY_LAYOUT_STATE_FULL_SCREEN = 5;
public static final int ACTIVITY_LAYOUT_STATE_SIDE_SHEET = 3;
public static final int ACTIVITY_LAYOUT_STATE_SIDE_SHEET_MAXIMIZED = 4;
public static final int ACTIVITY_LAYOUT_STATE_UNKNOWN = 0;
public static final int NAVIGATION_ABORTED = 4;
public static final int NAVIGATION_FAILED = 3;
public static final int NAVIGATION_FINISHED = 2;
public static final int NAVIGATION_STARTED = 1;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ONLINE_EXTRAS_KEY = "online";
public static final int TAB_HIDDEN = 6;
public static final int TAB_SHOWN = 5;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ActivityLayoutState {
}
public void extraCallback(@NonNull String str, @Nullable Bundle bundle) {
}
@Nullable
public Bundle extraCallbackWithResult(@NonNull String str, @Nullable Bundle bundle) {
return null;
}
public void onActivityLayout(@Dimension(unit = 1) int i, @Dimension(unit = 1) int i2, @Dimension(unit = 1) int i3, @Dimension(unit = 1) int i4, int i5, @NonNull Bundle bundle) {
}
public void onActivityResized(@Dimension(unit = 1) int i, @Dimension(unit = 1) int i2, @NonNull Bundle bundle) {
}
public void onMessageChannelReady(@Nullable Bundle bundle) {
}
@ExperimentalMinimizationCallback
public void onMinimized(@NonNull Bundle bundle) {
}
public void onNavigationEvent(int i, @Nullable Bundle bundle) {
}
public void onPostMessage(@NonNull String str, @Nullable Bundle bundle) {
}
public void onRelationshipValidationResult(int i, @NonNull Uri uri, boolean z, @Nullable Bundle bundle) {
}
@ExperimentalMinimizationCallback
public void onUnminimized(@NonNull Bundle bundle) {
}
public void onWarmupCompleted(@NonNull Bundle bundle) {
}
}

View File

@@ -0,0 +1,322 @@
package androidx.browser.customtabs;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.browser.customtabs.CustomTabsSession;
import androidx.core.view.accessibility.AccessibilityEventCompat;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public class CustomTabsClient {
private static final String TAG = "CustomTabsClient";
private final Context mApplicationContext;
private final ICustomTabsService mService;
private final ComponentName mServiceComponentName;
public CustomTabsClient(ICustomTabsService iCustomTabsService, ComponentName componentName, Context context) {
this.mService = iCustomTabsService;
this.mServiceComponentName = componentName;
this.mApplicationContext = context;
}
public static boolean bindCustomTabsService(@NonNull Context context, @Nullable String str, @NonNull CustomTabsServiceConnection customTabsServiceConnection) {
customTabsServiceConnection.setApplicationContext(context.getApplicationContext());
Intent intent = new Intent(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
if (!TextUtils.isEmpty(str)) {
intent.setPackage(str);
}
return context.bindService(intent, customTabsServiceConnection, 33);
}
public static boolean bindCustomTabsServicePreservePriority(@NonNull Context context, @Nullable String str, @NonNull CustomTabsServiceConnection customTabsServiceConnection) {
customTabsServiceConnection.setApplicationContext(context.getApplicationContext());
Intent intent = new Intent(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
if (!TextUtils.isEmpty(str)) {
intent.setPackage(str);
}
return context.bindService(intent, customTabsServiceConnection, 1);
}
@Nullable
public static String getPackageName(@NonNull Context context, @Nullable List<String> list) {
return getPackageName(context, list, false);
}
@Nullable
public static String getPackageName(@NonNull Context context, @Nullable List<String> list, boolean z) {
ResolveInfo resolveActivity;
PackageManager packageManager = context.getPackageManager();
List<String> arrayList = list == null ? new ArrayList<>() : list;
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://"));
if (!z && (resolveActivity = packageManager.resolveActivity(intent, 0)) != null) {
String str = resolveActivity.activityInfo.packageName;
ArrayList arrayList2 = new ArrayList(arrayList.size() + 1);
arrayList2.add(str);
if (list != null) {
arrayList2.addAll(list);
}
arrayList = arrayList2;
}
Intent intent2 = new Intent(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
for (String str2 : arrayList) {
intent2.setPackage(str2);
if (packageManager.resolveService(intent2, 0) != null) {
return str2;
}
}
if (Build.VERSION.SDK_INT < 30) {
return null;
}
Log.w(TAG, "Unable to find any Custom Tabs packages, you may need to add a <queries> element to your manifest. See the docs for CustomTabsClient#getPackageName.");
return null;
}
public static boolean connectAndInitialize(@NonNull Context context, @NonNull String str) {
if (str == null) {
return false;
}
final Context applicationContext = context.getApplicationContext();
try {
return bindCustomTabsService(applicationContext, str, new CustomTabsServiceConnection() { // from class: androidx.browser.customtabs.CustomTabsClient.1
@Override // android.content.ServiceConnection
public void onServiceDisconnected(ComponentName componentName) {
}
@Override // androidx.browser.customtabs.CustomTabsServiceConnection
public final void onCustomTabsServiceConnected(@NonNull ComponentName componentName, @NonNull CustomTabsClient customTabsClient) {
customTabsClient.warmup(0L);
applicationContext.unbindService(this);
}
});
} catch (SecurityException unused) {
return false;
}
}
public boolean warmup(long j) {
try {
return this.mService.warmup(j);
} catch (RemoteException unused) {
return false;
}
}
private static PendingIntent createSessionId(Context context, int i) {
return PendingIntent.getActivity(context, i, new Intent(), AccessibilityEventCompat.TYPE_VIEW_TARGETED_BY_SCROLL);
}
@Nullable
public CustomTabsSession newSession(@Nullable CustomTabsCallback customTabsCallback) {
return newSessionInternal(customTabsCallback, null);
}
@Nullable
public CustomTabsSession newSession(@Nullable CustomTabsCallback customTabsCallback, int i) {
return newSessionInternal(customTabsCallback, createSessionId(this.mApplicationContext, i));
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static CustomTabsSession.PendingSession newPendingSession(@NonNull Context context, @Nullable CustomTabsCallback customTabsCallback, int i) {
return new CustomTabsSession.PendingSession(customTabsCallback, createSessionId(context, i));
}
@Nullable
private CustomTabsSession newSessionInternal(@Nullable CustomTabsCallback customTabsCallback, @Nullable PendingIntent pendingIntent) {
boolean newSession;
ICustomTabsCallback.Stub createCallbackWrapper = createCallbackWrapper(customTabsCallback);
try {
if (pendingIntent != null) {
Bundle bundle = new Bundle();
bundle.putParcelable(CustomTabsIntent.EXTRA_SESSION_ID, pendingIntent);
newSession = this.mService.newSessionWithExtras(createCallbackWrapper, bundle);
} else {
newSession = this.mService.newSession(createCallbackWrapper);
}
if (newSession) {
return new CustomTabsSession(this.mService, createCallbackWrapper, this.mServiceComponentName, pendingIntent);
}
return null;
} catch (RemoteException unused) {
return null;
}
}
@Nullable
public Bundle extraCommand(@NonNull String str, @Nullable Bundle bundle) {
try {
return this.mService.extraCommand(str, bundle);
} catch (RemoteException unused) {
return null;
}
}
private ICustomTabsCallback.Stub createCallbackWrapper(@Nullable final CustomTabsCallback customTabsCallback) {
return new ICustomTabsCallback.Stub() { // from class: androidx.browser.customtabs.CustomTabsClient.2
private Handler mHandler = new Handler(Looper.getMainLooper());
@Override // android.support.customtabs.ICustomTabsCallback
public void onNavigationEvent(final int i, final Bundle bundle) {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.1
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onNavigationEvent(i, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void extraCallback(final String str, final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.2
@Override // java.lang.Runnable
public void run() {
customTabsCallback.extraCallback(str, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public Bundle extraCallbackWithResult(@NonNull String str, @Nullable Bundle bundle) throws RemoteException {
CustomTabsCallback customTabsCallback2 = customTabsCallback;
if (customTabsCallback2 == null) {
return null;
}
return customTabsCallback2.extraCallbackWithResult(str, bundle);
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onMessageChannelReady(final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.3
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onMessageChannelReady(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onPostMessage(final String str, final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.4
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onPostMessage(str, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onRelationshipValidationResult(final int i, final Uri uri, final boolean z, @Nullable final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.5
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onRelationshipValidationResult(i, uri, z, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onActivityResized(final int i, final int i2, @Nullable final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.6
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onActivityResized(i, i2, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onWarmupCompleted(@NonNull final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.7
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onWarmupCompleted(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onActivityLayout(final int i, final int i2, final int i3, final int i4, final int i5, @NonNull final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.8
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onActivityLayout(i, i2, i3, i4, i5, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onMinimized(@NonNull final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.9
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onMinimized(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onUnminimized(@NonNull final Bundle bundle) throws RemoteException {
if (customTabsCallback == null) {
return;
}
this.mHandler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.2.10
@Override // java.lang.Runnable
public void run() {
customTabsCallback.onUnminimized(bundle);
}
});
}
};
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public CustomTabsSession attachSession(@NonNull CustomTabsSession.PendingSession pendingSession) {
return newSessionInternal(pendingSession.getCallback(), pendingSession.getId());
}
}

View File

@@ -0,0 +1,22 @@
package androidx.browser.customtabs;
import androidx.annotation.RestrictTo;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class CustomTabsFeatures {
public static final String ENGAGEMENT_SIGNALS = "ENGAGEMENT_SIGNALS";
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface CustomTabsFeature {
}
private CustomTabsFeatures() {
}
}

View File

@@ -0,0 +1,771 @@
package androidx.browser.customtabs;
import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.LocaleList;
import android.text.TextUtils;
import android.util.SparseArray;
import android.widget.RemoteViews;
import androidx.annotation.AnimRes;
import androidx.annotation.ColorInt;
import androidx.annotation.Dimension;
import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsSession;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import com.google.android.gms.drive.DriveFile;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Locale;
/* loaded from: classes.dex */
public final class CustomTabsIntent {
public static final int ACTIVITY_HEIGHT_ADJUSTABLE = 1;
public static final int ACTIVITY_HEIGHT_DEFAULT = 0;
public static final int ACTIVITY_HEIGHT_FIXED = 2;
private static final int ACTIVITY_HEIGHT_MAX = 2;
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DEFAULT = 0;
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_DIVIDER = 3;
private static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_MAX = 3;
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_NONE = 1;
public static final int ACTIVITY_SIDE_SHEET_DECORATION_TYPE_SHADOW = 2;
public static final int ACTIVITY_SIDE_SHEET_POSITION_DEFAULT = 0;
public static final int ACTIVITY_SIDE_SHEET_POSITION_END = 2;
private static final int ACTIVITY_SIDE_SHEET_POSITION_MAX = 2;
public static final int ACTIVITY_SIDE_SHEET_POSITION_START = 1;
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_DEFAULT = 0;
private static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_MAX = 2;
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_NONE = 1;
public static final int ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION_TOP = 2;
public static final int CLOSE_BUTTON_POSITION_DEFAULT = 0;
public static final int CLOSE_BUTTON_POSITION_END = 2;
private static final int CLOSE_BUTTON_POSITION_MAX = 2;
public static final int CLOSE_BUTTON_POSITION_START = 1;
public static final int COLOR_SCHEME_DARK = 2;
public static final int COLOR_SCHEME_LIGHT = 1;
private static final int COLOR_SCHEME_MAX = 2;
public static final int COLOR_SCHEME_SYSTEM = 0;
public static final String EXTRA_ACTION_BUTTON_BUNDLE = "android.support.customtabs.extra.ACTION_BUTTON_BUNDLE";
public static final String EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR = "androidx.browser.customtabs.extra.ACTIVITY_HEIGHT_RESIZE_BEHAVIOR";
public static final String EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_BREAKPOINT_DP";
public static final String EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_DECORATION_TYPE";
public static final String EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION";
public static final String EXTRA_ACTIVITY_SIDE_SHEET_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_POSITION";
public static final String EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION = "androidx.browser.customtabs.extra.ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION";
public static final String EXTRA_CLOSE_BUTTON_ICON = "android.support.customtabs.extra.CLOSE_BUTTON_ICON";
public static final String EXTRA_CLOSE_BUTTON_POSITION = "androidx.browser.customtabs.extra.CLOSE_BUTTON_POSITION";
public static final String EXTRA_COLOR_SCHEME = "androidx.browser.customtabs.extra.COLOR_SCHEME";
public static final String EXTRA_COLOR_SCHEME_PARAMS = "androidx.browser.customtabs.extra.COLOR_SCHEME_PARAMS";
@Deprecated
public static final String EXTRA_DEFAULT_SHARE_MENU_ITEM = "android.support.customtabs.extra.SHARE_MENU_ITEM";
public static final String EXTRA_DISABLE_BACKGROUND_INTERACTION = "androidx.browser.customtabs.extra.DISABLE_BACKGROUND_INTERACTION";
public static final String EXTRA_DISABLE_BOOKMARKS_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_STAR_BUTTON";
public static final String EXTRA_DISABLE_DOWNLOAD_BUTTON = "org.chromium.chrome.browser.customtabs.EXTRA_DISABLE_DOWNLOAD_BUTTON";
public static final String EXTRA_ENABLE_INSTANT_APPS = "android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS";
public static final String EXTRA_ENABLE_URLBAR_HIDING = "android.support.customtabs.extra.ENABLE_URLBAR_HIDING";
public static final String EXTRA_EXIT_ANIMATION_BUNDLE = "android.support.customtabs.extra.EXIT_ANIMATION_BUNDLE";
public static final String EXTRA_INITIAL_ACTIVITY_HEIGHT_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_HEIGHT_PX";
public static final String EXTRA_INITIAL_ACTIVITY_WIDTH_PX = "androidx.browser.customtabs.extra.INITIAL_ACTIVITY_WIDTH_PX";
public static final String EXTRA_MENU_ITEMS = "android.support.customtabs.extra.MENU_ITEMS";
public static final String EXTRA_NAVIGATION_BAR_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR";
public static final String EXTRA_NAVIGATION_BAR_DIVIDER_COLOR = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR";
public static final String EXTRA_REMOTEVIEWS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS";
public static final String EXTRA_REMOTEVIEWS_CLICKED_ID = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_CLICKED_ID";
public static final String EXTRA_REMOTEVIEWS_PENDINGINTENT = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_PENDINGINTENT";
public static final String EXTRA_REMOTEVIEWS_VIEW_IDS = "android.support.customtabs.extra.EXTRA_REMOTEVIEWS_VIEW_IDS";
public static final String EXTRA_SECONDARY_TOOLBAR_COLOR = "android.support.customtabs.extra.SECONDARY_TOOLBAR_COLOR";
public static final String EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE = "androidx.browser.customtabs.extra.SECONDARY_TOOLBAR_SWIPE_UP_GESTURE";
public static final String EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER = "android.support.customtabs.extra.SEND_TO_EXTERNAL_HANDLER";
public static final String EXTRA_SESSION = "android.support.customtabs.extra.SESSION";
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String EXTRA_SESSION_ID = "android.support.customtabs.extra.SESSION_ID";
public static final String EXTRA_SHARE_STATE = "androidx.browser.customtabs.extra.SHARE_STATE";
public static final String EXTRA_TINT_ACTION_BUTTON = "android.support.customtabs.extra.TINT_ACTION_BUTTON";
public static final String EXTRA_TITLE_VISIBILITY_STATE = "android.support.customtabs.extra.TITLE_VISIBILITY";
public static final String EXTRA_TOOLBAR_COLOR = "android.support.customtabs.extra.TOOLBAR_COLOR";
public static final String EXTRA_TOOLBAR_CORNER_RADIUS_DP = "androidx.browser.customtabs.extra.TOOLBAR_CORNER_RADIUS_DP";
public static final String EXTRA_TOOLBAR_ITEMS = "android.support.customtabs.extra.TOOLBAR_ITEMS";
public static final String EXTRA_TRANSLATE_LANGUAGE_TAG = "androidx.browser.customtabs.extra.TRANSLATE_LANGUAGE_TAG";
private static final String EXTRA_USER_OPT_OUT_FROM_CUSTOM_TABS = "android.support.customtabs.extra.user_opt_out";
private static final String HTTP_ACCEPT_LANGUAGE = "Accept-Language";
public static final String KEY_DESCRIPTION = "android.support.customtabs.customaction.DESCRIPTION";
public static final String KEY_ICON = "android.support.customtabs.customaction.ICON";
public static final String KEY_ID = "android.support.customtabs.customaction.ID";
public static final String KEY_MENU_ITEM_TITLE = "android.support.customtabs.customaction.MENU_ITEM_TITLE";
public static final String KEY_PENDING_INTENT = "android.support.customtabs.customaction.PENDING_INTENT";
private static final int MAX_TOOLBAR_CORNER_RADIUS_DP = 16;
private static final int MAX_TOOLBAR_ITEMS = 5;
public static final int NO_TITLE = 0;
public static final int SHARE_STATE_DEFAULT = 0;
private static final int SHARE_STATE_MAX = 2;
public static final int SHARE_STATE_OFF = 2;
public static final int SHARE_STATE_ON = 1;
public static final int SHOW_PAGE_TITLE = 1;
public static final int TOOLBAR_ACTION_BUTTON_ID = 0;
@NonNull
public final Intent intent;
@Nullable
public final Bundle startAnimationBundle;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ActivityHeightResizeBehavior {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ActivitySideSheetDecorationType {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ActivitySideSheetPosition {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ActivitySideSheetRoundedCornersPosition {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface CloseButtonPosition {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ColorScheme {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ShareState {
}
public static int getMaxToolbarItems() {
return 5;
}
public void launchUrl(@NonNull Context context, @NonNull Uri uri) {
this.intent.setData(uri);
ContextCompat.startActivity(context, this.intent, this.startAnimationBundle);
}
public CustomTabsIntent(@NonNull Intent intent, @Nullable Bundle bundle) {
this.intent = intent;
this.startAnimationBundle = bundle;
}
public static final class Builder {
@Nullable
private ArrayList<Bundle> mActionButtons;
@Nullable
private ActivityOptions mActivityOptions;
@Nullable
private SparseArray<Bundle> mColorSchemeParamBundles;
@Nullable
private Bundle mDefaultColorSchemeBundle;
@Nullable
private ArrayList<Bundle> mMenuItems;
private boolean mShareIdentity;
private final Intent mIntent = new Intent("android.intent.action.VIEW");
private final CustomTabColorSchemeParams.Builder mDefaultColorSchemeBuilder = new CustomTabColorSchemeParams.Builder();
private int mShareState = 0;
private boolean mInstantAppsEnabled = true;
@NonNull
public Builder setInstantAppsEnabled(boolean z) {
this.mInstantAppsEnabled = z;
return this;
}
@NonNull
public Builder setShareIdentityEnabled(boolean z) {
this.mShareIdentity = z;
return this;
}
public Builder() {
}
public Builder(@Nullable CustomTabsSession customTabsSession) {
if (customTabsSession != null) {
setSession(customTabsSession);
}
}
@NonNull
public Builder setSession(@NonNull CustomTabsSession customTabsSession) {
this.mIntent.setPackage(customTabsSession.getComponentName().getPackageName());
setSessionParameters(customTabsSession.getBinder(), customTabsSession.getId());
return this;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Builder setPendingSession(@NonNull CustomTabsSession.PendingSession pendingSession) {
setSessionParameters(null, pendingSession.getId());
return this;
}
private void setSessionParameters(@Nullable IBinder iBinder, @Nullable PendingIntent pendingIntent) {
Bundle bundle = new Bundle();
bundle.putBinder(CustomTabsIntent.EXTRA_SESSION, iBinder);
if (pendingIntent != null) {
bundle.putParcelable(CustomTabsIntent.EXTRA_SESSION_ID, pendingIntent);
}
this.mIntent.putExtras(bundle);
}
@NonNull
@Deprecated
public Builder setToolbarColor(@ColorInt int i) {
this.mDefaultColorSchemeBuilder.setToolbarColor(i);
return this;
}
@NonNull
@Deprecated
public Builder enableUrlBarHiding() {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ENABLE_URLBAR_HIDING, true);
return this;
}
@NonNull
public Builder setUrlBarHidingEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ENABLE_URLBAR_HIDING, z);
return this;
}
@NonNull
public Builder setCloseButtonIcon(@NonNull Bitmap bitmap) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_CLOSE_BUTTON_ICON, bitmap);
return this;
}
@NonNull
public Builder setShowTitle(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, z ? 1 : 0);
return this;
}
@NonNull
public Builder addMenuItem(@NonNull String str, @NonNull PendingIntent pendingIntent) {
if (this.mMenuItems == null) {
this.mMenuItems = new ArrayList<>();
}
Bundle bundle = new Bundle();
bundle.putString(CustomTabsIntent.KEY_MENU_ITEM_TITLE, str);
bundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pendingIntent);
this.mMenuItems.add(bundle);
return this;
}
@NonNull
@Deprecated
public Builder addDefaultShareMenuItem() {
setShareState(1);
return this;
}
@NonNull
@Deprecated
public Builder setDefaultShareMenuItemEnabled(boolean z) {
if (z) {
setShareState(1);
} else {
setShareState(2);
}
return this;
}
@NonNull
public Builder setShareState(int i) {
if (i < 0 || i > 2) {
throw new IllegalArgumentException("Invalid value for the shareState argument");
}
this.mShareState = i;
if (i == 1) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM, true);
} else if (i == 2) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM, false);
} else {
this.mIntent.removeExtra(CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM);
}
return this;
}
@NonNull
public Builder setActionButton(@NonNull Bitmap bitmap, @NonNull String str, @NonNull PendingIntent pendingIntent, boolean z) {
Bundle bundle = new Bundle();
bundle.putInt(CustomTabsIntent.KEY_ID, 0);
bundle.putParcelable(CustomTabsIntent.KEY_ICON, bitmap);
bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, str);
bundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pendingIntent);
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, bundle);
this.mIntent.putExtra(CustomTabsIntent.EXTRA_TINT_ACTION_BUTTON, z);
return this;
}
@NonNull
public Builder setActionButton(@NonNull Bitmap bitmap, @NonNull String str, @NonNull PendingIntent pendingIntent) {
return setActionButton(bitmap, str, pendingIntent, false);
}
@NonNull
@Deprecated
public Builder addToolbarItem(int i, @NonNull Bitmap bitmap, @NonNull String str, @NonNull PendingIntent pendingIntent) throws IllegalStateException {
if (this.mActionButtons == null) {
this.mActionButtons = new ArrayList<>();
}
if (this.mActionButtons.size() >= 5) {
throw new IllegalStateException("Exceeded maximum toolbar item count of 5");
}
Bundle bundle = new Bundle();
bundle.putInt(CustomTabsIntent.KEY_ID, i);
bundle.putParcelable(CustomTabsIntent.KEY_ICON, bitmap);
bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, str);
bundle.putParcelable(CustomTabsIntent.KEY_PENDING_INTENT, pendingIntent);
this.mActionButtons.add(bundle);
return this;
}
@NonNull
@Deprecated
public Builder setSecondaryToolbarColor(@ColorInt int i) {
this.mDefaultColorSchemeBuilder.setSecondaryToolbarColor(i);
return this;
}
@NonNull
@Deprecated
public Builder setNavigationBarColor(@ColorInt int i) {
this.mDefaultColorSchemeBuilder.setNavigationBarColor(i);
return this;
}
@NonNull
@Deprecated
public Builder setNavigationBarDividerColor(@ColorInt int i) {
this.mDefaultColorSchemeBuilder.setNavigationBarDividerColor(i);
return this;
}
@NonNull
public Builder setSecondaryToolbarViews(@NonNull RemoteViews remoteViews, @Nullable int[] iArr, @Nullable PendingIntent pendingIntent) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_REMOTEVIEWS, remoteViews);
this.mIntent.putExtra(CustomTabsIntent.EXTRA_REMOTEVIEWS_VIEW_IDS, iArr);
this.mIntent.putExtra(CustomTabsIntent.EXTRA_REMOTEVIEWS_PENDINGINTENT, pendingIntent);
return this;
}
@NonNull
public Builder setSecondaryToolbarSwipeUpGesture(@Nullable PendingIntent pendingIntent) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE, pendingIntent);
return this;
}
@NonNull
public Builder setStartAnimations(@NonNull Context context, @AnimRes int i, @AnimRes int i2) {
this.mActivityOptions = ActivityOptions.makeCustomAnimation(context, i, i2);
return this;
}
@NonNull
public Builder setExitAnimations(@NonNull Context context, @AnimRes int i, @AnimRes int i2) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_EXIT_ANIMATION_BUNDLE, ActivityOptionsCompat.makeCustomAnimation(context, i, i2).toBundle());
return this;
}
@NonNull
public Builder setColorScheme(int i) {
if (i < 0 || i > 2) {
throw new IllegalArgumentException("Invalid value for the colorScheme argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_COLOR_SCHEME, i);
return this;
}
@NonNull
public Builder setColorSchemeParams(int i, @NonNull CustomTabColorSchemeParams customTabColorSchemeParams) {
if (i < 0 || i > 2 || i == 0) {
throw new IllegalArgumentException("Invalid colorScheme: " + i);
}
if (this.mColorSchemeParamBundles == null) {
this.mColorSchemeParamBundles = new SparseArray<>();
}
this.mColorSchemeParamBundles.put(i, customTabColorSchemeParams.toBundle());
return this;
}
@NonNull
public Builder setDefaultColorSchemeParams(@NonNull CustomTabColorSchemeParams customTabColorSchemeParams) {
this.mDefaultColorSchemeBundle = customTabColorSchemeParams.toBundle();
return this;
}
@NonNull
public Builder setInitialActivityHeightPx(@Dimension(unit = 1) int i, int i2) {
if (i <= 0) {
throw new IllegalArgumentException("Invalid value for the initialHeightPx argument");
}
if (i2 < 0 || i2 > 2) {
throw new IllegalArgumentException("Invalid value for the activityHeightResizeBehavior argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_INITIAL_ACTIVITY_HEIGHT_PX, i);
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR, i2);
return this;
}
@NonNull
public Builder setInitialActivityHeightPx(@Dimension(unit = 1) int i) {
return setInitialActivityHeightPx(i, 0);
}
@NonNull
public Builder setInitialActivityWidthPx(@Dimension(unit = 1) int i) {
if (i <= 0) {
throw new IllegalArgumentException("Invalid value for the initialWidthPx argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_INITIAL_ACTIVITY_WIDTH_PX, i);
return this;
}
@NonNull
public Builder setActivitySideSheetBreakpointDp(@Dimension(unit = 0) int i) {
if (i <= 0) {
throw new IllegalArgumentException("Invalid value for the initialWidthPx argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP, i);
return this;
}
@NonNull
public Builder setActivitySideSheetMaximizationEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION, z);
return this;
}
@NonNull
public Builder setActivitySideSheetPosition(int i) {
if (i < 0 || i > 2) {
throw new IllegalArgumentException("Invalid value for the sideSheetPosition argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_SIDE_SHEET_POSITION, i);
return this;
}
@NonNull
public Builder setActivitySideSheetDecorationType(int i) {
if (i < 0 || i > 3) {
throw new IllegalArgumentException("Invalid value for the decorationType argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE, i);
return this;
}
@NonNull
public Builder setActivitySideSheetRoundedCornersPosition(int i) {
if (i < 0 || i > 2) {
throw new IllegalArgumentException("Invalid value for the roundedCornersPosition./ argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION, i);
return this;
}
@NonNull
public Builder setToolbarCornerRadiusDp(@Dimension(unit = 0) int i) {
if (i < 0 || i > 16) {
throw new IllegalArgumentException("Invalid value for the cornerRadiusDp argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_TOOLBAR_CORNER_RADIUS_DP, i);
return this;
}
@NonNull
public Builder setCloseButtonPosition(int i) {
if (i < 0 || i > 2) {
throw new IllegalArgumentException("Invalid value for the position argument");
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_CLOSE_BUTTON_POSITION, i);
return this;
}
@NonNull
public Builder setBookmarksButtonEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_DISABLE_BOOKMARKS_BUTTON, !z);
return this;
}
@NonNull
public Builder setDownloadButtonEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_DISABLE_DOWNLOAD_BUTTON, !z);
return this;
}
@NonNull
public Builder setSendToExternalDefaultHandlerEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER, z);
return this;
}
@NonNull
public Builder setTranslateLocale(@NonNull Locale locale) {
setLanguageTag(locale);
return this;
}
@NonNull
public Builder setBackgroundInteractionEnabled(boolean z) {
this.mIntent.putExtra(CustomTabsIntent.EXTRA_DISABLE_BACKGROUND_INTERACTION, !z);
return this;
}
@NonNull
public CustomTabsIntent build() {
if (!this.mIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION)) {
setSessionParameters(null, null);
}
ArrayList<Bundle> arrayList = this.mMenuItems;
if (arrayList != null) {
this.mIntent.putParcelableArrayListExtra(CustomTabsIntent.EXTRA_MENU_ITEMS, arrayList);
}
ArrayList<Bundle> arrayList2 = this.mActionButtons;
if (arrayList2 != null) {
this.mIntent.putParcelableArrayListExtra(CustomTabsIntent.EXTRA_TOOLBAR_ITEMS, arrayList2);
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_ENABLE_INSTANT_APPS, this.mInstantAppsEnabled);
this.mIntent.putExtras(this.mDefaultColorSchemeBuilder.build().toBundle());
Bundle bundle = this.mDefaultColorSchemeBundle;
if (bundle != null) {
this.mIntent.putExtras(bundle);
}
if (this.mColorSchemeParamBundles != null) {
Bundle bundle2 = new Bundle();
bundle2.putSparseParcelableArray(CustomTabsIntent.EXTRA_COLOR_SCHEME_PARAMS, this.mColorSchemeParamBundles);
this.mIntent.putExtras(bundle2);
}
this.mIntent.putExtra(CustomTabsIntent.EXTRA_SHARE_STATE, this.mShareState);
int i = Build.VERSION.SDK_INT;
setCurrentLocaleAsDefaultAcceptLanguage();
if (i >= 34) {
setShareIdentityEnabled();
}
ActivityOptions activityOptions = this.mActivityOptions;
return new CustomTabsIntent(this.mIntent, activityOptions != null ? activityOptions.toBundle() : null);
}
@RequiresApi(api = 24)
private void setCurrentLocaleAsDefaultAcceptLanguage() {
String defaultLocale = Api24Impl.getDefaultLocale();
if (TextUtils.isEmpty(defaultLocale)) {
return;
}
Bundle bundleExtra = this.mIntent.hasExtra("com.android.browser.headers") ? this.mIntent.getBundleExtra("com.android.browser.headers") : new Bundle();
if (bundleExtra.containsKey(CustomTabsIntent.HTTP_ACCEPT_LANGUAGE)) {
return;
}
bundleExtra.putString(CustomTabsIntent.HTTP_ACCEPT_LANGUAGE, defaultLocale);
this.mIntent.putExtra("com.android.browser.headers", bundleExtra);
}
@RequiresApi(api = 24)
private void setLanguageTag(@NonNull Locale locale) {
Api21Impl.setLanguageTag(this.mIntent, locale);
}
@RequiresApi(api = 34)
private void setShareIdentityEnabled() {
if (this.mActivityOptions == null) {
this.mActivityOptions = Api23Impl.makeBasicActivityOptions();
}
Api34Impl.setShareIdentityEnabled(this.mActivityOptions, this.mShareIdentity);
}
}
@NonNull
public static Intent setAlwaysUseBrowserUI(@Nullable Intent intent) {
if (intent == null) {
intent = new Intent("android.intent.action.VIEW");
}
intent.addFlags(DriveFile.MODE_READ_ONLY);
intent.putExtra(EXTRA_USER_OPT_OUT_FROM_CUSTOM_TABS, true);
return intent;
}
public static boolean shouldAlwaysUseBrowserUI(@NonNull Intent intent) {
return intent.getBooleanExtra(EXTRA_USER_OPT_OUT_FROM_CUSTOM_TABS, false) && (intent.getFlags() & DriveFile.MODE_READ_ONLY) != 0;
}
@NonNull
public static CustomTabColorSchemeParams getColorSchemeParams(@NonNull Intent intent, int i) {
Bundle bundle;
if (i < 0 || i > 2 || i == 0) {
throw new IllegalArgumentException("Invalid colorScheme: " + i);
}
Bundle extras = intent.getExtras();
if (extras == null) {
return CustomTabColorSchemeParams.fromBundle(null);
}
CustomTabColorSchemeParams fromBundle = CustomTabColorSchemeParams.fromBundle(extras);
SparseArray sparseParcelableArray = extras.getSparseParcelableArray(EXTRA_COLOR_SCHEME_PARAMS);
return (sparseParcelableArray == null || (bundle = (Bundle) sparseParcelableArray.get(i)) == null) ? fromBundle : CustomTabColorSchemeParams.fromBundle(bundle).withDefaults(fromBundle);
}
public static int getActivityResizeBehavior(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_ACTIVITY_HEIGHT_RESIZE_BEHAVIOR, 0);
}
@Dimension(unit = 1)
public static int getInitialActivityHeightPx(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_INITIAL_ACTIVITY_HEIGHT_PX, 0);
}
@Dimension(unit = 1)
public static int getInitialActivityWidthPx(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_INITIAL_ACTIVITY_WIDTH_PX, 0);
}
@Dimension(unit = 0)
public static int getActivitySideSheetBreakpointDp(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_ACTIVITY_SIDE_SHEET_BREAKPOINT_DP, 0);
}
public static boolean isActivitySideSheetMaximizationEnabled(@NonNull Intent intent) {
return intent.getBooleanExtra(EXTRA_ACTIVITY_SIDE_SHEET_ENABLE_MAXIMIZATION, false);
}
public static int getActivitySideSheetPosition(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_ACTIVITY_SIDE_SHEET_POSITION, 0);
}
public static int getActivitySideSheetDecorationType(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_ACTIVITY_SIDE_SHEET_DECORATION_TYPE, 0);
}
public static int getActivitySideSheetRoundedCornersPosition(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_ACTIVITY_SIDE_SHEET_ROUNDED_CORNERS_POSITION, 0);
}
@Dimension(unit = 0)
public static int getToolbarCornerRadiusDp(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_TOOLBAR_CORNER_RADIUS_DP, 16);
}
public static int getCloseButtonPosition(@NonNull Intent intent) {
return intent.getIntExtra(EXTRA_CLOSE_BUTTON_POSITION, 0);
}
public static boolean isBookmarksButtonEnabled(@NonNull Intent intent) {
return !intent.getBooleanExtra(EXTRA_DISABLE_BOOKMARKS_BUTTON, false);
}
public static boolean isDownloadButtonEnabled(@NonNull Intent intent) {
return !intent.getBooleanExtra(EXTRA_DISABLE_DOWNLOAD_BUTTON, false);
}
public static boolean isSendToExternalDefaultHandlerEnabled(@NonNull Intent intent) {
return intent.getBooleanExtra(EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER, false);
}
@Nullable
public static Locale getTranslateLocale(@NonNull Intent intent) {
return getLocaleForLanguageTag(intent);
}
@Nullable
@RequiresApi(api = 24)
private static Locale getLocaleForLanguageTag(Intent intent) {
return Api21Impl.getLocaleForLanguageTag(intent);
}
public static boolean isBackgroundInteractionEnabled(@NonNull Intent intent) {
return !intent.getBooleanExtra(EXTRA_DISABLE_BACKGROUND_INTERACTION, false);
}
@Nullable
public static PendingIntent getSecondaryToolbarSwipeUpGesture(@NonNull Intent intent) {
return (PendingIntent) intent.getParcelableExtra(EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE);
}
@RequiresApi(api = 21)
public static class Api21Impl {
private Api21Impl() {
}
@DoNotInline
public static void setLanguageTag(Intent intent, Locale locale) {
intent.putExtra(CustomTabsIntent.EXTRA_TRANSLATE_LANGUAGE_TAG, locale.toLanguageTag());
}
@Nullable
@DoNotInline
public static Locale getLocaleForLanguageTag(Intent intent) {
String stringExtra = intent.getStringExtra(CustomTabsIntent.EXTRA_TRANSLATE_LANGUAGE_TAG);
if (stringExtra != null) {
return Locale.forLanguageTag(stringExtra);
}
return null;
}
}
@RequiresApi(api = 23)
public static class Api23Impl {
private Api23Impl() {
}
@DoNotInline
public static ActivityOptions makeBasicActivityOptions() {
return ActivityOptions.makeBasic();
}
}
@RequiresApi(api = 24)
public static class Api24Impl {
private Api24Impl() {
}
@Nullable
@DoNotInline
public static String getDefaultLocale() {
LocaleList adjustedDefault = LocaleList.getAdjustedDefault();
if (adjustedDefault.size() > 0) {
return adjustedDefault.get(0).toLanguageTag();
}
return null;
}
}
@RequiresApi(api = 34)
public static class Api34Impl {
private Api34Impl() {
}
@DoNotInline
public static void setShareIdentityEnabled(ActivityOptions activityOptions, boolean z) {
activityOptions.setShareIdentityEnabled(z);
}
}
}

View File

@@ -0,0 +1,229 @@
package androidx.browser.customtabs;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.browser.customtabs.CustomTabsService;
import androidx.collection.SimpleArrayMap;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
public abstract class CustomTabsService extends Service {
public static final String ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService";
public static final String CATEGORY_COLOR_SCHEME_CUSTOMIZATION = "androidx.browser.customtabs.category.ColorSchemeCustomization";
public static final String CATEGORY_NAVBAR_COLOR_CUSTOMIZATION = "androidx.browser.customtabs.category.NavBarColorCustomization";
public static final String CATEGORY_TRUSTED_WEB_ACTIVITY_IMMERSIVE_MODE = "androidx.browser.trusted.category.ImmersiveMode";
public static final String CATEGORY_WEB_SHARE_TARGET_V2 = "androidx.browser.trusted.category.WebShareTargetV2";
public static final int FILE_PURPOSE_TRUSTED_WEB_ACTIVITY_SPLASH_IMAGE = 1;
public static final String KEY_SUCCESS = "androidx.browser.customtabs.SUCCESS";
public static final String KEY_URL = "android.support.customtabs.otherurls.URL";
public static final int RELATION_HANDLE_ALL_URLS = 2;
public static final int RELATION_USE_AS_ORIGIN = 1;
public static final int RESULT_FAILURE_DISALLOWED = -1;
public static final int RESULT_FAILURE_MESSAGING_ERROR = -3;
public static final int RESULT_FAILURE_REMOTE_ERROR = -2;
public static final int RESULT_SUCCESS = 0;
private static final String TAG = "CustomTabsService";
public static final String TRUSTED_WEB_ACTIVITY_CATEGORY = "androidx.browser.trusted.category.TrustedWebActivities";
final SimpleArrayMap<IBinder, IBinder.DeathRecipient> mDeathRecipientMap = new SimpleArrayMap<>();
private ICustomTabsService.Stub mBinder = new AnonymousClass1();
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface FilePurpose {
}
@Retention(RetentionPolicy.SOURCE)
public @interface Relation {
}
@Retention(RetentionPolicy.SOURCE)
public @interface Result {
}
@Nullable
public abstract Bundle extraCommand(@NonNull String str, @Nullable Bundle bundle);
public boolean isEngagementSignalsApiAvailable(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull Bundle bundle) {
return false;
}
public abstract boolean mayLaunchUrl(@NonNull CustomTabsSessionToken customTabsSessionToken, @Nullable Uri uri, @Nullable Bundle bundle, @Nullable List<Bundle> list);
public abstract boolean newSession(@NonNull CustomTabsSessionToken customTabsSessionToken);
@Override // android.app.Service
@NonNull
public IBinder onBind(@Nullable Intent intent) {
return this.mBinder;
}
public abstract int postMessage(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull String str, @Nullable Bundle bundle);
public abstract boolean receiveFile(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull Uri uri, int i, @Nullable Bundle bundle);
public abstract boolean requestPostMessageChannel(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull Uri uri);
public boolean setEngagementSignalsCallback(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull EngagementSignalsCallback engagementSignalsCallback, @NonNull Bundle bundle) {
return false;
}
public abstract boolean updateVisuals(@NonNull CustomTabsSessionToken customTabsSessionToken, @Nullable Bundle bundle);
public abstract boolean validateRelationship(@NonNull CustomTabsSessionToken customTabsSessionToken, int i, @NonNull Uri uri, @Nullable Bundle bundle);
public abstract boolean warmup(long j);
/* renamed from: androidx.browser.customtabs.CustomTabsService$1, reason: invalid class name */
public class AnonymousClass1 extends ICustomTabsService.Stub {
public AnonymousClass1() {
}
@Override // android.support.customtabs.ICustomTabsService
public boolean warmup(long j) {
return CustomTabsService.this.warmup(j);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean newSession(@NonNull ICustomTabsCallback iCustomTabsCallback) {
return newSessionInternal(iCustomTabsCallback, null);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean newSessionWithExtras(@NonNull ICustomTabsCallback iCustomTabsCallback, @Nullable Bundle bundle) {
return newSessionInternal(iCustomTabsCallback, getSessionIdFromBundle(bundle));
}
private boolean newSessionInternal(@NonNull ICustomTabsCallback iCustomTabsCallback, @Nullable PendingIntent pendingIntent) {
final CustomTabsSessionToken customTabsSessionToken = new CustomTabsSessionToken(iCustomTabsCallback, pendingIntent);
try {
IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() { // from class: androidx.browser.customtabs.CustomTabsService$1$$ExternalSyntheticLambda0
@Override // android.os.IBinder.DeathRecipient
public final void binderDied() {
CustomTabsService.AnonymousClass1.this.lambda$newSessionInternal$0(customTabsSessionToken);
}
};
synchronized (CustomTabsService.this.mDeathRecipientMap) {
iCustomTabsCallback.asBinder().linkToDeath(deathRecipient, 0);
CustomTabsService.this.mDeathRecipientMap.put(iCustomTabsCallback.asBinder(), deathRecipient);
}
return CustomTabsService.this.newSession(customTabsSessionToken);
} catch (RemoteException unused) {
return false;
}
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$newSessionInternal$0(CustomTabsSessionToken customTabsSessionToken) {
CustomTabsService.this.cleanUpSession(customTabsSessionToken);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean mayLaunchUrl(@Nullable ICustomTabsCallback iCustomTabsCallback, @Nullable Uri uri, @Nullable Bundle bundle, @Nullable List<Bundle> list) {
return CustomTabsService.this.mayLaunchUrl(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), uri, bundle, list);
}
@Override // android.support.customtabs.ICustomTabsService
public Bundle extraCommand(@NonNull String str, @Nullable Bundle bundle) {
return CustomTabsService.this.extraCommand(str, bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean updateVisuals(@NonNull ICustomTabsCallback iCustomTabsCallback, @Nullable Bundle bundle) {
return CustomTabsService.this.updateVisuals(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean requestPostMessageChannel(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull Uri uri) {
return CustomTabsService.this.requestPostMessageChannel(new CustomTabsSessionToken(iCustomTabsCallback, null), uri, null, new Bundle());
}
@Override // android.support.customtabs.ICustomTabsService
public boolean requestPostMessageChannelWithExtras(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull Uri uri, @NonNull Bundle bundle) {
return CustomTabsService.this.requestPostMessageChannel(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), uri, getTargetOriginFromBundle(bundle), bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public int postMessage(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull String str, @Nullable Bundle bundle) {
return CustomTabsService.this.postMessage(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), str, bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean validateRelationship(@NonNull ICustomTabsCallback iCustomTabsCallback, int i, @NonNull Uri uri, @Nullable Bundle bundle) {
return CustomTabsService.this.validateRelationship(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), i, uri, bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean receiveFile(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull Uri uri, int i, @Nullable Bundle bundle) {
return CustomTabsService.this.receiveFile(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), uri, i, bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean isEngagementSignalsApiAvailable(ICustomTabsCallback iCustomTabsCallback, @NonNull Bundle bundle) {
return CustomTabsService.this.isEngagementSignalsApiAvailable(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), bundle);
}
@Override // android.support.customtabs.ICustomTabsService
public boolean setEngagementSignalsCallback(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull IBinder iBinder, @NonNull Bundle bundle) {
return CustomTabsService.this.setEngagementSignalsCallback(new CustomTabsSessionToken(iCustomTabsCallback, getSessionIdFromBundle(bundle)), EngagementSignalsCallbackRemote.fromBinder(iBinder), bundle);
}
@Nullable
private PendingIntent getSessionIdFromBundle(@Nullable Bundle bundle) {
if (bundle == null) {
return null;
}
PendingIntent pendingIntent = (PendingIntent) bundle.getParcelable(CustomTabsIntent.EXTRA_SESSION_ID);
bundle.remove(CustomTabsIntent.EXTRA_SESSION_ID);
return pendingIntent;
}
@Nullable
private Uri getTargetOriginFromBundle(@Nullable Bundle bundle) {
if (bundle == null) {
return null;
}
if (Build.VERSION.SDK_INT >= 33) {
return (Uri) Api33Impl.getParcelable(bundle, "target_origin", Uri.class);
}
return (Uri) bundle.getParcelable("target_origin");
}
}
public boolean cleanUpSession(@NonNull CustomTabsSessionToken customTabsSessionToken) {
try {
synchronized (this.mDeathRecipientMap) {
try {
IBinder callbackBinder = customTabsSessionToken.getCallbackBinder();
if (callbackBinder == null) {
return false;
}
callbackBinder.unlinkToDeath(this.mDeathRecipientMap.get(callbackBinder), 0);
this.mDeathRecipientMap.remove(callbackBinder);
return true;
} catch (Throwable th) {
throw th;
}
}
} catch (NoSuchElementException unused) {
return false;
}
}
public boolean requestPostMessageChannel(@NonNull CustomTabsSessionToken customTabsSessionToken, @NonNull Uri uri, @Nullable Uri uri2, @NonNull Bundle bundle) {
return requestPostMessageChannel(customTabsSessionToken, uri);
}
}

View File

@@ -0,0 +1,39 @@
package androidx.browser.customtabs;
import android.content.ComponentName;
import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.customtabs.ICustomTabsService;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
/* loaded from: classes.dex */
public abstract class CustomTabsServiceConnection implements ServiceConnection {
@Nullable
private Context mApplicationContext;
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Context getApplicationContext() {
return this.mApplicationContext;
}
public abstract void onCustomTabsServiceConnected(@NonNull ComponentName componentName, @NonNull CustomTabsClient customTabsClient);
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void setApplicationContext(@NonNull Context context) {
this.mApplicationContext = context;
}
@Override // android.content.ServiceConnection
public final void onServiceConnected(@NonNull ComponentName componentName, @NonNull IBinder iBinder) {
if (this.mApplicationContext == null) {
throw new IllegalStateException("Custom Tabs Service connected before an applicationcontext has been provided.");
}
onCustomTabsServiceConnected(componentName, new CustomTabsClient(ICustomTabsService.Stub.asInterface(iBinder), componentName, this.mApplicationContext) { // from class: androidx.browser.customtabs.CustomTabsServiceConnection.1
});
}
}

View File

@@ -0,0 +1,441 @@
package androidx.browser.customtabs;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.support.customtabs.IEngagementSignalsCallback;
import android.widget.RemoteViews;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.browser.customtabs.CustomTabsSessionToken;
import java.util.List;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public final class CustomTabsSession {
private static final String TAG = "CustomTabsSession";
static final String TARGET_ORIGIN_KEY = "target_origin";
private final ICustomTabsCallback mCallback;
private final ComponentName mComponentName;
@Nullable
private final PendingIntent mId;
private final Object mLock = new Object();
private final ICustomTabsService mService;
public static class MockSession extends ICustomTabsService.Stub {
@Override // android.support.customtabs.ICustomTabsService
public Bundle extraCommand(String str, Bundle bundle) throws RemoteException {
return null;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean isEngagementSignalsApiAvailable(ICustomTabsCallback iCustomTabsCallback, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean mayLaunchUrl(ICustomTabsCallback iCustomTabsCallback, Uri uri, Bundle bundle, List<Bundle> list) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean newSession(ICustomTabsCallback iCustomTabsCallback) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean newSessionWithExtras(ICustomTabsCallback iCustomTabsCallback, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public int postMessage(ICustomTabsCallback iCustomTabsCallback, String str, Bundle bundle) throws RemoteException {
return 0;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean receiveFile(ICustomTabsCallback iCustomTabsCallback, Uri uri, int i, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean requestPostMessageChannel(ICustomTabsCallback iCustomTabsCallback, Uri uri) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean requestPostMessageChannelWithExtras(ICustomTabsCallback iCustomTabsCallback, Uri uri, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean setEngagementSignalsCallback(ICustomTabsCallback iCustomTabsCallback, IBinder iBinder, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean updateVisuals(ICustomTabsCallback iCustomTabsCallback, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean validateRelationship(ICustomTabsCallback iCustomTabsCallback, int i, Uri uri, Bundle bundle) throws RemoteException {
return false;
}
@Override // android.support.customtabs.ICustomTabsService
public boolean warmup(long j) throws RemoteException {
return false;
}
}
public ComponentName getComponentName() {
return this.mComponentName;
}
@Nullable
public PendingIntent getId() {
return this.mId;
}
@NonNull
@VisibleForTesting
public static CustomTabsSession createMockSessionForTesting(@NonNull ComponentName componentName) {
return new CustomTabsSession(new MockSession(), new CustomTabsSessionToken.MockCallback(), componentName, null);
}
public CustomTabsSession(ICustomTabsService iCustomTabsService, ICustomTabsCallback iCustomTabsCallback, ComponentName componentName, @Nullable PendingIntent pendingIntent) {
this.mService = iCustomTabsService;
this.mCallback = iCustomTabsCallback;
this.mComponentName = componentName;
this.mId = pendingIntent;
}
public boolean mayLaunchUrl(@Nullable Uri uri, @Nullable Bundle bundle, @Nullable List<Bundle> list) {
try {
return this.mService.mayLaunchUrl(this.mCallback, uri, createBundleWithId(bundle), list);
} catch (RemoteException unused) {
return false;
}
}
public boolean setActionButton(@NonNull Bitmap bitmap, @NonNull String str) {
Bundle bundle = new Bundle();
bundle.putParcelable(CustomTabsIntent.KEY_ICON, bitmap);
bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, str);
Bundle bundle2 = new Bundle();
bundle2.putBundle(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, bundle);
addIdToBundle(bundle);
try {
return this.mService.updateVisuals(this.mCallback, bundle2);
} catch (RemoteException unused) {
return false;
}
}
public boolean setSecondaryToolbarViews(@Nullable RemoteViews remoteViews, @Nullable int[] iArr, @Nullable PendingIntent pendingIntent) {
Bundle bundle = new Bundle();
bundle.putParcelable(CustomTabsIntent.EXTRA_REMOTEVIEWS, remoteViews);
bundle.putIntArray(CustomTabsIntent.EXTRA_REMOTEVIEWS_VIEW_IDS, iArr);
bundle.putParcelable(CustomTabsIntent.EXTRA_REMOTEVIEWS_PENDINGINTENT, pendingIntent);
addIdToBundle(bundle);
try {
return this.mService.updateVisuals(this.mCallback, bundle);
} catch (RemoteException unused) {
return false;
}
}
public boolean setSecondaryToolbarSwipeUpGesture(@Nullable PendingIntent pendingIntent) {
Bundle bundle = new Bundle();
bundle.putParcelable(CustomTabsIntent.EXTRA_SECONDARY_TOOLBAR_SWIPE_UP_GESTURE, pendingIntent);
addIdToBundle(bundle);
try {
return this.mService.updateVisuals(this.mCallback, bundle);
} catch (RemoteException unused) {
return false;
}
}
@Deprecated
public boolean setToolbarItem(int i, @NonNull Bitmap bitmap, @NonNull String str) {
Bundle bundle = new Bundle();
bundle.putInt(CustomTabsIntent.KEY_ID, i);
bundle.putParcelable(CustomTabsIntent.KEY_ICON, bitmap);
bundle.putString(CustomTabsIntent.KEY_DESCRIPTION, str);
Bundle bundle2 = new Bundle();
bundle2.putBundle(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, bundle);
addIdToBundle(bundle2);
try {
return this.mService.updateVisuals(this.mCallback, bundle2);
} catch (RemoteException unused) {
return false;
}
}
public boolean requestPostMessageChannel(@NonNull Uri uri) {
return requestPostMessageChannel(uri, null, new Bundle());
}
public boolean requestPostMessageChannel(@NonNull Uri uri, @Nullable Uri uri2, @NonNull Bundle bundle) {
try {
Bundle createPostMessageExtraBundle = createPostMessageExtraBundle(uri2);
if (createPostMessageExtraBundle != null) {
bundle.putAll(createPostMessageExtraBundle);
return this.mService.requestPostMessageChannelWithExtras(this.mCallback, uri, bundle);
}
return this.mService.requestPostMessageChannel(this.mCallback, uri);
} catch (RemoteException unused) {
return false;
}
}
public int postMessage(@NonNull String str, @Nullable Bundle bundle) {
int postMessage;
Bundle createBundleWithId = createBundleWithId(bundle);
synchronized (this.mLock) {
try {
try {
postMessage = this.mService.postMessage(this.mCallback, str, createBundleWithId);
} catch (RemoteException unused) {
return -2;
}
} catch (Throwable th) {
throw th;
}
}
return postMessage;
}
public boolean validateRelationship(int i, @NonNull Uri uri, @Nullable Bundle bundle) {
if (i >= 1 && i <= 2) {
try {
return this.mService.validateRelationship(this.mCallback, i, uri, createBundleWithId(bundle));
} catch (RemoteException unused) {
}
}
return false;
}
public boolean receiveFile(@NonNull Uri uri, int i, @Nullable Bundle bundle) {
try {
return this.mService.receiveFile(this.mCallback, uri, i, createBundleWithId(bundle));
} catch (RemoteException unused) {
return false;
}
}
public boolean isEngagementSignalsApiAvailable(@NonNull Bundle bundle) throws RemoteException {
try {
return this.mService.isEngagementSignalsApiAvailable(this.mCallback, createBundleWithId(bundle));
} catch (SecurityException e) {
throw new UnsupportedOperationException("This method isn't supported by the Custom Tabs implementation.", e);
}
}
public boolean setEngagementSignalsCallback(@NonNull EngagementSignalsCallback engagementSignalsCallback, @NonNull Bundle bundle) throws RemoteException {
try {
return this.mService.setEngagementSignalsCallback(this.mCallback, createEngagementSignalsCallbackWrapper(engagementSignalsCallback).asBinder(), createBundleWithId(bundle));
} catch (SecurityException e) {
throw new UnsupportedOperationException("This method isn't supported by the Custom Tabs implementation.", e);
}
}
/* renamed from: androidx.browser.customtabs.CustomTabsSession$1, reason: invalid class name */
public class AnonymousClass1 extends IEngagementSignalsCallback.Stub {
private final Handler mHandler = new Handler(Looper.getMainLooper());
final /* synthetic */ EngagementSignalsCallback val$callback;
public AnonymousClass1(EngagementSignalsCallback engagementSignalsCallback) {
this.val$callback = engagementSignalsCallback;
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onVerticalScrollEvent(final boolean z, final Bundle bundle) {
Handler handler = this.mHandler;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
handler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$1$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onVerticalScrollEvent(z, bundle);
}
});
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onGreatestScrollPercentageIncreased(final int i, final Bundle bundle) {
Handler handler = this.mHandler;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
handler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$1$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onGreatestScrollPercentageIncreased(i, bundle);
}
});
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onSessionEnded(final boolean z, final Bundle bundle) {
Handler handler = this.mHandler;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
handler.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$1$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onSessionEnded(z, bundle);
}
});
}
}
private IEngagementSignalsCallback.Stub createEngagementSignalsCallbackWrapper(@NonNull EngagementSignalsCallback engagementSignalsCallback) {
return new AnonymousClass1(engagementSignalsCallback);
}
public boolean setEngagementSignalsCallback(@NonNull Executor executor, @NonNull EngagementSignalsCallback engagementSignalsCallback, @NonNull Bundle bundle) throws RemoteException {
try {
return this.mService.setEngagementSignalsCallback(this.mCallback, createEngagementSignalsCallbackWrapper(engagementSignalsCallback, executor).asBinder(), createBundleWithId(bundle));
} catch (SecurityException e) {
throw new UnsupportedOperationException("This method isn't supported by the Custom Tabs implementation.", e);
}
}
/* renamed from: androidx.browser.customtabs.CustomTabsSession$2, reason: invalid class name */
public class AnonymousClass2 extends IEngagementSignalsCallback.Stub {
private final Executor mExecutor;
final /* synthetic */ EngagementSignalsCallback val$callback;
final /* synthetic */ Executor val$executor;
public AnonymousClass2(Executor executor, EngagementSignalsCallback engagementSignalsCallback) {
this.val$executor = executor;
this.val$callback = engagementSignalsCallback;
this.mExecutor = executor;
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onVerticalScrollEvent(final boolean z, final Bundle bundle) {
long clearCallingIdentity = Binder.clearCallingIdentity();
try {
Executor executor = this.mExecutor;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
executor.execute(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$2$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onVerticalScrollEvent(z, bundle);
}
});
} finally {
Binder.restoreCallingIdentity(clearCallingIdentity);
}
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onGreatestScrollPercentageIncreased(final int i, final Bundle bundle) {
long clearCallingIdentity = Binder.clearCallingIdentity();
try {
Executor executor = this.mExecutor;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
executor.execute(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$2$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onGreatestScrollPercentageIncreased(i, bundle);
}
});
} finally {
Binder.restoreCallingIdentity(clearCallingIdentity);
}
}
@Override // android.support.customtabs.IEngagementSignalsCallback
public void onSessionEnded(final boolean z, final Bundle bundle) {
long clearCallingIdentity = Binder.clearCallingIdentity();
try {
Executor executor = this.mExecutor;
final EngagementSignalsCallback engagementSignalsCallback = this.val$callback;
executor.execute(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsSession$2$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
EngagementSignalsCallback.this.onSessionEnded(z, bundle);
}
});
} finally {
Binder.restoreCallingIdentity(clearCallingIdentity);
}
}
}
private IEngagementSignalsCallback.Stub createEngagementSignalsCallbackWrapper(@NonNull EngagementSignalsCallback engagementSignalsCallback, @NonNull Executor executor) {
return new AnonymousClass2(executor, engagementSignalsCallback);
}
@Nullable
private Bundle createPostMessageExtraBundle(@Nullable Uri uri) {
Bundle bundle = new Bundle();
if (uri != null) {
bundle.putParcelable(TARGET_ORIGIN_KEY, uri);
}
if (this.mId != null) {
addIdToBundle(bundle);
}
if (bundle.isEmpty()) {
return null;
}
return bundle;
}
private Bundle createBundleWithId(@Nullable Bundle bundle) {
Bundle bundle2 = new Bundle();
if (bundle != null) {
bundle2.putAll(bundle);
}
addIdToBundle(bundle2);
return bundle2;
}
private void addIdToBundle(Bundle bundle) {
PendingIntent pendingIntent = this.mId;
if (pendingIntent != null) {
bundle.putParcelable(CustomTabsIntent.EXTRA_SESSION_ID, pendingIntent);
}
}
public IBinder getBinder() {
return this.mCallback.asBinder();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class PendingSession {
@Nullable
private final CustomTabsCallback mCallback;
@Nullable
private final PendingIntent mId;
@Nullable
public CustomTabsCallback getCallback() {
return this.mCallback;
}
@Nullable
public PendingIntent getId() {
return this.mId;
}
public PendingSession(@Nullable CustomTabsCallback customTabsCallback, @Nullable PendingIntent pendingIntent) {
this.mCallback = customTabsCallback;
this.mId = pendingIntent;
}
}
}

View File

@@ -0,0 +1,273 @@
package androidx.browser.customtabs;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
/* loaded from: classes.dex */
public class CustomTabsSessionToken {
private static final String TAG = "CustomTabsSessionToken";
@Nullable
private final CustomTabsCallback mCallback;
@Nullable
final ICustomTabsCallback mCallbackBinder;
@Nullable
private final PendingIntent mSessionId;
public static class MockCallback extends ICustomTabsCallback.Stub {
@Override // android.support.customtabs.ICustomTabsCallback.Stub, android.os.IInterface
public IBinder asBinder() {
return this;
}
@Override // android.support.customtabs.ICustomTabsCallback
public void extraCallback(String str, Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public Bundle extraCallbackWithResult(String str, Bundle bundle) {
return null;
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onActivityLayout(int i, int i2, int i3, int i4, int i5, @NonNull Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onActivityResized(int i, int i2, Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onMessageChannelReady(Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onMinimized(@NonNull Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onNavigationEvent(int i, Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onPostMessage(String str, Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onRelationshipValidationResult(int i, Uri uri, boolean z, Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onUnminimized(@NonNull Bundle bundle) {
}
@Override // android.support.customtabs.ICustomTabsCallback
public void onWarmupCompleted(Bundle bundle) {
}
}
@Nullable
public CustomTabsCallback getCallback() {
return this.mCallback;
}
@Nullable
public PendingIntent getId() {
return this.mSessionId;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public boolean hasCallback() {
return this.mCallbackBinder != null;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public boolean hasId() {
return this.mSessionId != null;
}
@Nullable
public static CustomTabsSessionToken getSessionTokenFromIntent(@NonNull Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null) {
return null;
}
IBinder binder = extras.getBinder(CustomTabsIntent.EXTRA_SESSION);
PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra(CustomTabsIntent.EXTRA_SESSION_ID);
if (binder == null && pendingIntent == null) {
return null;
}
return new CustomTabsSessionToken(binder != null ? ICustomTabsCallback.Stub.asInterface(binder) : null, pendingIntent);
}
@NonNull
public static CustomTabsSessionToken createMockSessionTokenForTesting() {
return new CustomTabsSessionToken(new MockCallback(), null);
}
public CustomTabsSessionToken(@Nullable ICustomTabsCallback iCustomTabsCallback, @Nullable PendingIntent pendingIntent) {
if (iCustomTabsCallback == null && pendingIntent == null) {
throw new IllegalStateException("CustomTabsSessionToken must have either a session id or a callback (or both).");
}
this.mCallbackBinder = iCustomTabsCallback;
this.mSessionId = pendingIntent;
this.mCallback = iCustomTabsCallback == null ? null : new CustomTabsCallback() { // from class: androidx.browser.customtabs.CustomTabsSessionToken.1
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onNavigationEvent(int i, @Nullable Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onNavigationEvent(i, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void extraCallback(@NonNull String str, @Nullable Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.extraCallback(str, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
@NonNull
public Bundle extraCallbackWithResult(@NonNull String str, @Nullable Bundle bundle) {
try {
return CustomTabsSessionToken.this.mCallbackBinder.extraCallbackWithResult(str, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
return null;
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onMessageChannelReady(@Nullable Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onMessageChannelReady(bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onPostMessage(@NonNull String str, @Nullable Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onPostMessage(str, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onRelationshipValidationResult(int i, @NonNull Uri uri, boolean z, @Nullable Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onRelationshipValidationResult(i, uri, z, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onActivityResized(int i, int i2, @NonNull Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onActivityResized(i, i2, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onWarmupCompleted(@NonNull Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onWarmupCompleted(bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onActivityLayout(int i, int i2, int i3, int i4, int i5, @NonNull Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onActivityLayout(i, i2, i3, i4, i5, bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onMinimized(@NonNull Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onMinimized(bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
@Override // androidx.browser.customtabs.CustomTabsCallback
public void onUnminimized(@NonNull Bundle bundle) {
try {
CustomTabsSessionToken.this.mCallbackBinder.onUnminimized(bundle);
} catch (RemoteException unused) {
Log.e(CustomTabsSessionToken.TAG, "RemoteException during ICustomTabsCallback transaction");
}
}
};
}
@Nullable
public IBinder getCallbackBinder() {
ICustomTabsCallback iCustomTabsCallback = this.mCallbackBinder;
if (iCustomTabsCallback == null) {
return null;
}
return iCustomTabsCallback.asBinder();
}
private IBinder getCallbackBinderAssertNotNull() {
ICustomTabsCallback iCustomTabsCallback = this.mCallbackBinder;
if (iCustomTabsCallback == null) {
throw new IllegalStateException("CustomTabSessionToken must have valid binder or pending session");
}
return iCustomTabsCallback.asBinder();
}
public int hashCode() {
PendingIntent pendingIntent = this.mSessionId;
if (pendingIntent != null) {
return pendingIntent.hashCode();
}
return getCallbackBinderAssertNotNull().hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof CustomTabsSessionToken)) {
return false;
}
CustomTabsSessionToken customTabsSessionToken = (CustomTabsSessionToken) obj;
PendingIntent id = customTabsSessionToken.getId();
PendingIntent pendingIntent = this.mSessionId;
if ((pendingIntent == null) != (id == null)) {
return false;
}
if (pendingIntent != null) {
return pendingIntent.equals(id);
}
return getCallbackBinderAssertNotNull().equals(customTabsSessionToken.getCallbackBinderAssertNotNull());
}
public boolean isAssociatedWith(@NonNull CustomTabsSession customTabsSession) {
return customTabsSession.getBinder().equals(this.mCallbackBinder);
}
}

View File

@@ -0,0 +1,17 @@
package androidx.browser.customtabs;
import android.os.Bundle;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
/* loaded from: classes.dex */
public interface EngagementSignalsCallback {
default void onGreatestScrollPercentageIncreased(@IntRange(from = 1, to = 100) int i, @NonNull Bundle bundle) {
}
default void onSessionEnded(boolean z, @NonNull Bundle bundle) {
}
default void onVerticalScrollEvent(boolean z, @NonNull Bundle bundle) {
}
}

View File

@@ -0,0 +1,53 @@
package androidx.browser.customtabs;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.IEngagementSignalsCallback;
import android.util.Log;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
final class EngagementSignalsCallbackRemote implements EngagementSignalsCallback {
private static final String TAG = "EngagementSigsCallbkRmt";
private final IEngagementSignalsCallback mCallbackBinder;
private EngagementSignalsCallbackRemote(@NonNull IEngagementSignalsCallback iEngagementSignalsCallback) {
this.mCallbackBinder = iEngagementSignalsCallback;
}
@NonNull
public static EngagementSignalsCallbackRemote fromBinder(@NonNull IBinder iBinder) {
return new EngagementSignalsCallbackRemote(IEngagementSignalsCallback.Stub.asInterface(iBinder));
}
@Override // androidx.browser.customtabs.EngagementSignalsCallback
public void onVerticalScrollEvent(boolean z, @NonNull Bundle bundle) {
try {
this.mCallbackBinder.onVerticalScrollEvent(z, bundle);
} catch (RemoteException unused) {
Log.e(TAG, "RemoteException during IEngagementSignalsCallback transaction");
}
}
@Override // androidx.browser.customtabs.EngagementSignalsCallback
public void onGreatestScrollPercentageIncreased(@IntRange(from = 1, to = 100) int i, @NonNull Bundle bundle) {
try {
this.mCallbackBinder.onGreatestScrollPercentageIncreased(i, bundle);
} catch (RemoteException unused) {
Log.e(TAG, "RemoteException during IEngagementSignalsCallback transaction");
}
}
@Override // androidx.browser.customtabs.EngagementSignalsCallback
public void onSessionEnded(boolean z, @NonNull Bundle bundle) {
try {
this.mCallbackBinder.onSessionEnded(z, bundle);
} catch (RemoteException unused) {
Log.e(TAG, "RemoteException during IEngagementSignalsCallback transaction");
}
}
}

View File

@@ -0,0 +1,8 @@
package androidx.browser.customtabs;
import androidx.annotation.RequiresOptIn;
@RequiresOptIn(level = RequiresOptIn.Level.WARNING)
/* loaded from: classes.dex */
public @interface ExperimentalMinimizationCallback {
}

View File

@@ -0,0 +1,17 @@
package androidx.browser.customtabs;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public interface PostMessageBackend {
void onDisconnectChannel(@NonNull Context context);
boolean onNotifyMessageChannelReady(@Nullable Bundle bundle);
boolean onPostMessage(@NonNull String str, @Nullable Bundle bundle);
}

View File

@@ -0,0 +1,32 @@
package androidx.browser.customtabs;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.IPostMessageService;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
public class PostMessageService extends Service {
private IPostMessageService.Stub mBinder = new IPostMessageService.Stub() { // from class: androidx.browser.customtabs.PostMessageService.1
@Override // android.support.customtabs.IPostMessageService
public void onMessageChannelReady(@NonNull ICustomTabsCallback iCustomTabsCallback, @Nullable Bundle bundle) throws RemoteException {
iCustomTabsCallback.onMessageChannelReady(bundle);
}
@Override // android.support.customtabs.IPostMessageService
public void onPostMessage(@NonNull ICustomTabsCallback iCustomTabsCallback, @NonNull String str, @Nullable Bundle bundle) throws RemoteException {
iCustomTabsCallback.onPostMessage(str, bundle);
}
};
@Override // android.app.Service
@NonNull
public IBinder onBind(@Nullable Intent intent) {
return this.mBinder;
}
}

View File

@@ -0,0 +1,159 @@
package androidx.browser.customtabs;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.IPostMessageService;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
/* loaded from: classes.dex */
public abstract class PostMessageServiceConnection implements PostMessageBackend, ServiceConnection {
private static final String TAG = "PostMessageServConn";
private final Object mLock = new Object();
private boolean mMessageChannelCreated;
@Nullable
private String mPackageName;
@Nullable
private IPostMessageService mService;
private final ICustomTabsCallback mSessionBinder;
private boolean isBoundToService() {
return this.mService != null;
}
public void onPostMessageServiceDisconnected() {
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void setPackageName(@NonNull String str) {
this.mPackageName = str;
}
public PostMessageServiceConnection(@NonNull CustomTabsSessionToken customTabsSessionToken) {
IBinder callbackBinder = customTabsSessionToken.getCallbackBinder();
if (callbackBinder == null) {
throw new IllegalArgumentException("Provided session must have binder.");
}
this.mSessionBinder = ICustomTabsCallback.Stub.asInterface(callbackBinder);
}
public boolean bindSessionToPostMessageService(@NonNull Context context, @NonNull String str) {
Intent intent = new Intent();
intent.setClassName(str, PostMessageService.class.getName());
boolean bindService = context.bindService(intent, this, 1);
if (!bindService) {
Log.w(TAG, "Could not bind to PostMessageService in client.");
}
return bindService;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public boolean bindSessionToPostMessageService(@NonNull Context context) {
String str = this.mPackageName;
if (str == null) {
throw new IllegalStateException("setPackageName must be called before bindSessionToPostMessageService.");
}
return bindSessionToPostMessageService(context, str);
}
public void unbindFromContext(@NonNull Context context) {
if (isBoundToService()) {
context.unbindService(this);
this.mService = null;
}
}
@Override // android.content.ServiceConnection
public final void onServiceConnected(@NonNull ComponentName componentName, @NonNull IBinder iBinder) {
this.mService = IPostMessageService.Stub.asInterface(iBinder);
onPostMessageServiceConnected();
}
@Override // android.content.ServiceConnection
public final void onServiceDisconnected(@NonNull ComponentName componentName) {
this.mService = null;
onPostMessageServiceDisconnected();
}
@Override // androidx.browser.customtabs.PostMessageBackend
@RestrictTo({RestrictTo.Scope.LIBRARY})
public final boolean onNotifyMessageChannelReady(@Nullable Bundle bundle) {
return notifyMessageChannelReady(bundle);
}
public final boolean notifyMessageChannelReady(@Nullable Bundle bundle) {
this.mMessageChannelCreated = true;
return notifyMessageChannelReadyInternal(bundle);
}
private boolean notifyMessageChannelReadyInternal(@Nullable Bundle bundle) {
if (this.mService == null) {
return false;
}
synchronized (this.mLock) {
try {
try {
this.mService.onMessageChannelReady(this.mSessionBinder, bundle);
} catch (RemoteException unused) {
return false;
}
} catch (Throwable th) {
throw th;
}
}
return true;
}
@Override // androidx.browser.customtabs.PostMessageBackend
@RestrictTo({RestrictTo.Scope.LIBRARY})
public final boolean onPostMessage(@NonNull String str, @Nullable Bundle bundle) {
return postMessage(str, bundle);
}
public final boolean postMessage(@NonNull String str, @Nullable Bundle bundle) {
if (this.mService == null) {
return false;
}
synchronized (this.mLock) {
try {
try {
this.mService.onPostMessage(this.mSessionBinder, str, bundle);
} catch (RemoteException unused) {
return false;
}
} catch (Throwable th) {
throw th;
}
}
return true;
}
@Override // androidx.browser.customtabs.PostMessageBackend
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void onDisconnectChannel(@NonNull Context context) {
unbindFromContext(context);
}
public void onPostMessageServiceConnected() {
if (this.mMessageChannelCreated) {
notifyMessageChannelReadyInternal(null);
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void cleanup(@NonNull Context context) {
if (isBoundToService()) {
unbindFromContext(context);
}
}
}

View File

@@ -0,0 +1,65 @@
package androidx.browser.customtabs;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
import androidx.core.content.FileProvider;
import java.io.File;
/* loaded from: classes.dex */
public class TrustedWebUtils {
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static final String ACTION_MANAGE_TRUSTED_WEB_ACTIVITY_DATA = "android.support.customtabs.action.ACTION_MANAGE_TRUSTED_WEB_ACTIVITY_DATA";
public static final String EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY = "android.support.customtabs.extra.LAUNCH_AS_TRUSTED_WEB_ACTIVITY";
private TrustedWebUtils() {
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static void launchBrowserSiteSettings(@NonNull Context context, @NonNull CustomTabsSession customTabsSession, @NonNull Uri uri) {
Intent intent = new Intent(ACTION_MANAGE_TRUSTED_WEB_ACTIVITY_DATA);
intent.setPackage(customTabsSession.getComponentName().getPackageName());
intent.setData(uri);
Bundle bundle = new Bundle();
bundle.putBinder(CustomTabsIntent.EXTRA_SESSION, customTabsSession.getBinder());
intent.putExtras(bundle);
PendingIntent id = customTabsSession.getId();
if (id != null) {
intent.putExtra(CustomTabsIntent.EXTRA_SESSION_ID, id);
}
context.startActivity(intent);
}
public static boolean areSplashScreensSupported(@NonNull Context context, @NonNull String str, @NonNull String str2) {
IntentFilter intentFilter;
ResolveInfo resolveService = context.getPackageManager().resolveService(new Intent().setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION).setPackage(str), 64);
if (resolveService == null || (intentFilter = resolveService.filter) == null) {
return false;
}
return intentFilter.hasCategory(str2);
}
@WorkerThread
public static boolean transferSplashImage(@NonNull Context context, @NonNull File file, @NonNull String str, @NonNull String str2, @NonNull CustomTabsSession customTabsSession) {
Uri uriForFile = FileProvider.getUriForFile(context, str, file);
context.grantUriPermission(str2, uriForFile, 1);
return customTabsSession.receiveFile(uriForFile, 1, null);
}
@Deprecated
public static void launchAsTrustedWebActivity(@NonNull Context context, @NonNull CustomTabsIntent customTabsIntent, @NonNull Uri uri) {
if (customTabsIntent.intent.getExtras().getBinder(CustomTabsIntent.EXTRA_SESSION) == null) {
throw new IllegalArgumentException("Given CustomTabsIntent should be associated with a valid CustomTabsSession");
}
customTabsIntent.intent.putExtra(EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);
customTabsIntent.launchUrl(context, uri);
}
}

View File

@@ -0,0 +1,127 @@
package androidx.browser.trusted;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.customtabs.trusted.ITrustedWebActivityService;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.concurrent.futures.CallbackToFutureAdapter;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
class ConnectionHolder implements ServiceConnection {
private static final int STATE_AWAITING_CONNECTION = 0;
private static final int STATE_CANCELLED = 3;
private static final int STATE_CONNECTED = 1;
private static final int STATE_DISCONNECTED = 2;
@Nullable
private Exception mCancellationException;
@NonNull
private final Runnable mCloseRunnable;
@NonNull
private List<CallbackToFutureAdapter.Completer<TrustedWebActivityServiceConnection>> mCompleters;
@Nullable
private TrustedWebActivityServiceConnection mService;
private int mState;
@NonNull
private final WrapperFactory mWrapperFactory;
public static class WrapperFactory {
@NonNull
public TrustedWebActivityServiceConnection create(ComponentName componentName, IBinder iBinder) {
return new TrustedWebActivityServiceConnection(ITrustedWebActivityService.Stub.asInterface(iBinder), componentName);
}
}
@MainThread
public ConnectionHolder(@NonNull Runnable runnable) {
this(runnable, new WrapperFactory());
}
@MainThread
public ConnectionHolder(@NonNull Runnable runnable, @NonNull WrapperFactory wrapperFactory) {
this.mState = 0;
this.mCompleters = new ArrayList();
this.mCloseRunnable = runnable;
this.mWrapperFactory = wrapperFactory;
}
@Override // android.content.ServiceConnection
@MainThread
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
this.mService = this.mWrapperFactory.create(componentName, iBinder);
Iterator<CallbackToFutureAdapter.Completer<TrustedWebActivityServiceConnection>> it = this.mCompleters.iterator();
while (it.hasNext()) {
it.next().set(this.mService);
}
this.mCompleters.clear();
this.mState = 1;
}
@Override // android.content.ServiceConnection
@MainThread
public void onServiceDisconnected(ComponentName componentName) {
this.mService = null;
this.mCloseRunnable.run();
this.mState = 2;
}
@MainThread
public void cancel(@NonNull Exception exc) {
Iterator<CallbackToFutureAdapter.Completer<TrustedWebActivityServiceConnection>> it = this.mCompleters.iterator();
while (it.hasNext()) {
it.next().setException(exc);
}
this.mCompleters.clear();
this.mCloseRunnable.run();
this.mState = 3;
this.mCancellationException = exc;
}
@NonNull
@MainThread
public ListenableFuture getServiceWrapper() {
return CallbackToFutureAdapter.getFuture(new CallbackToFutureAdapter.Resolver() { // from class: androidx.browser.trusted.ConnectionHolder$$ExternalSyntheticLambda0
@Override // androidx.concurrent.futures.CallbackToFutureAdapter.Resolver
public final Object attachCompleter(CallbackToFutureAdapter.Completer completer) {
Object lambda$getServiceWrapper$0;
lambda$getServiceWrapper$0 = ConnectionHolder.this.lambda$getServiceWrapper$0(completer);
return lambda$getServiceWrapper$0;
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ Object lambda$getServiceWrapper$0(CallbackToFutureAdapter.Completer completer) throws Exception {
int i = this.mState;
if (i == 0) {
this.mCompleters.add(completer);
} else {
if (i != 1) {
if (i == 2) {
throw new IllegalStateException("Service has been disconnected.");
}
if (i == 3) {
throw this.mCancellationException;
}
throw new IllegalStateException("Connection state is invalid");
}
TrustedWebActivityServiceConnection trustedWebActivityServiceConnection = this.mService;
if (trustedWebActivityServiceConnection == null) {
throw new IllegalStateException("ConnectionHolder state is incorrect.");
}
completer.set(trustedWebActivityServiceConnection);
}
return "ConnectionHolder, state = " + this.mState;
}
}

View File

@@ -0,0 +1,18 @@
package androidx.browser.trusted;
import androidx.annotation.NonNull;
import androidx.concurrent.futures.ResolvableFuture;
import com.google.common.util.concurrent.ListenableFuture;
/* loaded from: classes.dex */
class FutureUtils {
@NonNull
public static <T> ListenableFuture immediateFailedFuture(@NonNull Throwable th) {
ResolvableFuture create = ResolvableFuture.create();
create.setException(th);
return create;
}
private FutureUtils() {
}
}

View File

@@ -0,0 +1,20 @@
package androidx.browser.trusted;
import android.app.NotificationManager;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class NotificationApiHelperForM {
@NonNull
public static Parcelable[] getActiveNotifications(NotificationManager notificationManager) {
return notificationManager.getActiveNotifications();
}
private NotificationApiHelperForM() {
}
}

View File

@@ -0,0 +1,33 @@
package androidx.browser.trusted;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
@RequiresApi(26)
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
class NotificationApiHelperForO {
public static boolean isChannelEnabled(NotificationManager notificationManager, String str) {
NotificationChannel notificationChannel = notificationManager.getNotificationChannel(str);
return notificationChannel == null || notificationChannel.getImportance() != 0;
}
@Nullable
public static Notification copyNotificationOntoChannel(Context context, NotificationManager notificationManager, Notification notification, String str, String str2) {
notificationManager.createNotificationChannel(new NotificationChannel(str, str2, 3));
if (notificationManager.getNotificationChannel(str).getImportance() == 0) {
return null;
}
Notification.Builder recoverBuilder = Notification.Builder.recoverBuilder(context, notification);
recoverBuilder.setChannelId(str);
return recoverBuilder.build();
}
private NotificationApiHelperForO() {
}
}

View File

@@ -0,0 +1,124 @@
package androidx.browser.trusted;
import android.annotation.SuppressLint;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.pm.SigningInfo;
import android.os.Build;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class PackageIdentityUtils {
private static final String TAG = "PackageIdentity";
public interface SignaturesCompat {
@Nullable
List<byte[]> getFingerprintsForPackage(String str, PackageManager packageManager) throws PackageManager.NameNotFoundException;
boolean packageMatchesToken(String str, PackageManager packageManager, TokenContents tokenContents) throws IOException, PackageManager.NameNotFoundException;
}
private PackageIdentityUtils() {
}
@Nullable
public static List<byte[]> getFingerprintsForPackage(String str, PackageManager packageManager) {
try {
return getImpl().getFingerprintsForPackage(str, packageManager);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Could not get fingerprint for package.", e);
return null;
}
}
public static boolean packageMatchesToken(String str, PackageManager packageManager, TokenContents tokenContents) {
try {
return getImpl().packageMatchesToken(str, packageManager, tokenContents);
} catch (PackageManager.NameNotFoundException | IOException e) {
Log.e(TAG, "Could not check if package matches token.", e);
return false;
}
}
private static SignaturesCompat getImpl() {
if (Build.VERSION.SDK_INT >= 28) {
return new Api28Implementation();
}
return new Pre28Implementation();
}
@RequiresApi(28)
public static class Api28Implementation implements SignaturesCompat {
@Override // androidx.browser.trusted.PackageIdentityUtils.SignaturesCompat
@Nullable
public List<byte[]> getFingerprintsForPackage(String str, PackageManager packageManager) throws PackageManager.NameNotFoundException {
PackageInfo packageInfo = packageManager.getPackageInfo(str, 134217728);
ArrayList arrayList = new ArrayList();
SigningInfo signingInfo = packageInfo.signingInfo;
if (signingInfo.hasMultipleSigners()) {
for (Signature signature : signingInfo.getApkContentsSigners()) {
arrayList.add(PackageIdentityUtils.getCertificateSHA256Fingerprint(signature));
}
} else {
arrayList.add(PackageIdentityUtils.getCertificateSHA256Fingerprint(signingInfo.getSigningCertificateHistory()[0]));
}
return arrayList;
}
@Override // androidx.browser.trusted.PackageIdentityUtils.SignaturesCompat
public boolean packageMatchesToken(String str, PackageManager packageManager, TokenContents tokenContents) throws PackageManager.NameNotFoundException, IOException {
List<byte[]> fingerprintsForPackage;
if (!tokenContents.getPackageName().equals(str) || (fingerprintsForPackage = getFingerprintsForPackage(str, packageManager)) == null) {
return false;
}
if (fingerprintsForPackage.size() == 1) {
return packageManager.hasSigningCertificate(str, tokenContents.getFingerprint(0), 1);
}
return tokenContents.equals(TokenContents.create(str, fingerprintsForPackage));
}
}
public static class Pre28Implementation implements SignaturesCompat {
@Override // androidx.browser.trusted.PackageIdentityUtils.SignaturesCompat
@Nullable
@SuppressLint({"PackageManagerGetSignatures"})
public List<byte[]> getFingerprintsForPackage(String str, PackageManager packageManager) throws PackageManager.NameNotFoundException {
PackageInfo packageInfo = packageManager.getPackageInfo(str, 64);
ArrayList arrayList = new ArrayList(packageInfo.signatures.length);
for (Signature signature : packageInfo.signatures) {
byte[] certificateSHA256Fingerprint = PackageIdentityUtils.getCertificateSHA256Fingerprint(signature);
if (certificateSHA256Fingerprint == null) {
return null;
}
arrayList.add(certificateSHA256Fingerprint);
}
return arrayList;
}
@Override // androidx.browser.trusted.PackageIdentityUtils.SignaturesCompat
public boolean packageMatchesToken(String str, PackageManager packageManager, TokenContents tokenContents) throws IOException, PackageManager.NameNotFoundException {
List<byte[]> fingerprintsForPackage;
if (str.equals(tokenContents.getPackageName()) && (fingerprintsForPackage = getFingerprintsForPackage(str, packageManager)) != null) {
return tokenContents.equals(TokenContents.create(str, fingerprintsForPackage));
}
return false;
}
}
@Nullable
public static byte[] getCertificateSHA256Fingerprint(Signature signature) {
try {
return MessageDigest.getInstance("SHA256").digest(signature.toByteArray());
} catch (NoSuchAlgorithmException unused) {
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
package androidx.browser.trusted;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes.dex */
public final class ScreenOrientation {
public static final int ANY = 5;
public static final int DEFAULT = 0;
public static final int LANDSCAPE = 6;
public static final int LANDSCAPE_PRIMARY = 3;
public static final int LANDSCAPE_SECONDARY = 4;
public static final int NATURAL = 8;
public static final int PORTRAIT = 7;
public static final int PORTRAIT_PRIMARY = 1;
public static final int PORTRAIT_SECONDARY = 2;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface LockType {
}
private ScreenOrientation() {
}
}

View File

@@ -0,0 +1,48 @@
package androidx.browser.trusted;
import android.content.pm.PackageManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.IOException;
import java.util.List;
/* loaded from: classes.dex */
public final class Token {
private static final String TAG = "Token";
@NonNull
private final TokenContents mContents;
@Nullable
public static Token create(@NonNull String str, @NonNull PackageManager packageManager) {
List<byte[]> fingerprintsForPackage = PackageIdentityUtils.getFingerprintsForPackage(str, packageManager);
if (fingerprintsForPackage == null) {
return null;
}
try {
return new Token(TokenContents.create(str, fingerprintsForPackage));
} catch (IOException e) {
Log.e(TAG, "Exception when creating token.", e);
return null;
}
}
@NonNull
public static Token deserialize(@NonNull byte[] bArr) {
return new Token(TokenContents.deserialize(bArr));
}
private Token(@NonNull TokenContents tokenContents) {
this.mContents = tokenContents;
}
@NonNull
public byte[] serialize() {
return this.mContents.serialize();
}
public boolean matches(@NonNull String str, @NonNull PackageManager packageManager) {
return PackageIdentityUtils.packageMatchesToken(str, packageManager, this.mContents);
}
}

View File

@@ -0,0 +1,163 @@
package androidx.browser.trusted;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/* loaded from: classes.dex */
final class TokenContents {
@NonNull
private final byte[] mContents;
@Nullable
private List<byte[]> mFingerprints;
@Nullable
private String mPackageName;
@NonNull
public static TokenContents deserialize(@NonNull byte[] bArr) {
return new TokenContents(bArr);
}
private TokenContents(@NonNull byte[] bArr) {
this.mContents = bArr;
}
@NonNull
public static TokenContents create(String str, List<byte[]> list) throws IOException {
return new TokenContents(createToken(str, list), str, list);
}
private TokenContents(@NonNull byte[] bArr, @NonNull String str, @NonNull List<byte[]> list) {
this.mContents = bArr;
this.mPackageName = str;
this.mFingerprints = new ArrayList(list.size());
for (byte[] bArr2 : list) {
this.mFingerprints.add(Arrays.copyOf(bArr2, bArr2.length));
}
}
@NonNull
public String getPackageName() throws IOException {
parseIfNeeded();
String str = this.mPackageName;
if (str != null) {
return str;
}
throw new IllegalStateException();
}
public int getFingerprintCount() throws IOException {
parseIfNeeded();
List<byte[]> list = this.mFingerprints;
if (list == null) {
throw new IllegalStateException();
}
return list.size();
}
@NonNull
public byte[] getFingerprint(int i) throws IOException {
parseIfNeeded();
List<byte[]> list = this.mFingerprints;
if (list == null) {
throw new IllegalStateException();
}
return Arrays.copyOf(list.get(i), this.mFingerprints.get(i).length);
}
@NonNull
public byte[] serialize() {
byte[] bArr = this.mContents;
return Arrays.copyOf(bArr, bArr.length);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || TokenContents.class != obj.getClass()) {
return false;
}
return Arrays.equals(this.mContents, ((TokenContents) obj).mContents);
}
public int hashCode() {
return Arrays.hashCode(this.mContents);
}
@NonNull
private static byte[] createToken(@NonNull String str, @NonNull List<byte[]> list) throws IOException {
Collections.sort(list, new Comparator() { // from class: androidx.browser.trusted.TokenContents$$ExternalSyntheticLambda0
@Override // java.util.Comparator
public final int compare(Object obj, Object obj2) {
int compareByteArrays;
compareByteArrays = TokenContents.compareByteArrays((byte[]) obj, (byte[]) obj2);
return compareByteArrays;
}
});
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
dataOutputStream.writeUTF(str);
dataOutputStream.writeInt(list.size());
for (byte[] bArr : list) {
dataOutputStream.writeInt(bArr.length);
dataOutputStream.write(bArr);
}
dataOutputStream.flush();
return byteArrayOutputStream.toByteArray();
}
/* JADX INFO: Access modifiers changed from: private */
public static int compareByteArrays(byte[] bArr, byte[] bArr2) {
if (bArr == bArr2) {
return 0;
}
if (bArr == null) {
return -1;
}
if (bArr2 == null) {
return 1;
}
for (int i = 0; i < Math.min(bArr.length, bArr2.length); i++) {
byte b = bArr[i];
byte b2 = bArr2[i];
if (b != b2) {
return b - b2;
}
}
if (bArr.length != bArr2.length) {
return bArr.length - bArr2.length;
}
return 0;
}
private void parseIfNeeded() throws IOException {
if (this.mPackageName != null) {
return;
}
DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(this.mContents));
this.mPackageName = dataInputStream.readUTF();
int readInt = dataInputStream.readInt();
this.mFingerprints = new ArrayList(readInt);
for (int i = 0; i < readInt; i++) {
int readInt2 = dataInputStream.readInt();
byte[] bArr = new byte[readInt2];
if (dataInputStream.read(bArr) != readInt2) {
throw new IllegalStateException("Could not read fingerprint");
}
this.mFingerprints.add(bArr);
}
}
}

View File

@@ -0,0 +1,15 @@
package androidx.browser.trusted;
import androidx.annotation.BinderThread;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
/* loaded from: classes.dex */
public interface TokenStore {
@Nullable
@BinderThread
Token load();
@WorkerThread
void store(@Nullable Token token);
}

View File

@@ -0,0 +1,10 @@
package androidx.browser.trusted;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
public abstract class TrustedWebActivityCallback {
public abstract void onExtraCallback(@NonNull String str, @Nullable Bundle bundle);
}

View File

@@ -0,0 +1,30 @@
package androidx.browser.trusted;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.customtabs.trusted.ITrustedWebActivityCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/* loaded from: classes.dex */
public class TrustedWebActivityCallbackRemote {
private final ITrustedWebActivityCallback mCallbackBinder;
private TrustedWebActivityCallbackRemote(@NonNull ITrustedWebActivityCallback iTrustedWebActivityCallback) {
this.mCallbackBinder = iTrustedWebActivityCallback;
}
@Nullable
public static TrustedWebActivityCallbackRemote fromBinder(@Nullable IBinder iBinder) {
ITrustedWebActivityCallback asInterface = iBinder == null ? null : ITrustedWebActivityCallback.Stub.asInterface(iBinder);
if (asInterface == null) {
return null;
}
return new TrustedWebActivityCallbackRemote(asInterface);
}
public void runExtraCallback(@NonNull String str, @NonNull Bundle bundle) throws RemoteException {
this.mCallbackBinder.onExtraCallback(str, bundle);
}
}

View File

@@ -0,0 +1,68 @@
package androidx.browser.trusted;
import android.os.Bundle;
import androidx.annotation.NonNull;
/* loaded from: classes.dex */
public interface TrustedWebActivityDisplayMode {
public static final String KEY_ID = "androidx.browser.trusted.displaymode.KEY_ID";
@NonNull
Bundle toBundle();
@NonNull
static TrustedWebActivityDisplayMode fromBundle(@NonNull Bundle bundle) {
if (bundle.getInt(KEY_ID) == 1) {
return ImmersiveMode.fromBundle(bundle);
}
return new DefaultMode();
}
public static class DefaultMode implements TrustedWebActivityDisplayMode {
private static final int ID = 0;
@Override // androidx.browser.trusted.TrustedWebActivityDisplayMode
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(TrustedWebActivityDisplayMode.KEY_ID, 0);
return bundle;
}
}
public static class ImmersiveMode implements TrustedWebActivityDisplayMode {
private static final int ID = 1;
public static final String KEY_CUTOUT_MODE = "androidx.browser.trusted.displaymode.KEY_CUTOUT_MODE";
public static final String KEY_STICKY = "androidx.browser.trusted.displaymode.KEY_STICKY";
private final boolean mIsSticky;
private final int mLayoutInDisplayCutoutMode;
public boolean isSticky() {
return this.mIsSticky;
}
public int layoutInDisplayCutoutMode() {
return this.mLayoutInDisplayCutoutMode;
}
public ImmersiveMode(boolean z, int i) {
this.mIsSticky = z;
this.mLayoutInDisplayCutoutMode = i;
}
@NonNull
public static TrustedWebActivityDisplayMode fromBundle(@NonNull Bundle bundle) {
return new ImmersiveMode(bundle.getBoolean(KEY_STICKY), bundle.getInt(KEY_CUTOUT_MODE));
}
@Override // androidx.browser.trusted.TrustedWebActivityDisplayMode
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putInt(TrustedWebActivityDisplayMode.KEY_ID, 1);
bundle.putBoolean(KEY_STICKY, this.mIsSticky);
bundle.putInt(KEY_CUTOUT_MODE, this.mLayoutInDisplayCutoutMode);
return bundle;
}
}
}

View File

@@ -0,0 +1,41 @@
package androidx.browser.trusted;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class TrustedWebActivityIntent {
@NonNull
private final Intent mIntent;
@NonNull
private final List<Uri> mSharedFileUris;
@NonNull
public Intent getIntent() {
return this.mIntent;
}
public TrustedWebActivityIntent(@NonNull Intent intent, @NonNull List<Uri> list) {
this.mIntent = intent;
this.mSharedFileUris = list;
}
public void launchTrustedWebActivity(@NonNull Context context) {
grantUriPermissionToProvider(context);
ContextCompat.startActivity(context, this.mIntent, null);
}
private void grantUriPermissionToProvider(Context context) {
Iterator<Uri> it = this.mSharedFileUris.iterator();
while (it.hasNext()) {
context.grantUriPermission(this.mIntent.getPackage(), it.next(), 1);
}
}
}

View File

@@ -0,0 +1,175 @@
package androidx.browser.trusted;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.customtabs.CustomTabsSession;
import androidx.browser.customtabs.TrustedWebUtils;
import androidx.browser.trusted.TrustedWebActivityDisplayMode;
import androidx.browser.trusted.sharing.ShareData;
import androidx.browser.trusted.sharing.ShareTarget;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public class TrustedWebActivityIntentBuilder {
@SuppressLint({"ActionValue"})
public static final String EXTRA_ADDITIONAL_TRUSTED_ORIGINS = "android.support.customtabs.extra.ADDITIONAL_TRUSTED_ORIGINS";
public static final String EXTRA_DISPLAY_MODE = "androidx.browser.trusted.extra.DISPLAY_MODE";
public static final String EXTRA_SCREEN_ORIENTATION = "androidx.browser.trusted.extra.SCREEN_ORIENTATION";
public static final String EXTRA_SHARE_DATA = "androidx.browser.trusted.extra.SHARE_DATA";
public static final String EXTRA_SHARE_TARGET = "androidx.browser.trusted.extra.SHARE_TARGET";
@SuppressLint({"ActionValue"})
public static final String EXTRA_SPLASH_SCREEN_PARAMS = "androidx.browser.trusted.EXTRA_SPLASH_SCREEN_PARAMS";
@Nullable
private List<String> mAdditionalTrustedOrigins;
@Nullable
private ShareData mShareData;
@Nullable
private ShareTarget mShareTarget;
@Nullable
private Bundle mSplashScreenParams;
@NonNull
private final Uri mUri;
@NonNull
private final CustomTabsIntent.Builder mIntentBuilder = new CustomTabsIntent.Builder();
@NonNull
private TrustedWebActivityDisplayMode mDisplayMode = new TrustedWebActivityDisplayMode.DefaultMode();
private int mScreenOrientation = 0;
@NonNull
public TrustedWebActivityDisplayMode getDisplayMode() {
return this.mDisplayMode;
}
@NonNull
public Uri getUri() {
return this.mUri;
}
@NonNull
public TrustedWebActivityIntentBuilder setAdditionalTrustedOrigins(@NonNull List<String> list) {
this.mAdditionalTrustedOrigins = list;
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setDisplayMode(@NonNull TrustedWebActivityDisplayMode trustedWebActivityDisplayMode) {
this.mDisplayMode = trustedWebActivityDisplayMode;
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setScreenOrientation(int i) {
this.mScreenOrientation = i;
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setShareParams(@NonNull ShareTarget shareTarget, @NonNull ShareData shareData) {
this.mShareTarget = shareTarget;
this.mShareData = shareData;
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setSplashScreenParams(@NonNull Bundle bundle) {
this.mSplashScreenParams = bundle;
return this;
}
public TrustedWebActivityIntentBuilder(@NonNull Uri uri) {
this.mUri = uri;
}
@NonNull
@Deprecated
public TrustedWebActivityIntentBuilder setToolbarColor(@ColorInt int i) {
this.mIntentBuilder.setToolbarColor(i);
return this;
}
@NonNull
@Deprecated
public TrustedWebActivityIntentBuilder setNavigationBarColor(@ColorInt int i) {
this.mIntentBuilder.setNavigationBarColor(i);
return this;
}
@NonNull
@Deprecated
public TrustedWebActivityIntentBuilder setNavigationBarDividerColor(@ColorInt int i) {
this.mIntentBuilder.setNavigationBarDividerColor(i);
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setColorScheme(int i) {
this.mIntentBuilder.setColorScheme(i);
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setColorSchemeParams(int i, @NonNull CustomTabColorSchemeParams customTabColorSchemeParams) {
this.mIntentBuilder.setColorSchemeParams(i, customTabColorSchemeParams);
return this;
}
@NonNull
public TrustedWebActivityIntentBuilder setDefaultColorSchemeParams(@NonNull CustomTabColorSchemeParams customTabColorSchemeParams) {
this.mIntentBuilder.setDefaultColorSchemeParams(customTabColorSchemeParams);
return this;
}
@NonNull
public TrustedWebActivityIntent build(@NonNull CustomTabsSession customTabsSession) {
if (customTabsSession == null) {
throw new NullPointerException("CustomTabsSession is required for launching a TWA");
}
this.mIntentBuilder.setSession(customTabsSession);
Intent intent = this.mIntentBuilder.build().intent;
intent.setData(this.mUri);
intent.putExtra(TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);
if (this.mAdditionalTrustedOrigins != null) {
intent.putExtra(EXTRA_ADDITIONAL_TRUSTED_ORIGINS, new ArrayList(this.mAdditionalTrustedOrigins));
}
Bundle bundle = this.mSplashScreenParams;
if (bundle != null) {
intent.putExtra(EXTRA_SPLASH_SCREEN_PARAMS, bundle);
}
List<Uri> emptyList = Collections.emptyList();
ShareTarget shareTarget = this.mShareTarget;
if (shareTarget != null && this.mShareData != null) {
intent.putExtra(EXTRA_SHARE_TARGET, shareTarget.toBundle());
intent.putExtra(EXTRA_SHARE_DATA, this.mShareData.toBundle());
List<Uri> list = this.mShareData.uris;
if (list != null) {
emptyList = list;
}
}
intent.putExtra(EXTRA_DISPLAY_MODE, this.mDisplayMode.toBundle());
intent.putExtra(EXTRA_SCREEN_ORIENTATION, this.mScreenOrientation);
return new TrustedWebActivityIntent(intent, emptyList);
}
@NonNull
public CustomTabsIntent buildCustomTabsIntent() {
return this.mIntentBuilder.build();
}
}

View File

@@ -0,0 +1,219 @@
package androidx.browser.trusted;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.BitmapFactory;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.support.customtabs.trusted.ITrustedWebActivityService;
import androidx.annotation.BinderThread;
import androidx.annotation.CallSuper;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import androidx.annotation.RestrictTo;
import androidx.browser.trusted.TrustedWebActivityServiceConnection;
import androidx.core.app.NotificationManagerCompat;
import java.util.Locale;
/* loaded from: classes.dex */
public abstract class TrustedWebActivityService extends Service {
@SuppressLint({"ActionValue", "ServiceName"})
public static final String ACTION_TRUSTED_WEB_ACTIVITY_SERVICE = "android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE";
public static final String KEY_SMALL_ICON_BITMAP = "android.support.customtabs.trusted.SMALL_ICON_BITMAP";
public static final String KEY_SUCCESS = "androidx.browser.trusted.SUCCESS";
public static final String META_DATA_NAME_SMALL_ICON = "android.support.customtabs.trusted.SMALL_ICON";
public static final int SMALL_ICON_NOT_SET = -1;
private NotificationManager mNotificationManager;
int mVerifiedUid = -1;
private final ITrustedWebActivityService.Stub mBinder = new ITrustedWebActivityService.Stub() { // from class: androidx.browser.trusted.TrustedWebActivityService.1
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public Bundle areNotificationsEnabled(Bundle bundle) {
checkCaller();
return new TrustedWebActivityServiceConnection.ResultArgs(TrustedWebActivityService.this.onAreNotificationsEnabled(TrustedWebActivityServiceConnection.NotificationsEnabledArgs.fromBundle(bundle).channelName)).toBundle();
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
@RequiresPermission("android.permission.POST_NOTIFICATIONS")
public Bundle notifyNotificationWithChannel(Bundle bundle) {
checkCaller();
TrustedWebActivityServiceConnection.NotifyNotificationArgs fromBundle = TrustedWebActivityServiceConnection.NotifyNotificationArgs.fromBundle(bundle);
return new TrustedWebActivityServiceConnection.ResultArgs(TrustedWebActivityService.this.onNotifyNotificationWithChannel(fromBundle.platformTag, fromBundle.platformId, fromBundle.notification, fromBundle.channelName)).toBundle();
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public void cancelNotification(Bundle bundle) {
checkCaller();
TrustedWebActivityServiceConnection.CancelNotificationArgs fromBundle = TrustedWebActivityServiceConnection.CancelNotificationArgs.fromBundle(bundle);
TrustedWebActivityService.this.onCancelNotification(fromBundle.platformTag, fromBundle.platformId);
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public Bundle getActiveNotifications() {
checkCaller();
return new TrustedWebActivityServiceConnection.ActiveNotificationsArgs(TrustedWebActivityService.this.onGetActiveNotifications()).toBundle();
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public int getSmallIconId() {
checkCaller();
return TrustedWebActivityService.this.onGetSmallIconId();
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public Bundle getSmallIconBitmap() {
checkCaller();
return TrustedWebActivityService.this.onGetSmallIconBitmap();
}
@Override // android.support.customtabs.trusted.ITrustedWebActivityService
public Bundle extraCommand(String str, Bundle bundle, IBinder iBinder) {
checkCaller();
return TrustedWebActivityService.this.onExtraCommand(str, bundle, TrustedWebActivityCallbackRemote.fromBinder(iBinder));
}
private void checkCaller() {
TrustedWebActivityService trustedWebActivityService = TrustedWebActivityService.this;
if (trustedWebActivityService.mVerifiedUid == -1) {
String[] packagesForUid = trustedWebActivityService.getPackageManager().getPackagesForUid(Binder.getCallingUid());
int i = 0;
if (packagesForUid == null) {
packagesForUid = new String[0];
}
Token load = TrustedWebActivityService.this.getTokenStore().load();
PackageManager packageManager = TrustedWebActivityService.this.getPackageManager();
if (load != null) {
int length = packagesForUid.length;
while (true) {
if (i >= length) {
break;
}
if (load.matches(packagesForUid[i], packageManager)) {
TrustedWebActivityService.this.mVerifiedUid = Binder.getCallingUid();
break;
}
i++;
}
}
}
if (TrustedWebActivityService.this.mVerifiedUid != Binder.getCallingUid()) {
throw new SecurityException("Caller is not verified as Trusted Web Activity provider.");
}
}
};
@NonNull
@BinderThread
public abstract TokenStore getTokenStore();
@Override // android.app.Service
@Nullable
@MainThread
public final IBinder onBind(@Nullable Intent intent) {
return this.mBinder;
}
@Nullable
@BinderThread
public Bundle onExtraCommand(@NonNull String str, @NonNull Bundle bundle, @Nullable TrustedWebActivityCallbackRemote trustedWebActivityCallbackRemote) {
return null;
}
@Override // android.app.Service
@CallSuper
@MainThread
public void onCreate() {
super.onCreate();
this.mNotificationManager = (NotificationManager) getSystemService("notification");
}
@BinderThread
public boolean onAreNotificationsEnabled(@NonNull String str) {
ensureOnCreateCalled();
if (NotificationManagerCompat.from(this).areNotificationsEnabled()) {
return NotificationApiHelperForO.isChannelEnabled(this.mNotificationManager, channelNameToId(str));
}
return false;
}
@BinderThread
@RequiresPermission("android.permission.POST_NOTIFICATIONS")
public boolean onNotifyNotificationWithChannel(@NonNull String str, int i, @NonNull Notification notification, @NonNull String str2) {
ensureOnCreateCalled();
if (!NotificationManagerCompat.from(this).areNotificationsEnabled()) {
return false;
}
String channelNameToId = channelNameToId(str2);
Notification copyNotificationOntoChannel = NotificationApiHelperForO.copyNotificationOntoChannel(this, this.mNotificationManager, notification, channelNameToId, str2);
if (!NotificationApiHelperForO.isChannelEnabled(this.mNotificationManager, channelNameToId)) {
return false;
}
this.mNotificationManager.notify(str, i, copyNotificationOntoChannel);
return true;
}
@BinderThread
public void onCancelNotification(@NonNull String str, int i) {
ensureOnCreateCalled();
this.mNotificationManager.cancel(str, i);
}
@NonNull
@BinderThread
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Parcelable[] onGetActiveNotifications() {
ensureOnCreateCalled();
return NotificationApiHelperForM.getActiveNotifications(this.mNotificationManager);
}
@NonNull
@BinderThread
public Bundle onGetSmallIconBitmap() {
int onGetSmallIconId = onGetSmallIconId();
Bundle bundle = new Bundle();
if (onGetSmallIconId == -1) {
return bundle;
}
bundle.putParcelable(KEY_SMALL_ICON_BITMAP, BitmapFactory.decodeResource(getResources(), onGetSmallIconId));
return bundle;
}
@BinderThread
public int onGetSmallIconId() {
try {
Bundle bundle = getPackageManager().getServiceInfo(new ComponentName(this, getClass()), 128).metaData;
if (bundle == null) {
return -1;
}
return bundle.getInt(META_DATA_NAME_SMALL_ICON, -1);
} catch (PackageManager.NameNotFoundException unused) {
return -1;
}
}
@Override // android.app.Service
@MainThread
public final boolean onUnbind(@Nullable Intent intent) {
this.mVerifiedUid = -1;
return super.onUnbind(intent);
}
private static String channelNameToId(String str) {
return str.toLowerCase(Locale.ROOT).replace(' ', '_') + "_channel_id";
}
private void ensureOnCreateCalled() {
if (this.mNotificationManager == null) {
throw new IllegalStateException("TrustedWebActivityService has not been properly initialized. Did onCreate() call super.onCreate()?");
}
}
}

View File

@@ -0,0 +1,201 @@
package androidx.browser.trusted;
import android.app.Notification;
import android.content.ComponentName;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.RemoteException;
import android.support.customtabs.trusted.ITrustedWebActivityCallback;
import android.support.customtabs.trusted.ITrustedWebActivityService;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
/* loaded from: classes.dex */
public final class TrustedWebActivityServiceConnection {
private static final String KEY_ACTIVE_NOTIFICATIONS = "android.support.customtabs.trusted.ACTIVE_NOTIFICATIONS";
private static final String KEY_CHANNEL_NAME = "android.support.customtabs.trusted.CHANNEL_NAME";
private static final String KEY_NOTIFICATION = "android.support.customtabs.trusted.NOTIFICATION";
private static final String KEY_NOTIFICATION_SUCCESS = "android.support.customtabs.trusted.NOTIFICATION_SUCCESS";
private static final String KEY_PLATFORM_ID = "android.support.customtabs.trusted.PLATFORM_ID";
private static final String KEY_PLATFORM_TAG = "android.support.customtabs.trusted.PLATFORM_TAG";
private final ComponentName mComponentName;
private final ITrustedWebActivityService mService;
@NonNull
public ComponentName getComponentName() {
return this.mComponentName;
}
public TrustedWebActivityServiceConnection(@NonNull ITrustedWebActivityService iTrustedWebActivityService, @NonNull ComponentName componentName) {
this.mService = iTrustedWebActivityService;
this.mComponentName = componentName;
}
public boolean areNotificationsEnabled(@NonNull String str) throws RemoteException {
return ResultArgs.fromBundle(this.mService.areNotificationsEnabled(new NotificationsEnabledArgs(str).toBundle())).success;
}
public boolean notify(@NonNull String str, int i, @NonNull Notification notification, @NonNull String str2) throws RemoteException {
return ResultArgs.fromBundle(this.mService.notifyNotificationWithChannel(new NotifyNotificationArgs(str, i, notification, str2).toBundle())).success;
}
public void cancel(@NonNull String str, int i) throws RemoteException {
this.mService.cancelNotification(new CancelNotificationArgs(str, i).toBundle());
}
@NonNull
@RequiresApi(23)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Parcelable[] getActiveNotifications() throws RemoteException {
return ActiveNotificationsArgs.fromBundle(this.mService.getActiveNotifications()).notifications;
}
public int getSmallIconId() throws RemoteException {
return this.mService.getSmallIconId();
}
@Nullable
public Bitmap getSmallIconBitmap() throws RemoteException {
return (Bitmap) this.mService.getSmallIconBitmap().getParcelable(TrustedWebActivityService.KEY_SMALL_ICON_BITMAP);
}
@Nullable
public Bundle sendExtraCommand(@NonNull String str, @NonNull Bundle bundle, @Nullable TrustedWebActivityCallback trustedWebActivityCallback) throws RemoteException {
ITrustedWebActivityCallback wrapCallback = wrapCallback(trustedWebActivityCallback);
return this.mService.extraCommand(str, bundle, wrapCallback == null ? null : wrapCallback.asBinder());
}
public static class NotifyNotificationArgs {
public final String channelName;
public final Notification notification;
public final int platformId;
public final String platformTag;
public NotifyNotificationArgs(String str, int i, Notification notification, String str2) {
this.platformTag = str;
this.platformId = i;
this.notification = notification;
this.channelName = str2;
}
public static NotifyNotificationArgs fromBundle(Bundle bundle) {
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG);
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_PLATFORM_ID);
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_NOTIFICATION);
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME);
return new NotifyNotificationArgs(bundle.getString(TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG), bundle.getInt(TrustedWebActivityServiceConnection.KEY_PLATFORM_ID), (Notification) bundle.getParcelable(TrustedWebActivityServiceConnection.KEY_NOTIFICATION), bundle.getString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME));
}
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG, this.platformTag);
bundle.putInt(TrustedWebActivityServiceConnection.KEY_PLATFORM_ID, this.platformId);
bundle.putParcelable(TrustedWebActivityServiceConnection.KEY_NOTIFICATION, this.notification);
bundle.putString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME, this.channelName);
return bundle;
}
}
public static class CancelNotificationArgs {
public final int platformId;
public final String platformTag;
public CancelNotificationArgs(String str, int i) {
this.platformTag = str;
this.platformId = i;
}
public static CancelNotificationArgs fromBundle(Bundle bundle) {
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG);
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_PLATFORM_ID);
return new CancelNotificationArgs(bundle.getString(TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG), bundle.getInt(TrustedWebActivityServiceConnection.KEY_PLATFORM_ID));
}
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG, this.platformTag);
bundle.putInt(TrustedWebActivityServiceConnection.KEY_PLATFORM_ID, this.platformId);
return bundle;
}
}
public static class ResultArgs {
public final boolean success;
public ResultArgs(boolean z) {
this.success = z;
}
public static ResultArgs fromBundle(Bundle bundle) {
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS);
return new ResultArgs(bundle.getBoolean(TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS));
}
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putBoolean(TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS, this.success);
return bundle;
}
}
public static class ActiveNotificationsArgs {
public final Parcelable[] notifications;
public ActiveNotificationsArgs(Parcelable[] parcelableArr) {
this.notifications = parcelableArr;
}
public static ActiveNotificationsArgs fromBundle(Bundle bundle) {
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS);
return new ActiveNotificationsArgs(bundle.getParcelableArray(TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS));
}
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putParcelableArray(TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS, this.notifications);
return bundle;
}
}
public static class NotificationsEnabledArgs {
public final String channelName;
public NotificationsEnabledArgs(String str) {
this.channelName = str;
}
public static NotificationsEnabledArgs fromBundle(Bundle bundle) {
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME);
return new NotificationsEnabledArgs(bundle.getString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME));
}
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME, this.channelName);
return bundle;
}
}
public static void ensureBundleContains(Bundle bundle, String str) {
if (bundle.containsKey(str)) {
return;
}
throw new IllegalArgumentException("Bundle must contain " + str);
}
@Nullable
private static ITrustedWebActivityCallback wrapCallback(@Nullable final TrustedWebActivityCallback trustedWebActivityCallback) {
if (trustedWebActivityCallback == null) {
return null;
}
return new ITrustedWebActivityCallback.Stub() { // from class: androidx.browser.trusted.TrustedWebActivityServiceConnection.1
@Override // android.support.customtabs.trusted.ITrustedWebActivityCallback
public void onExtraCallback(String str, Bundle bundle) throws RemoteException {
TrustedWebActivityCallback.this.onExtraCallback(str, bundle);
}
};
}
}

View File

@@ -0,0 +1,160 @@
package androidx.browser.trusted;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentTransaction;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public final class TrustedWebActivityServiceConnectionPool {
private static final String TAG = "TWAConnectionPool";
private final Map<Uri, ConnectionHolder> mConnections = new HashMap();
private final Context mContext;
private TrustedWebActivityServiceConnectionPool(@NonNull Context context) {
this.mContext = context.getApplicationContext();
}
@NonNull
public static TrustedWebActivityServiceConnectionPool create(@NonNull Context context) {
return new TrustedWebActivityServiceConnectionPool(context);
}
@NonNull
@MainThread
public ListenableFuture connect(@NonNull final Uri uri, @NonNull Set<Token> set, @NonNull Executor executor) {
ConnectionHolder connectionHolder = this.mConnections.get(uri);
if (connectionHolder != null) {
return connectionHolder.getServiceWrapper();
}
Intent createServiceIntent = createServiceIntent(this.mContext, uri, set, true);
if (createServiceIntent == null) {
return FutureUtils.immediateFailedFuture(new IllegalArgumentException("No service exists for scope"));
}
ConnectionHolder connectionHolder2 = new ConnectionHolder(new Runnable() { // from class: androidx.browser.trusted.TrustedWebActivityServiceConnectionPool$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
TrustedWebActivityServiceConnectionPool.this.lambda$connect$0(uri);
}
});
this.mConnections.put(uri, connectionHolder2);
new BindToServiceAsyncTask(this.mContext, createServiceIntent, connectionHolder2).executeOnExecutor(executor, new Void[0]);
return connectionHolder2.getServiceWrapper();
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$connect$0(Uri uri) {
this.mConnections.remove(uri);
}
public static class BindToServiceAsyncTask extends AsyncTask<Void, Void, Exception> {
private final Context mAppContext;
private final ConnectionHolder mConnection;
private final Intent mIntent;
public BindToServiceAsyncTask(Context context, Intent intent, ConnectionHolder connectionHolder) {
this.mAppContext = context.getApplicationContext();
this.mIntent = intent;
this.mConnection = connectionHolder;
}
@Override // android.os.AsyncTask
@Nullable
public Exception doInBackground(Void... voidArr) {
try {
if (this.mAppContext.bindService(this.mIntent, this.mConnection, FragmentTransaction.TRANSIT_FRAGMENT_OPEN)) {
return null;
}
this.mAppContext.unbindService(this.mConnection);
return new IllegalStateException("Could not bind to the service");
} catch (SecurityException e) {
Log.w(TrustedWebActivityServiceConnectionPool.TAG, "SecurityException while binding.", e);
return e;
}
}
@Override // android.os.AsyncTask
public void onPostExecute(Exception exc) {
if (exc != null) {
this.mConnection.cancel(exc);
}
}
}
@MainThread
public boolean serviceExistsForScope(@NonNull Uri uri, @NonNull Set<Token> set) {
return (this.mConnections.get(uri) == null && createServiceIntent(this.mContext, uri, set, false) == null) ? false : true;
}
public void unbindAllConnections() {
Iterator<ConnectionHolder> it = this.mConnections.values().iterator();
while (it.hasNext()) {
this.mContext.unbindService(it.next());
}
this.mConnections.clear();
}
@Nullable
private Intent createServiceIntent(Context context, Uri uri, Set<Token> set, boolean z) {
if (set == null || set.size() == 0) {
return null;
}
Intent intent = new Intent();
intent.setData(uri);
intent.setAction("android.intent.action.VIEW");
Iterator<ResolveInfo> it = context.getPackageManager().queryIntentActivities(intent, 65536).iterator();
String str = null;
while (it.hasNext()) {
String str2 = it.next().activityInfo.packageName;
Iterator<Token> it2 = set.iterator();
while (true) {
if (!it2.hasNext()) {
break;
}
if (it2.next().matches(str2, context.getPackageManager())) {
str = str2;
break;
}
}
}
if (str == null) {
if (z) {
Log.w(TAG, "No TWA candidates for " + uri + " have been registered.");
}
return null;
}
Intent intent2 = new Intent();
intent2.setPackage(str);
intent2.setAction(TrustedWebActivityService.ACTION_TRUSTED_WEB_ACTIVITY_SERVICE);
ResolveInfo resolveService = context.getPackageManager().resolveService(intent2, 131072);
if (resolveService == null) {
if (z) {
Log.w(TAG, "Could not find TWAService for " + str);
}
return null;
}
if (z) {
StringBuilder sb = new StringBuilder();
sb.append("Found ");
sb.append(resolveService.serviceInfo.name);
sb.append(" to handle request for ");
sb.append(uri);
}
Intent intent3 = new Intent();
intent3.setComponent(new ComponentName(str, resolveService.serviceInfo.name));
return intent3;
}
}

View File

@@ -0,0 +1,46 @@
package androidx.browser.trusted.sharing;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public final class ShareData {
public static final String KEY_TEXT = "androidx.browser.trusted.sharing.KEY_TEXT";
public static final String KEY_TITLE = "androidx.browser.trusted.sharing.KEY_TITLE";
public static final String KEY_URIS = "androidx.browser.trusted.sharing.KEY_URIS";
@Nullable
public final String text;
@Nullable
public final String title;
@Nullable
public final List<Uri> uris;
public ShareData(@Nullable String str, @Nullable String str2, @Nullable List<Uri> list) {
this.title = str;
this.text = str2;
this.uris = list;
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString("androidx.browser.trusted.sharing.KEY_TITLE", this.title);
bundle.putString("androidx.browser.trusted.sharing.KEY_TEXT", this.text);
if (this.uris != null) {
bundle.putParcelableArrayList(KEY_URIS, new ArrayList<>(this.uris));
}
return bundle;
}
@NonNull
public static ShareData fromBundle(@NonNull Bundle bundle) {
return new ShareData(bundle.getString("androidx.browser.trusted.sharing.KEY_TITLE"), bundle.getString("androidx.browser.trusted.sharing.KEY_TEXT"), bundle.getParcelableArrayList(KEY_URIS));
}
}

View File

@@ -0,0 +1,170 @@
package androidx.browser.trusted.sharing;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class ShareTarget {
public static final String ENCODING_TYPE_MULTIPART = "multipart/form-data";
public static final String ENCODING_TYPE_URL_ENCODED = "application/x-www-form-urlencoded";
@SuppressLint({"IntentName"})
public static final String KEY_ACTION = "androidx.browser.trusted.sharing.KEY_ACTION";
public static final String KEY_ENCTYPE = "androidx.browser.trusted.sharing.KEY_ENCTYPE";
public static final String KEY_METHOD = "androidx.browser.trusted.sharing.KEY_METHOD";
public static final String KEY_PARAMS = "androidx.browser.trusted.sharing.KEY_PARAMS";
public static final String METHOD_GET = "GET";
public static final String METHOD_POST = "POST";
@NonNull
public final String action;
@Nullable
public final String encodingType;
@Nullable
public final String method;
@NonNull
public final Params params;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface EncodingType {
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface RequestMethod {
}
public ShareTarget(@NonNull String str, @Nullable String str2, @Nullable String str3, @NonNull Params params) {
this.action = str;
this.method = str2;
this.encodingType = str3;
this.params = params;
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(KEY_ACTION, this.action);
bundle.putString(KEY_METHOD, this.method);
bundle.putString(KEY_ENCTYPE, this.encodingType);
bundle.putBundle(KEY_PARAMS, this.params.toBundle());
return bundle;
}
@Nullable
public static ShareTarget fromBundle(@NonNull Bundle bundle) {
String string = bundle.getString(KEY_ACTION);
String string2 = bundle.getString(KEY_METHOD);
String string3 = bundle.getString(KEY_ENCTYPE);
Params fromBundle = Params.fromBundle(bundle.getBundle(KEY_PARAMS));
if (string == null || fromBundle == null) {
return null;
}
return new ShareTarget(string, string2, string3, fromBundle);
}
public static class Params {
public static final String KEY_FILES = "androidx.browser.trusted.sharing.KEY_FILES";
public static final String KEY_TEXT = "androidx.browser.trusted.sharing.KEY_TEXT";
public static final String KEY_TITLE = "androidx.browser.trusted.sharing.KEY_TITLE";
@Nullable
public final List<FileFormField> files;
@Nullable
public final String text;
@Nullable
public final String title;
public Params(@Nullable String str, @Nullable String str2, @Nullable List<FileFormField> list) {
this.title = str;
this.text = str2;
this.files = list;
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString("androidx.browser.trusted.sharing.KEY_TITLE", this.title);
bundle.putString("androidx.browser.trusted.sharing.KEY_TEXT", this.text);
if (this.files != null) {
ArrayList<? extends Parcelable> arrayList = new ArrayList<>();
Iterator<FileFormField> it = this.files.iterator();
while (it.hasNext()) {
arrayList.add(it.next().toBundle());
}
bundle.putParcelableArrayList(KEY_FILES, arrayList);
}
return bundle;
}
@Nullable
public static Params fromBundle(@Nullable Bundle bundle) {
ArrayList arrayList = null;
if (bundle == null) {
return null;
}
ArrayList parcelableArrayList = bundle.getParcelableArrayList(KEY_FILES);
if (parcelableArrayList != null) {
arrayList = new ArrayList();
Iterator it = parcelableArrayList.iterator();
while (it.hasNext()) {
arrayList.add(FileFormField.fromBundle((Bundle) it.next()));
}
}
return new Params(bundle.getString("androidx.browser.trusted.sharing.KEY_TITLE"), bundle.getString("androidx.browser.trusted.sharing.KEY_TEXT"), arrayList);
}
}
public static final class FileFormField {
public static final String KEY_ACCEPTED_TYPES = "androidx.browser.trusted.sharing.KEY_ACCEPTED_TYPES";
public static final String KEY_NAME = "androidx.browser.trusted.sharing.KEY_FILE_NAME";
@NonNull
public final List<String> acceptedTypes;
@NonNull
public final String name;
public FileFormField(@NonNull String str, @NonNull List<String> list) {
this.name = str;
this.acceptedTypes = Collections.unmodifiableList(list);
}
@NonNull
public Bundle toBundle() {
Bundle bundle = new Bundle();
bundle.putString(KEY_NAME, this.name);
bundle.putStringArrayList(KEY_ACCEPTED_TYPES, new ArrayList<>(this.acceptedTypes));
return bundle;
}
@Nullable
public static FileFormField fromBundle(@Nullable Bundle bundle) {
if (bundle == null) {
return null;
}
String string = bundle.getString(KEY_NAME);
ArrayList<String> stringArrayList = bundle.getStringArrayList(KEY_ACCEPTED_TYPES);
if (string == null || stringArrayList == null) {
return null;
}
return new FileFormField(string, stringArrayList);
}
}
}

View File

@@ -0,0 +1,13 @@
package androidx.browser.trusted.splashscreens;
/* loaded from: classes.dex */
public final class SplashScreenParamKey {
public static final String KEY_BACKGROUND_COLOR = "androidx.browser.trusted.trusted.KEY_SPLASH_SCREEN_BACKGROUND_COLOR";
public static final String KEY_FADE_OUT_DURATION_MS = "androidx.browser.trusted.KEY_SPLASH_SCREEN_FADE_OUT_DURATION";
public static final String KEY_IMAGE_TRANSFORMATION_MATRIX = "androidx.browser.trusted.KEY_SPLASH_SCREEN_TRANSFORMATION_MATRIX";
public static final String KEY_SCALE_TYPE = "androidx.browser.trusted.KEY_SPLASH_SCREEN_SCALE_TYPE";
public static final String KEY_VERSION = "androidx.browser.trusted.KEY_SPLASH_SCREEN_VERSION";
private SplashScreenParamKey() {
}
}

View File

@@ -0,0 +1,9 @@
package androidx.browser.trusted.splashscreens;
/* loaded from: classes.dex */
public final class SplashScreenVersion {
public static final String V1 = "androidx.browser.trusted.category.TrustedWebActivitySplashScreensV1";
private SplashScreenVersion() {
}
}