discord-jadx/app/src/main/java/com/discord/samsung/SamsungConnectActivity.java

234 lines
9.2 KiB
Java

package com.discord.samsung;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
import android.util.Log;
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AppCompatActivity;
import c.a.r.d;
import c.n.a.a.b;
import com.discord.BuildConfig;
import d0.g0.t;
import d0.z.d.m;
import java.util.Objects;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: SamsungConnectActivity.kt */
public final class SamsungConnectActivity extends AppCompatActivity {
public c.n.a.a.a i;
public boolean j;
public final a k = new a(this);
/* compiled from: SamsungConnectActivity.kt */
public static abstract class Result {
/* compiled from: SamsungConnectActivity.kt */
public static final class Failure extends Result {
public final boolean a;
public final int b;
public Failure(boolean z2, int i) {
super(null);
this.a = z2;
this.b = i;
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Failure(boolean z2, int i, int i2) {
super(null);
i = (i2 & 2) != 0 ? 0 : i;
this.a = z2;
this.b = i;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Failure)) {
return false;
}
Failure failure = (Failure) obj;
return this.a == failure.a && this.b == failure.b;
}
public int hashCode() {
boolean z2 = this.a;
if (z2) {
z2 = true;
}
int i = z2 ? 1 : 0;
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
return (i * 31) + this.b;
}
public String toString() {
StringBuilder P = c.d.b.a.a.P("Failure(isRetryAllowed=");
P.append(this.a);
P.append(", attemptCount=");
return c.d.b.a.a.z(P, this.b, ")");
}
}
/* compiled from: SamsungConnectActivity.kt */
public static final class Success extends Result {
public final String a;
public final String b;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Success(String str, String str2) {
super(null);
m.checkNotNullParameter(str, "authCode");
m.checkNotNullParameter(str2, "serverUrl");
this.a = str;
this.b = str2;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Success)) {
return false;
}
Success success = (Success) obj;
return m.areEqual(this.a, success.a) && m.areEqual(this.b, success.b);
}
public int hashCode() {
String str = this.a;
int i = 0;
int hashCode = (str != null ? str.hashCode() : 0) * 31;
String str2 = this.b;
if (str2 != null) {
i = str2.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder P = c.d.b.a.a.P("Success(authCode=");
P.append(this.a);
P.append(", serverUrl=");
return c.d.b.a.a.H(P, this.b, ")");
}
}
public Result() {
}
public Result(DefaultConstructorMarker defaultConstructorMarker) {
}
}
/* compiled from: SamsungConnectActivity.kt */
public static final class a implements ServiceConnection {
public final /* synthetic */ SamsungConnectActivity i;
public a(SamsungConnectActivity samsungConnectActivity) {
this.i = samsungConnectActivity;
}
@Override // android.content.ServiceConnection
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
b bVar;
this.i.j = true;
int i = b.a.a;
if (iBinder == null) {
bVar = null;
} else {
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.msc.sa.aidl.ISAService");
bVar = (queryLocalInterface == null || !(queryLocalInterface instanceof b)) ? new b.a.C0159a(iBinder) : (b) queryLocalInterface;
}
Log.i("Discord", "Samsung Account service connection established");
try {
c.n.a.a.a aVar = this.i.i;
if (aVar == null) {
m.throwUninitializedPropertyAccessException("samsungAccountServiceCallback");
}
String N = bVar.N("97t47j218f", "dummy", BuildConfig.APPLICATION_ID, aVar);
Log.i("Discord", "Samsung Account service connection established: " + N);
if (N == null) {
SamsungConnectActivity samsungConnectActivity = this.i;
samsungConnectActivity.setResult(500, new Intent().putExtra("com.discord.samsung.intent.extra.ATTEMPT_COUNT", samsungConnectActivity.getIntent().getIntExtra("com.discord.samsung.intent.extra.ATTEMPT_COUNT", 0) + 1));
samsungConnectActivity.finish();
return;
}
Bundle bundle = new Bundle();
bundle.putStringArray("additional", new String[]{"api_server_url", "auth_server_url"});
boolean j02 = bVar.j0(1221, N, bundle);
Log.i("Discord", "Samsung Account service connection established: isReqSucc? " + j02);
if (!j02) {
throw new Exception("Call Samsung.requestAuthCode failed");
}
} catch (Throwable th) {
Log.e("Discord", "Unable to connect to Samsung", th);
SamsungConnectActivity.a(this.i, null, null);
}
}
@Override // android.content.ServiceConnection
public void onServiceDisconnected(ComponentName componentName) {
Log.i("Discord", "Samsung Account service connection unbound");
SamsungConnectActivity samsungConnectActivity = this.i;
samsungConnectActivity.j = false;
samsungConnectActivity.finish();
}
}
public static final void a(SamsungConnectActivity samsungConnectActivity, String str, String str2) {
Objects.requireNonNull(samsungConnectActivity);
boolean z2 = true;
if (!(str == null || t.isBlank(str))) {
if (str2 != null && !t.isBlank(str2)) {
z2 = false;
}
if (!z2) {
Intent intent = new Intent();
intent.putExtra("com.discord.samsung.intent.extra.AUTH_CODE", str);
intent.putExtra("com.discord.samsung.intent.extra.SERVER_URL", str2);
samsungConnectActivity.setResult(-1, intent);
samsungConnectActivity.finish();
}
}
samsungConnectActivity.setResult(0);
samsungConnectActivity.finish();
}
public static final void b(Context context, ActivityResultLauncher<Intent> activityResultLauncher, int i) {
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(activityResultLauncher, "launcher");
Intent addFlags = new Intent(context, SamsungConnectActivity.class).putExtra("com.discord.samsung.intent.extra.ATTEMPT_COUNT", i).addFlags(65536);
m.checkNotNullExpressionValue(addFlags, "Intent(context, SamsungC…AG_ACTIVITY_NO_ANIMATION)");
activityResultLauncher.launch(addFlags);
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, android.app.Activity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.i = new d(this);
Intent intent = new Intent("com.msc.action.samsungaccount.REQUEST_SERVICE").setPackage("com.osp.app.signin");
m.checkNotNullExpressionValue(intent, "Intent(SA_ACCOUNT_ACTION…ckage(SA_ACCOUNT_SERVICE)");
Log.i("Discord", "Samsung starting SA Service");
if (startService(intent) == null) {
Log.e("Discord", "Samsung Account service could not be started");
} else if (!bindService(intent, this.k, 1)) {
Log.e("Discord", "Samsung Account service could not be bound");
}
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
public void onStop() {
if (this.j) {
unbindService(this.k);
this.j = false;
}
super.onStop();
}
}