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-08-18 07:29:27 +00:00
|
|
|
public class AnonymousClass1 extends a.AbstractBinderC0351a {
|
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) {
|
2021-08-09 22:50:52 +00:00
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS);
|
|
|
|
return new ActiveNotificationsArgs(bundle.getParcelableArray(TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
2021-08-09 22:50:52 +00:00
|
|
|
bundle.putParcelableArray(TrustedWebActivityServiceConnection.KEY_ACTIVE_NOTIFICATIONS, this.notifications);
|
2021-06-27 20:44:35 +00:00
|
|
|
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) {
|
2021-08-09 22:50:52 +00:00
|
|
|
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));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
2021-08-09 22:50:52 +00:00
|
|
|
bundle.putString(TrustedWebActivityServiceConnection.KEY_PLATFORM_TAG, this.platformTag);
|
|
|
|
bundle.putInt(TrustedWebActivityServiceConnection.KEY_PLATFORM_ID, this.platformId);
|
2021-06-27 20:44:35 +00:00
|
|
|
return bundle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class NotificationsEnabledArgs {
|
|
|
|
public final String channelName;
|
|
|
|
|
|
|
|
public NotificationsEnabledArgs(String str) {
|
|
|
|
this.channelName = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static NotificationsEnabledArgs fromBundle(Bundle bundle) {
|
2021-08-09 22:50:52 +00:00
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME);
|
|
|
|
return new NotificationsEnabledArgs(bundle.getString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
2021-08-09 22:50:52 +00:00
|
|
|
bundle.putString(TrustedWebActivityServiceConnection.KEY_CHANNEL_NAME, this.channelName);
|
2021-06-27 20:44:35 +00:00
|
|
|
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) {
|
2021-08-09 22:50:52 +00:00
|
|
|
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));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
2021-08-09 22:50:52 +00:00
|
|
|
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);
|
2021-06-27 20:44:35 +00:00
|
|
|
return bundle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class ResultArgs {
|
|
|
|
public final boolean success;
|
|
|
|
|
|
|
|
public ResultArgs(boolean z2) {
|
|
|
|
this.success = z2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ResultArgs fromBundle(Bundle bundle) {
|
2021-08-09 22:50:52 +00:00
|
|
|
TrustedWebActivityServiceConnection.ensureBundleContains(bundle, TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS);
|
|
|
|
return new ResultArgs(bundle.getBoolean(TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Bundle toBundle() {
|
|
|
|
Bundle bundle = new Bundle();
|
2021-08-09 22:50:52 +00:00
|
|
|
bundle.putBoolean(TrustedWebActivityServiceConnection.KEY_NOTIFICATION_SUCCESS, this.success);
|
2021-06-27 20:44:35 +00:00
|
|
|
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-08-31 07:21:49 +00:00
|
|
|
throw new IllegalArgumentException(c.d.b.a.a.u("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 {
|
2021-08-09 22:50:52 +00:00
|
|
|
return (Bitmap) this.mService.getSmallIconBitmap().getParcelable(TrustedWebActivityService.KEY_SMALL_ICON_BITMAP);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|