2021-06-27 20:44:35 +00:00
|
|
|
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 androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import androidx.annotation.RestrictTo;
|
|
|
|
import x.a.a.d.a;
|
|
|
|
import x.a.a.d.b;
|
|
|
|
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 b mService;
|
|
|
|
|
|
|
|
/* renamed from: androidx.browser.trusted.TrustedWebActivityServiceConnection$1 reason: invalid class name */
|
2021-07-22 07:57:51 +00:00
|
|
|
public class AnonymousClass1 extends a.AbstractBinderC0349a {
|
2021-06-27 20:44:35 +00:00
|
|
|
public final /* synthetic */ TrustedWebActivityCallback val$callback;
|
|
|
|
|
|
|
|
public AnonymousClass1(TrustedWebActivityCallback trustedWebActivityCallback) {
|
|
|
|
this.val$callback = trustedWebActivityCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // x.a.a.d.a
|
|
|
|
public void onExtraCallback(String str, Bundle bundle) throws RemoteException {
|
|
|
|
this.val$callback.onExtraCallback(str, 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, "android.support.customtabs.trusted.ACTIVE_NOTIFICATIONS");
|
|
|
|
return new ActiveNotificationsArgs(bundle.getParcelableArray("android.support.customtabs.trusted.ACTIVE_NOTIFICATIONS"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putParcelableArray("android.support.customtabs.trusted.ACTIVE_NOTIFICATIONS", this.notifications);
|
|
|
|
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, "android.support.customtabs.trusted.PLATFORM_TAG");
|
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, "android.support.customtabs.trusted.PLATFORM_ID");
|
|
|
|
return new CancelNotificationArgs(bundle.getString("android.support.customtabs.trusted.PLATFORM_TAG"), bundle.getInt("android.support.customtabs.trusted.PLATFORM_ID"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putString("android.support.customtabs.trusted.PLATFORM_TAG", this.platformTag);
|
|
|
|
bundle.putInt("android.support.customtabs.trusted.PLATFORM_ID", this.platformId);
|
|
|
|
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, "android.support.customtabs.trusted.CHANNEL_NAME");
|
|
|
|
return new NotificationsEnabledArgs(bundle.getString("android.support.customtabs.trusted.CHANNEL_NAME"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putString("android.support.customtabs.trusted.CHANNEL_NAME", this.channelName);
|
|
|
|
return bundle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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, "android.support.customtabs.trusted.PLATFORM_TAG");
|
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, "android.support.customtabs.trusted.PLATFORM_ID");
|
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, "android.support.customtabs.trusted.NOTIFICATION");
|
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, "android.support.customtabs.trusted.CHANNEL_NAME");
|
|
|
|
return new NotifyNotificationArgs(bundle.getString("android.support.customtabs.trusted.PLATFORM_TAG"), bundle.getInt("android.support.customtabs.trusted.PLATFORM_ID"), (Notification) bundle.getParcelable("android.support.customtabs.trusted.NOTIFICATION"), bundle.getString("android.support.customtabs.trusted.CHANNEL_NAME"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putString("android.support.customtabs.trusted.PLATFORM_TAG", this.platformTag);
|
|
|
|
bundle.putInt("android.support.customtabs.trusted.PLATFORM_ID", this.platformId);
|
|
|
|
bundle.putParcelable("android.support.customtabs.trusted.NOTIFICATION", this.notification);
|
|
|
|
bundle.putString("android.support.customtabs.trusted.CHANNEL_NAME", this.channelName);
|
|
|
|
return bundle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ResultArgs {
|
|
|
|
public final boolean success;
|
|
|
|
|
|
|
|
public ResultArgs(boolean z2) {
|
|
|
|
this.success = z2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ResultArgs fromBundle(Bundle bundle) {
|
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, "android.support.customtabs.trusted.NOTIFICATION_SUCCESS");
|
|
|
|
return new ResultArgs(bundle.getBoolean("android.support.customtabs.trusted.NOTIFICATION_SUCCESS"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putBoolean("android.support.customtabs.trusted.NOTIFICATION_SUCCESS", this.success);
|
|
|
|
return bundle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TrustedWebActivityServiceConnection(@NonNull b bVar, @NonNull ComponentName componentName) {
|
|
|
|
this.mService = bVar;
|
|
|
|
this.mComponentName = componentName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void ensureBundleContains(Bundle bundle, String str) {
|
|
|
|
if (!bundle.containsKey(str)) {
|
2021-07-19 19:45:22 +00:00
|
|
|
throw new IllegalArgumentException(c.d.b.a.a.s("Bundle must contain ", str));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
private static a wrapCallback(@Nullable TrustedWebActivityCallback trustedWebActivityCallback) {
|
|
|
|
if (trustedWebActivityCallback == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new AnonymousClass1(trustedWebActivityCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean areNotificationsEnabled(@NonNull String str) throws RemoteException {
|
|
|
|
return ResultArgs.fromBundle(this.mService.areNotificationsEnabled(new NotificationsEnabledArgs(str).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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public ComponentName getComponentName() {
|
|
|
|
return this.mComponentName;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Bitmap getSmallIconBitmap() throws RemoteException {
|
|
|
|
return (Bitmap) this.mService.getSmallIconBitmap().getParcelable("android.support.customtabs.trusted.SMALL_ICON_BITMAP");
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSmallIconId() throws RemoteException {
|
|
|
|
return this.mService.getSmallIconId();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Bundle sendExtraCommand(@NonNull String str, @NonNull Bundle bundle, @Nullable TrustedWebActivityCallback trustedWebActivityCallback) throws RemoteException {
|
|
|
|
a wrapCallback = wrapCallback(trustedWebActivityCallback);
|
|
|
|
return this.mService.extraCommand(str, bundle, wrapCallback == null ? null : wrapCallback.asBinder());
|
|
|
|
}
|
|
|
|
}
|