213 lines
7.7 KiB
Java
213 lines
7.7 KiB
Java
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.util.Log;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.app.BundleCompat;
|
|
import x.a.a.a;
|
|
public class CustomTabsSessionToken {
|
|
private static final String TAG = "CustomTabsSessionToken";
|
|
@Nullable
|
|
private final CustomTabsCallback mCallback;
|
|
@Nullable
|
|
public final a mCallbackBinder;
|
|
@Nullable
|
|
private final PendingIntent mSessionId;
|
|
|
|
/* renamed from: androidx.browser.customtabs.CustomTabsSessionToken$1 reason: invalid class name */
|
|
public class AnonymousClass1 extends CustomTabsCallback {
|
|
public AnonymousClass1() {
|
|
}
|
|
|
|
@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", "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", "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", "RemoteException during ICustomTabsCallback transaction");
|
|
}
|
|
}
|
|
|
|
@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", "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", "RemoteException during ICustomTabsCallback transaction");
|
|
}
|
|
}
|
|
|
|
@Override // androidx.browser.customtabs.CustomTabsCallback
|
|
public void onRelationshipValidationResult(int i, @NonNull Uri uri, boolean z2, @Nullable Bundle bundle) {
|
|
try {
|
|
CustomTabsSessionToken.this.mCallbackBinder.onRelationshipValidationResult(i, uri, z2, bundle);
|
|
} catch (RemoteException unused) {
|
|
Log.e("CustomTabsSessionToken", "RemoteException during ICustomTabsCallback transaction");
|
|
}
|
|
}
|
|
}
|
|
|
|
public static class MockCallback extends a.AbstractBinderC0345a {
|
|
@Override // x.a.a.a.AbstractBinderC0345a, android.os.IInterface
|
|
public IBinder asBinder() {
|
|
return this;
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public void extraCallback(String str, Bundle bundle) {
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public Bundle extraCallbackWithResult(String str, Bundle bundle) {
|
|
return null;
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public void onMessageChannelReady(Bundle bundle) {
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public void onNavigationEvent(int i, Bundle bundle) {
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public void onPostMessage(String str, Bundle bundle) {
|
|
}
|
|
|
|
@Override // x.a.a.a
|
|
public void onRelationshipValidationResult(int i, Uri uri, boolean z2, Bundle bundle) {
|
|
}
|
|
}
|
|
|
|
public CustomTabsSessionToken(@Nullable a aVar, @Nullable PendingIntent pendingIntent) {
|
|
if (aVar == null && pendingIntent == null) {
|
|
throw new IllegalStateException("CustomTabsSessionToken must have either a session id or a callback (or both).");
|
|
}
|
|
this.mCallbackBinder = aVar;
|
|
this.mSessionId = pendingIntent;
|
|
this.mCallback = aVar == null ? null : new AnonymousClass1();
|
|
}
|
|
|
|
@NonNull
|
|
public static CustomTabsSessionToken createMockSessionTokenForTesting() {
|
|
return new CustomTabsSessionToken(new MockCallback(), null);
|
|
}
|
|
|
|
private IBinder getCallbackBinderAssertNotNull() {
|
|
a aVar = this.mCallbackBinder;
|
|
if (aVar != null) {
|
|
return aVar.asBinder();
|
|
}
|
|
throw new IllegalStateException("CustomTabSessionToken must have valid binder or pending session");
|
|
}
|
|
|
|
@Nullable
|
|
public static CustomTabsSessionToken getSessionTokenFromIntent(@NonNull Intent intent) {
|
|
Bundle extras = intent.getExtras();
|
|
a aVar = null;
|
|
if (extras == null) {
|
|
return null;
|
|
}
|
|
IBinder binder = BundleCompat.getBinder(extras, "android.support.customtabs.extra.SESSION");
|
|
PendingIntent pendingIntent = (PendingIntent) intent.getParcelableExtra("android.support.customtabs.extra.SESSION_ID");
|
|
if (binder == null && pendingIntent == null) {
|
|
return null;
|
|
}
|
|
if (binder != null) {
|
|
aVar = a.AbstractBinderC0345a.asInterface(binder);
|
|
}
|
|
return new CustomTabsSessionToken(aVar, pendingIntent);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof CustomTabsSessionToken)) {
|
|
return false;
|
|
}
|
|
CustomTabsSessionToken customTabsSessionToken = (CustomTabsSessionToken) obj;
|
|
PendingIntent id2 = customTabsSessionToken.getId();
|
|
PendingIntent pendingIntent = this.mSessionId;
|
|
boolean z2 = true;
|
|
boolean z3 = pendingIntent == null;
|
|
if (id2 != null) {
|
|
z2 = false;
|
|
}
|
|
if (z3 != z2) {
|
|
return false;
|
|
}
|
|
return pendingIntent != null ? pendingIntent.equals(id2) : getCallbackBinderAssertNotNull().equals(customTabsSessionToken.getCallbackBinderAssertNotNull());
|
|
}
|
|
|
|
@Nullable
|
|
public CustomTabsCallback getCallback() {
|
|
return this.mCallback;
|
|
}
|
|
|
|
@Nullable
|
|
public IBinder getCallbackBinder() {
|
|
a aVar = this.mCallbackBinder;
|
|
if (aVar == null) {
|
|
return null;
|
|
}
|
|
return aVar.asBinder();
|
|
}
|
|
|
|
@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;
|
|
}
|
|
|
|
public int hashCode() {
|
|
PendingIntent pendingIntent = this.mSessionId;
|
|
return pendingIntent != null ? pendingIntent.hashCode() : getCallbackBinderAssertNotNull().hashCode();
|
|
}
|
|
|
|
public boolean isAssociatedWith(@NonNull CustomTabsSession customTabsSession) {
|
|
return customTabsSession.getBinder().equals(this.mCallbackBinder);
|
|
}
|
|
}
|