Rabbit-R1/android (non root)/smali/smali_classes3/io/sentry/util/StringUtils.smali
2024-05-21 17:08:36 -04:00

647 lines
14 KiB
Smali

.class public final Lio/sentry/util/StringUtils;
.super Ljava/lang/Object;
.source "StringUtils.java"
# static fields
.field private static final CORRUPTED_NIL_UUID:Ljava/lang/String; = "0000-0000"
.field private static final PATTERN_WORD_SNAKE_CASE:Ljava/util/regex/Pattern;
.field private static final PROPER_NIL_UUID:Ljava/lang/String; = "00000000-0000-0000-0000-000000000000"
.field private static final UTF_8:Ljava/nio/charset/Charset;
# direct methods
.method static constructor <clinit>()V
.locals 1
const-string v0, "UTF-8"
.line 21
invoke-static {v0}, Ljava/nio/charset/Charset;->forName(Ljava/lang/String;)Ljava/nio/charset/Charset;
move-result-object v0
sput-object v0, Lio/sentry/util/StringUtils;->UTF_8:Ljava/nio/charset/Charset;
const-string v0, "[\\W_]+"
.line 25
invoke-static {v0}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;
move-result-object v0
sput-object v0, Lio/sentry/util/StringUtils;->PATTERN_WORD_SNAKE_CASE:Ljava/util/regex/Pattern;
return-void
.end method
.method private constructor <init>()V
.locals 0
.line 27
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static byteCountToString(J)Ljava/lang/String;
.locals 5
const-wide/16 v0, -0x3e8
cmp-long v0, v0, p0
const-wide/16 v1, 0x3e8
if-gez v0, :cond_0
cmp-long v0, p0, v1
if-gez v0, :cond_0
.line 99
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
invoke-virtual {v0, p0, p1}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
move-result-object p0
const-string p1, " B"
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.line 101
:cond_0
new-instance v0, Ljava/text/StringCharacterIterator;
const-string v3, "kMGTPE"
invoke-direct {v0, v3}, Ljava/text/StringCharacterIterator;-><init>(Ljava/lang/String;)V
:goto_0
const-wide/32 v3, -0xf420e
cmp-long v3, p0, v3
if-lez v3, :cond_2
const-wide/32 v3, 0xf420e
cmp-long v3, p0, v3
if-ltz v3, :cond_1
goto :goto_1
.line 106
:cond_1
sget-object v1, Ljava/util/Locale;->ROOT:Ljava/util/Locale;
long-to-double p0, p0
const-wide v2, 0x408f400000000000L # 1000.0
div-double/2addr p0, v2
invoke-static {p0, p1}, Ljava/lang/Double;->valueOf(D)Ljava/lang/Double;
move-result-object p0
invoke-interface {v0}, Ljava/text/CharacterIterator;->current()C
move-result p1
invoke-static {p1}, Ljava/lang/Character;->valueOf(C)Ljava/lang/Character;
move-result-object p1
filled-new-array {p0, p1}, [Ljava/lang/Object;
move-result-object p0
const-string p1, "%.1f %cB"
invoke-static {v1, p1, p0}, Ljava/lang/String;->format(Ljava/util/Locale;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object p0
return-object p0
.line 103
:cond_2
:goto_1
div-long/2addr p0, v1
.line 104
invoke-interface {v0}, Ljava/text/CharacterIterator;->next()C
goto :goto_0
.end method
.method public static calculateStringHash(Ljava/lang/String;Lio/sentry/ILogger;)Ljava/lang/String;
.locals 4
const/4 v0, 0x0
if-eqz p0, :cond_1
.line 118
invoke-virtual {p0}, Ljava/lang/String;->isEmpty()Z
move-result v1
if-eqz v1, :cond_0
goto :goto_0
:cond_0
:try_start_0
const-string v1, "SHA-1"
.line 124
invoke-static {v1}, Ljava/security/MessageDigest;->getInstance(Ljava/lang/String;)Ljava/security/MessageDigest;
move-result-object v1
sget-object v2, Lio/sentry/util/StringUtils;->UTF_8:Ljava/nio/charset/Charset;
.line 129
invoke-virtual {p0, v2}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
move-result-object v2
invoke-virtual {v1, v2}, Ljava/security/MessageDigest;->digest([B)[B
move-result-object v1
.line 132
new-instance v2, Ljava/math/BigInteger;
const/4 v3, 0x1
invoke-direct {v2, v3, v1}, Ljava/math/BigInteger;-><init>(I[B)V
.line 135
new-instance v1, Ljava/lang/StringBuilder;
const/16 v3, 0x10
invoke-virtual {v2, v3}, Ljava/math/BigInteger;->toString(I)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
.line 138
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
:try_end_0
.catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
return-object p0
:catchall_0
move-exception v1
.line 145
sget-object v2, Lio/sentry/SentryLevel;->INFO:Lio/sentry/SentryLevel;
const-string v3, "string: %s could not calculate its hash"
filled-new-array {v1, p0}, [Ljava/lang/Object;
move-result-object p0
invoke-interface {p1, v2, v3, p0}, Lio/sentry/ILogger;->log(Lio/sentry/SentryLevel;Ljava/lang/String;[Ljava/lang/Object;)V
goto :goto_0
:catch_0
move-exception p0
.line 143
sget-object v1, Lio/sentry/SentryLevel;->INFO:Lio/sentry/SentryLevel;
const-string v2, "SHA-1 isn\'t available to calculate the hash."
invoke-interface {p1, v1, v2, p0}, Lio/sentry/ILogger;->log(Lio/sentry/SentryLevel;Ljava/lang/String;Ljava/lang/Throwable;)V
:cond_1
:goto_0
return-object v0
.end method
.method public static camelCase(Ljava/lang/String;)Ljava/lang/String;
.locals 4
if-eqz p0, :cond_2
.line 62
invoke-virtual {p0}, Ljava/lang/String;->isEmpty()Z
move-result v0
if-eqz v0, :cond_0
goto :goto_1
:cond_0
sget-object v0, Lio/sentry/util/StringUtils;->PATTERN_WORD_SNAKE_CASE:Ljava/util/regex/Pattern;
const/4 v1, -0x1
.line 66
invoke-virtual {v0, p0, v1}, Ljava/util/regex/Pattern;->split(Ljava/lang/CharSequence;I)[Ljava/lang/String;
move-result-object p0
.line 67
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
.line 68
array-length v1, p0
const/4 v2, 0x0
:goto_0
if-ge v2, v1, :cond_1
aget-object v3, p0, v2
.line 69
invoke-static {v3}, Lio/sentry/util/StringUtils;->capitalize(Ljava/lang/String;)Ljava/lang/String;
move-result-object v3
invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
add-int/lit8 v2, v2, 0x1
goto :goto_0
.line 71
:cond_1
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
:cond_2
:goto_1
return-object p0
.end method
.method public static capitalize(Ljava/lang/String;)Ljava/lang/String;
.locals 4
if-eqz p0, :cond_1
.line 48
invoke-virtual {p0}, Ljava/lang/String;->isEmpty()Z
move-result v0
if-eqz v0, :cond_0
goto :goto_0
.line 52
:cond_0
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const/4 v1, 0x0
const/4 v2, 0x1
invoke-virtual {p0, v1, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object v1
sget-object v3, Ljava/util/Locale;->ROOT:Ljava/util/Locale;
invoke-virtual {v1, v3}, Ljava/lang/String;->toUpperCase(Ljava/util/Locale;)Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {p0, v2}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object p0
sget-object v1, Ljava/util/Locale;->ROOT:Ljava/util/Locale;
invoke-virtual {p0, v1}, Ljava/lang/String;->toLowerCase(Ljava/util/Locale;)Ljava/lang/String;
move-result-object p0
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
:cond_1
:goto_0
return-object p0
.end method
.method public static countOf(Ljava/lang/String;C)I
.locals 3
const/4 v0, 0x0
move v1, v0
.line 159
:goto_0
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v2
if-ge v0, v2, :cond_1
.line 160
invoke-virtual {p0, v0}, Ljava/lang/String;->charAt(I)C
move-result v2
if-ne v2, p1, :cond_0
add-int/lit8 v1, v1, 0x1
:cond_0
add-int/lit8 v0, v0, 0x1
goto :goto_0
:cond_1
return v1
.end method
.method public static getStringAfterDot(Ljava/lang/String;)Ljava/lang/String;
.locals 2
if-eqz p0, :cond_1
const-string v0, "."
.line 31
invoke-virtual {p0, v0}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I
move-result v0
if-ltz v0, :cond_0
.line 32
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v1
add-int/lit8 v0, v0, 0x1
if-le v1, v0, :cond_0
.line 33
invoke-virtual {p0, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object p0
:cond_0
return-object p0
:cond_1
const/4 p0, 0x0
return-object p0
.end method
.method public static join(Ljava/lang/CharSequence;Ljava/lang/Iterable;)Ljava/lang/String;
.locals 2
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/CharSequence;",
"Ljava/lang/Iterable<",
"+",
"Ljava/lang/CharSequence;",
">;)",
"Ljava/lang/String;"
}
.end annotation
.line 192
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
.line 193
invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
move-result-object p1
.line 195
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_0
.line 196
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/lang/CharSequence;
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;
.line 197
:goto_0
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result v1
if-eqz v1, :cond_0
.line 198
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;
.line 199
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/lang/CharSequence;
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;
goto :goto_0
.line 203
:cond_0
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method public static normalizeUUID(Ljava/lang/String;)Ljava/lang/String;
.locals 1
const-string v0, "0000-0000"
.line 176
invoke-virtual {p0, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_0
const-string p0, "00000000-0000-0000-0000-000000000000"
:cond_0
return-object p0
.end method
.method public static removePrefix(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
.locals 1
if-nez p0, :cond_0
const-string p0, ""
return-object p0
.line 219
:cond_0
invoke-virtual {p0, p1}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I
move-result v0
if-nez v0, :cond_1
.line 221
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result p1
invoke-virtual {p0, p1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
move-result-object p0
:cond_1
return-object p0
.end method
.method public static removeSurrounding(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
.locals 2
if-eqz p0, :cond_0
if-eqz p1, :cond_0
.line 84
invoke-virtual {p0, p1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
move-result v0
if-eqz v0, :cond_0
invoke-virtual {p0, p1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
move-result v0
if-eqz v0, :cond_0
.line 85
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result v0
invoke-virtual {p0}, Ljava/lang/String;->length()I
move-result v1
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result p1
sub-int/2addr v1, p1
invoke-virtual {p0, v0, v1}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object p0
:cond_0
return-object p0
.end method
.method public static substringBefore(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
.locals 1
if-nez p0, :cond_0
const-string p0, ""
return-object p0
.line 232
:cond_0
invoke-virtual {p0, p1}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I
move-result p1
if-ltz p1, :cond_1
const/4 v0, 0x0
.line 234
invoke-virtual {p0, v0, p1}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object p0
:cond_1
return-object p0
.end method
.method public static toString(Ljava/lang/Object;)Ljava/lang/String;
.locals 0
if-nez p0, :cond_0
const/4 p0, 0x0
return-object p0
.line 211
:cond_0
invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p0
return-object p0
.end method