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,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() {
}
}