2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.utilities.fcm;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.app.Application;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import androidx.collection.ArrayMap;
|
|
|
|
import androidx.core.app.FrameMetricsAggregator;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import c.i.c.c;
|
|
|
|
import c.i.c.w.i;
|
|
|
|
import com.discord.app.AppLog;
|
|
|
|
import com.discord.utilities.logging.Logger;
|
|
|
|
import com.discord.utilities.persister.Persister;
|
|
|
|
import com.discord.utilities.rest.RestAPI;
|
|
|
|
import com.google.firebase.messaging.FirebaseMessaging;
|
|
|
|
import com.google.firebase.messaging.FirebaseMessagingService;
|
|
|
|
import com.google.firebase.messaging.RemoteMessage;
|
|
|
|
import d0.o;
|
|
|
|
import d0.t.h0;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import kotlin.Unit;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
/* compiled from: NotificationClient.kt */
|
|
|
|
@SuppressLint({"StaticFieldLeak"})
|
|
|
|
public final class NotificationClient {
|
|
|
|
public static final NotificationClient INSTANCE = new NotificationClient();
|
|
|
|
public static final String NOTIF_CHANNEL_CALLS = "Calls";
|
|
|
|
public static final String NOTIF_CHANNEL_GAME_DETECTION = "Game Detection";
|
|
|
|
public static final String NOTIF_CHANNEL_MEDIA_CONNECTIONS = "Media Connections";
|
|
|
|
public static final String NOTIF_CHANNEL_MESSAGES = "Messages";
|
|
|
|
public static final String NOTIF_CHANNEL_MESSAGES_DIRECT = "DirectMessages";
|
|
|
|
public static final String NOTIF_CHANNEL_SOCIAL = "Social";
|
|
|
|
public static final String NOTIF_CHANNEL_STAGE_START = "Stage Live";
|
|
|
|
public static final String NOTIF_GUILD_SCHEDULED_EVENT_START = "Guild Event Live";
|
|
|
|
private static Context context;
|
|
|
|
private static boolean isBackgrounded = true;
|
|
|
|
private static final Persister<SettingsV2> settings = new Persister<>("NOTIFICATION_CLIENT_SETTINGS_V3", new SettingsV2(false, false, false, false, false, false, null, null, null, FrameMetricsAggregator.EVERY_DURATION, null));
|
|
|
|
private static String token;
|
|
|
|
private static Function1<? super String, Unit> tokenCallback = NotificationClient$tokenCallback$1.INSTANCE;
|
|
|
|
|
|
|
|
/* compiled from: NotificationClient.kt */
|
|
|
|
public static final class FCMMessagingService extends FirebaseMessagingService {
|
|
|
|
@Override // com.google.firebase.messaging.FirebaseMessagingService
|
|
|
|
public void onMessageReceived(RemoteMessage remoteMessage) {
|
|
|
|
m.checkNotNullParameter(remoteMessage, "remoteMessage");
|
|
|
|
super.onMessageReceived(remoteMessage);
|
|
|
|
if (remoteMessage.j == null) {
|
|
|
|
Bundle bundle = remoteMessage.i;
|
|
|
|
ArrayMap arrayMap = new ArrayMap();
|
|
|
|
for (String str : bundle.keySet()) {
|
|
|
|
Object obj = bundle.get(str);
|
|
|
|
if (obj instanceof String) {
|
|
|
|
String str2 = (String) obj;
|
|
|
|
if (!str.startsWith("google.") && !str.startsWith("gcm.") && !str.equals("from") && !str.equals("message_type") && !str.equals("collapse_key")) {
|
|
|
|
arrayMap.put(str, str2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
remoteMessage.j = arrayMap;
|
|
|
|
}
|
|
|
|
Map<String, String> map = remoteMessage.j;
|
|
|
|
m.checkNotNullExpressionValue(map, "remoteMessage.data");
|
|
|
|
AppLog.i("Got notification: " + map);
|
|
|
|
NotificationData notificationData = new NotificationData(map);
|
|
|
|
SettingsV2 settings$app_productionBetaRelease = NotificationClient.INSTANCE.getSettings$app_productionBetaRelease();
|
|
|
|
for (Long l : notificationData.getAckChannelIds()) {
|
|
|
|
long longValue = l.longValue();
|
|
|
|
NotificationClient notificationClient = NotificationClient.INSTANCE;
|
|
|
|
notificationClient.clear(longValue, NotificationClient.access$getContext$p(notificationClient), true);
|
|
|
|
}
|
|
|
|
NotificationClient notificationClient2 = NotificationClient.INSTANCE;
|
|
|
|
Context access$getContext$p = NotificationClient.access$getContext$p(notificationClient2);
|
|
|
|
if (access$getContext$p == null) {
|
|
|
|
Logger.e$default(AppLog.g, "Not showing notification because context was null.", null, null, 6, null);
|
|
|
|
} else if (notificationData.isValid() && settings$app_productionBetaRelease.isAuthed()) {
|
|
|
|
if (notificationData.getChannelId() != -1) {
|
|
|
|
NotificationCache.INSTANCE.setIgnoreNextClearForAck(notificationData.getChannelId(), false);
|
|
|
|
}
|
|
|
|
if (NotificationClient.access$isBackgrounded$p(notificationClient2) && settings$app_productionBetaRelease.isEnabled()) {
|
|
|
|
NotificationRenderer.INSTANCE.display(access$getContext$p, notificationData, settings$app_productionBetaRelease);
|
|
|
|
} else if (!NotificationClient.access$isBackgrounded$p(notificationClient2) && settings$app_productionBetaRelease.isEnabledInApp()) {
|
|
|
|
NotificationRenderer.INSTANCE.displayInApp(access$getContext$p, notificationData);
|
|
|
|
}
|
|
|
|
} else if (m.areEqual(notificationData.getType(), NotificationData.TYPE_MESSAGE_CREATE)) {
|
|
|
|
Logger.e$default(AppLog.g, "Not showing invalid notification", null, h0.mapOf(o.to("messageId", String.valueOf(notificationData.getMessageId())), o.to("channelId", String.valueOf(notificationData.getChannelId())), o.to("isAuthed", String.valueOf(settings$app_productionBetaRelease.isAuthed())), o.to("type", notificationData.getType())), 2, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.google.firebase.messaging.FirebaseMessagingService
|
|
|
|
public void onNewToken(String str) {
|
|
|
|
m.checkNotNullParameter(str, "token");
|
|
|
|
NotificationClient.INSTANCE.onNewToken(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: NotificationClient.kt */
|
|
|
|
public static final class SettingsV2 {
|
|
|
|
private final boolean isAuthed;
|
|
|
|
private final boolean isDisableBlink;
|
|
|
|
private final boolean isDisableSound;
|
|
|
|
private final boolean isDisableVibrate;
|
|
|
|
private final boolean isEnabled;
|
|
|
|
private final boolean isEnabledInApp;
|
|
|
|
private final boolean isWake;
|
|
|
|
private final String locale;
|
|
|
|
private final Set<Long> sendBlockedChannels;
|
|
|
|
private final String token;
|
|
|
|
|
|
|
|
public SettingsV2() {
|
|
|
|
this(false, false, false, false, false, false, null, null, null, FrameMetricsAggregator.EVERY_DURATION, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SettingsV2(boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, String str, String str2, Set<Long> set) {
|
|
|
|
m.checkNotNullParameter(str2, "locale");
|
|
|
|
m.checkNotNullParameter(set, "sendBlockedChannels");
|
|
|
|
this.isEnabled = z2;
|
|
|
|
this.isEnabledInApp = z3;
|
|
|
|
this.isWake = z4;
|
|
|
|
this.isDisableBlink = z5;
|
|
|
|
this.isDisableSound = z6;
|
|
|
|
this.isDisableVibrate = z7;
|
|
|
|
this.token = str;
|
|
|
|
this.locale = str2;
|
|
|
|
this.sendBlockedChannels = set;
|
|
|
|
this.isAuthed = str != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ SettingsV2(boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, String str, String str2, Set set, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this((i & 1) != 0 ? true : z2, (i & 2) == 0 ? z3 : true, (i & 4) != 0 ? false : z4, (i & 8) != 0 ? false : z5, (i & 16) != 0 ? false : z6, (i & 32) != 0 ? false : z7, (i & 64) != 0 ? null : str, (i & 128) != 0 ? "" : str2, (i & 256) != 0 ? new HashSet(0) : set);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ SettingsV2 copy$default(SettingsV2 settingsV2, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, String str, String str2, Set set, int i, Object obj) {
|
|
|
|
return settingsV2.copy((i & 1) != 0 ? settingsV2.isEnabled : z2, (i & 2) != 0 ? settingsV2.isEnabledInApp : z3, (i & 4) != 0 ? settingsV2.isWake : z4, (i & 8) != 0 ? settingsV2.isDisableBlink : z5, (i & 16) != 0 ? settingsV2.isDisableSound : z6, (i & 32) != 0 ? settingsV2.isDisableVibrate : z7, (i & 64) != 0 ? settingsV2.token : str, (i & 128) != 0 ? settingsV2.locale : str2, (i & 256) != 0 ? settingsV2.sendBlockedChannels : set);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component1() {
|
|
|
|
return this.isEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component2() {
|
|
|
|
return this.isEnabledInApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component3() {
|
|
|
|
return this.isWake;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component4() {
|
|
|
|
return this.isDisableBlink;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component5() {
|
|
|
|
return this.isDisableSound;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component6() {
|
|
|
|
return this.isDisableVibrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String component7() {
|
|
|
|
return this.token;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String component8() {
|
|
|
|
return this.locale;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Set<Long> component9() {
|
|
|
|
return this.sendBlockedChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final SettingsV2 copy(boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, String str, String str2, Set<Long> set) {
|
|
|
|
m.checkNotNullParameter(str2, "locale");
|
|
|
|
m.checkNotNullParameter(set, "sendBlockedChannels");
|
|
|
|
return new SettingsV2(z2, z3, z4, z5, z6, z7, str, str2, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof SettingsV2)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
SettingsV2 settingsV2 = (SettingsV2) obj;
|
|
|
|
return this.isEnabled == settingsV2.isEnabled && this.isEnabledInApp == settingsV2.isEnabledInApp && this.isWake == settingsV2.isWake && this.isDisableBlink == settingsV2.isDisableBlink && this.isDisableSound == settingsV2.isDisableSound && this.isDisableVibrate == settingsV2.isDisableVibrate && m.areEqual(this.token, settingsV2.token) && m.areEqual(this.locale, settingsV2.locale) && m.areEqual(this.sendBlockedChannels, settingsV2.sendBlockedChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getLocale() {
|
|
|
|
return this.locale;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Set<Long> getSendBlockedChannels() {
|
|
|
|
return this.sendBlockedChannels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final String getToken() {
|
|
|
|
return this.token;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
boolean z2 = this.isEnabled;
|
|
|
|
int i = 1;
|
|
|
|
if (z2) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
int i2 = z2 ? 1 : 0;
|
|
|
|
int i3 = z2 ? 1 : 0;
|
|
|
|
int i4 = z2 ? 1 : 0;
|
|
|
|
int i5 = i2 * 31;
|
|
|
|
boolean z3 = this.isEnabledInApp;
|
|
|
|
if (z3) {
|
|
|
|
z3 = true;
|
|
|
|
}
|
|
|
|
int i6 = z3 ? 1 : 0;
|
|
|
|
int i7 = z3 ? 1 : 0;
|
|
|
|
int i8 = z3 ? 1 : 0;
|
|
|
|
int i9 = (i5 + i6) * 31;
|
|
|
|
boolean z4 = this.isWake;
|
|
|
|
if (z4) {
|
|
|
|
z4 = true;
|
|
|
|
}
|
|
|
|
int i10 = z4 ? 1 : 0;
|
|
|
|
int i11 = z4 ? 1 : 0;
|
|
|
|
int i12 = z4 ? 1 : 0;
|
|
|
|
int i13 = (i9 + i10) * 31;
|
|
|
|
boolean z5 = this.isDisableBlink;
|
|
|
|
if (z5) {
|
|
|
|
z5 = true;
|
|
|
|
}
|
|
|
|
int i14 = z5 ? 1 : 0;
|
|
|
|
int i15 = z5 ? 1 : 0;
|
|
|
|
int i16 = z5 ? 1 : 0;
|
|
|
|
int i17 = (i13 + i14) * 31;
|
|
|
|
boolean z6 = this.isDisableSound;
|
|
|
|
if (z6) {
|
|
|
|
z6 = true;
|
|
|
|
}
|
|
|
|
int i18 = z6 ? 1 : 0;
|
|
|
|
int i19 = z6 ? 1 : 0;
|
|
|
|
int i20 = z6 ? 1 : 0;
|
|
|
|
int i21 = (i17 + i18) * 31;
|
|
|
|
boolean z7 = this.isDisableVibrate;
|
|
|
|
if (!z7) {
|
|
|
|
i = z7 ? 1 : 0;
|
|
|
|
}
|
|
|
|
int i22 = (i21 + i) * 31;
|
|
|
|
String str = this.token;
|
|
|
|
int i23 = 0;
|
|
|
|
int hashCode = (i22 + (str != null ? str.hashCode() : 0)) * 31;
|
|
|
|
String str2 = this.locale;
|
|
|
|
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
|
|
|
|
Set<Long> set = this.sendBlockedChannels;
|
|
|
|
if (set != null) {
|
|
|
|
i23 = set.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode2 + i23;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isAuthed() {
|
|
|
|
return this.isAuthed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isDisableBlink() {
|
|
|
|
return this.isDisableBlink;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isDisableSound() {
|
|
|
|
return this.isDisableSound;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isDisableVibrate() {
|
|
|
|
return this.isDisableVibrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isEnabled() {
|
|
|
|
return this.isEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isEnabledInApp() {
|
|
|
|
return this.isEnabledInApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isWake() {
|
|
|
|
return this.isWake;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-08-18 07:29:27 +00:00
|
|
|
StringBuilder L = a.L("SettingsV2(isEnabled=");
|
|
|
|
L.append(this.isEnabled);
|
|
|
|
L.append(", isEnabledInApp=");
|
|
|
|
L.append(this.isEnabledInApp);
|
|
|
|
L.append(", isWake=");
|
|
|
|
L.append(this.isWake);
|
|
|
|
L.append(", isDisableBlink=");
|
|
|
|
L.append(this.isDisableBlink);
|
|
|
|
L.append(", isDisableSound=");
|
|
|
|
L.append(this.isDisableSound);
|
|
|
|
L.append(", isDisableVibrate=");
|
|
|
|
L.append(this.isDisableVibrate);
|
|
|
|
L.append(", token=");
|
|
|
|
L.append(this.token);
|
|
|
|
L.append(", locale=");
|
|
|
|
L.append(this.locale);
|
|
|
|
L.append(", sendBlockedChannels=");
|
|
|
|
L.append(this.sendBlockedChannels);
|
|
|
|
L.append(")");
|
|
|
|
return L.toString();
|
2021-08-09 22:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private NotificationClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Context access$getContext$p(NotificationClient notificationClient) {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ boolean access$isBackgrounded$p(NotificationClient notificationClient) {
|
|
|
|
return isBackgrounded;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setBackgrounded$p(NotificationClient notificationClient, boolean z2) {
|
|
|
|
isBackgrounded = z2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setContext$p(NotificationClient notificationClient, Context context2) {
|
|
|
|
context = context2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ void clear$default(NotificationClient notificationClient, long j, Context context2, boolean z2, int i, Object obj) {
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
context2 = null;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
z2 = false;
|
|
|
|
}
|
|
|
|
notificationClient.clear(j, context2, z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<String, Object> buildTrackingData(Intent intent) {
|
|
|
|
return NotificationData.Companion.buildTrackingData(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void clear(long j, Context context2, boolean z2) {
|
|
|
|
NotificationRenderer notificationRenderer = NotificationRenderer.INSTANCE;
|
|
|
|
if (context2 == null) {
|
|
|
|
context2 = context;
|
|
|
|
}
|
|
|
|
notificationRenderer.clear(context2, j, z2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final synchronized SettingsV2 getSettings$app_productionBetaRelease() {
|
|
|
|
return settings.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
@TargetApi(26)
|
|
|
|
public final void init(Application application) {
|
|
|
|
FirebaseMessaging instance;
|
|
|
|
m.checkNotNullParameter(application, "application");
|
|
|
|
context = application;
|
|
|
|
if (isOsLevelNotificationEnabled()) {
|
|
|
|
NotificationRenderer.INSTANCE.initNotificationChannels(application);
|
|
|
|
}
|
|
|
|
RestAPI.AppHeadersProvider.authTokenProvider = NotificationClient$init$1.INSTANCE;
|
|
|
|
RestAPI.AppHeadersProvider.localeProvider = NotificationClient$init$2.INSTANCE;
|
|
|
|
try {
|
|
|
|
synchronized (FirebaseMessaging.class) {
|
|
|
|
instance = FirebaseMessaging.getInstance(c.b());
|
|
|
|
}
|
|
|
|
m.checkNotNullExpressionValue(instance, "FirebaseMessaging.getInstance()");
|
|
|
|
m.checkNotNullExpressionValue(instance.d.f().h(i.a).b(NotificationClient$init$3.INSTANCE), "FirebaseMessaging.getIns…eption)\n }\n }");
|
|
|
|
} catch (IllegalStateException e) {
|
|
|
|
AppLog.g.w("FCM service start error", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final synchronized boolean isAuthed() {
|
|
|
|
return settings.get().isAuthed();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isOsLevelNotificationEnabled() {
|
|
|
|
return Build.VERSION.SDK_INT >= 26;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final synchronized void onNewToken(String str) {
|
|
|
|
AppLog appLog = AppLog.g;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append("FCM token received. hash=");
|
|
|
|
sb.append(str != null ? Integer.valueOf(str.hashCode()) : null);
|
|
|
|
Logger.d$default(appLog, sb.toString(), null, 2, null);
|
|
|
|
token = str;
|
|
|
|
tokenCallback.invoke(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final synchronized void setRegistrationIdReceived(Function1<? super String, Unit> function1) {
|
|
|
|
m.checkNotNullParameter(function1, "onDeviceRegistrationIdReceived");
|
|
|
|
tokenCallback = function1;
|
|
|
|
function1.invoke(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final synchronized void updateSettings$app_productionBetaRelease(SettingsV2 settingsV2, boolean z2) {
|
|
|
|
m.checkNotNullParameter(settingsV2, "settings");
|
|
|
|
settings.set(settingsV2, z2);
|
|
|
|
isBackgrounded = z2;
|
|
|
|
}
|
|
|
|
}
|