134 lines
5.1 KiB
Java
134 lines
5.1 KiB
Java
package com.discord.utilities.debug;
|
|
|
|
import android.app.ActivityManager;
|
|
import android.app.ApplicationExitInfo;
|
|
import android.os.Build;
|
|
import androidx.appcompat.widget.ActivityChooserModel;
|
|
import c.d.b.a.a;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.utilities.lifecycle.ApplicationProvider;
|
|
import d0.g;
|
|
import d0.o;
|
|
import d0.t.h0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import kotlin.Lazy;
|
|
/* compiled from: HistoricalProcessExitReason.kt */
|
|
public final class HistoricalProcessExitReason {
|
|
public static final HistoricalProcessExitReason INSTANCE = new HistoricalProcessExitReason();
|
|
private static final Lazy lastReason$delegate = g.lazy(HistoricalProcessExitReason$lastReason$2.INSTANCE);
|
|
|
|
/* compiled from: HistoricalProcessExitReason.kt */
|
|
public static final class Reason {
|
|
private final String description;
|
|
private final String reason;
|
|
|
|
public Reason(String str, String str2) {
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_REASON);
|
|
this.reason = str;
|
|
this.description = str2;
|
|
}
|
|
|
|
public static /* synthetic */ Reason copy$default(Reason reason, String str, String str2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = reason.reason;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
str2 = reason.description;
|
|
}
|
|
return reason.copy(str, str2);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.reason;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.description;
|
|
}
|
|
|
|
public final Reason copy(String str, String str2) {
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_REASON);
|
|
return new Reason(str, str2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Reason)) {
|
|
return false;
|
|
}
|
|
Reason reason = (Reason) obj;
|
|
return m.areEqual(this.reason, reason.reason) && m.areEqual(this.description, reason.description);
|
|
}
|
|
|
|
public final String getDescription() {
|
|
return this.description;
|
|
}
|
|
|
|
public final String getReason() {
|
|
return this.reason;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.reason;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
String str2 = this.description;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Reason(reason=");
|
|
L.append(this.reason);
|
|
L.append(", description=");
|
|
return a.D(L, this.description, ")");
|
|
}
|
|
}
|
|
|
|
private HistoricalProcessExitReason() {
|
|
}
|
|
|
|
public static final /* synthetic */ Reason access$createLastReason(HistoricalProcessExitReason historicalProcessExitReason) {
|
|
return historicalProcessExitReason.createLastReason();
|
|
}
|
|
|
|
private final Reason createLastReason() {
|
|
Reason reason = null;
|
|
if (Build.VERSION.SDK_INT < 30) {
|
|
return null;
|
|
}
|
|
Map mapOf = h0.mapOf(o.to(6, "REASON_ANR"), o.to(4, "REASON_CRASH"), o.to(5, "REASON_CRASH_NATIVE"), o.to(12, "REASON_DEPENDENCY_DIED"), o.to(9, "REASON_EXCESSIVE_RESOURCE_USAGE"), o.to(1, "REASON_EXIT_SELF"), o.to(7, "REASON_INITIALIZATION_FAILURE"), o.to(3, "REASON_LOW_MEMORY"), o.to(13, "REASON_OTHER"), o.to(8, "REASON_PERMISSION_CHANGE"), o.to(2, "REASON_SIGNALED"), o.to(0, "REASON_UNKNOWN"), o.to(10, "REASON_USER_REQUESTED"), o.to(11, "REASON_USER_STOPPED"));
|
|
Object systemService = ApplicationProvider.INSTANCE.get().getSystemService(ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
if (!(systemService instanceof ActivityManager)) {
|
|
systemService = null;
|
|
}
|
|
ActivityManager activityManager = (ActivityManager) systemService;
|
|
if (activityManager != null) {
|
|
List<ApplicationExitInfo> historicalProcessExitReasons = activityManager.getHistoricalProcessExitReasons(null, 0, 1);
|
|
m.checkNotNullExpressionValue(historicalProcessExitReasons, "activityManager.getHisto…ssExitReasons(null, 0, 1)");
|
|
ApplicationExitInfo applicationExitInfo = (ApplicationExitInfo) u.firstOrNull((List<? extends Object>) historicalProcessExitReasons);
|
|
if (applicationExitInfo != null) {
|
|
String str = (String) mapOf.get(Integer.valueOf(applicationExitInfo.getReason()));
|
|
if (str == null) {
|
|
StringBuilder L = a.L("Unknown ");
|
|
L.append(applicationExitInfo.getReason());
|
|
str = L.toString();
|
|
}
|
|
reason = new Reason(str, applicationExitInfo.getDescription());
|
|
}
|
|
}
|
|
return reason;
|
|
}
|
|
|
|
public final Reason getLastReason() {
|
|
return (Reason) lastReason$delegate.getValue();
|
|
}
|
|
}
|