alexandroid/decompiled/jadx/sources/com/google/firebase/messaging/TopicOperation.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

89 lines
3 KiB
Java

package com.google.firebase.messaging;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.exifinterface.media.ExifInterface;
import com.google.android.gms.common.internal.Objects;
import defpackage.a$$ExternalSyntheticOutline0;
import java.util.regex.Pattern;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes8.dex */
final class TopicOperation {
private static final String OLD_TOPIC_PREFIX = "/topics/";
@VisibleForTesting
static final String OPERATION_PAIR_DIVIDER = "!";
private static final String TOPIC_NAME_PATTERN = "[a-zA-Z0-9-_.~%]{1,900}";
private static final Pattern TOPIC_NAME_REGEXP = Pattern.compile(TOPIC_NAME_PATTERN);
private final String operation;
private final String serializedString;
private final String topic;
private TopicOperation(String str, String str2) {
this.topic = normalizeTopicOrThrow(str2, str);
this.operation = str;
this.serializedString = a$$ExternalSyntheticOutline0.m$1(str, "!", str2);
}
@Nullable
public static TopicOperation from(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
String[] split = str.split("!", -1);
if (split.length != 2) {
return null;
}
return new TopicOperation(split[0], split[1]);
}
@NonNull
private static String normalizeTopicOrThrow(String str, String str2) {
if (str != null && str.startsWith(OLD_TOPIC_PREFIX)) {
Log.w(Constants.TAG, "Format /topics/topic-name is deprecated. Only 'topic-name' should be used in " + str2 + ".");
str = str.substring(8);
}
if (str != null && TOPIC_NAME_REGEXP.matcher(str).matches()) {
return str;
}
Single$$ExternalSyntheticBUOutline0.m$3(a$$ExternalSyntheticOutline0.m("Invalid topic name: ", str, " does not match the allowed format [a-zA-Z0-9-_.~%]{1,900}."));
return null;
}
public static TopicOperation subscribe(@NonNull String str) {
return new TopicOperation(ExifInterface.LATITUDE_SOUTH, str);
}
public static TopicOperation unsubscribe(@NonNull String str) {
return new TopicOperation("U", str);
}
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof TopicOperation)) {
return false;
}
TopicOperation topicOperation = (TopicOperation) obj;
return this.topic.equals(topicOperation.topic) && this.operation.equals(topicOperation.operation);
}
public String getOperation() {
return this.operation;
}
public String getTopic() {
return this.topic;
}
public int hashCode() {
return Objects.hashCode(this.operation, this.topic);
}
public String serialize() {
return this.serializedString;
}
}