discord-jadx/app/src/main/java/b/a/q/i0.java

141 lines
5.0 KiB
Java
Raw Normal View History

2021-12-21 23:37:30 +00:00
package b.a.q;
2021-07-20 22:20:08 +00:00
import android.app.Application;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import androidx.annotation.AnyThread;
import androidx.annotation.RequiresApi;
2021-12-21 23:37:30 +00:00
import b.c.a.a0.d;
2021-07-20 22:20:08 +00:00
import com.discord.rtcconnection.enums.ThermalStatus;
import com.discord.utilities.debug.DebugPrintBuilder;
import com.discord.utilities.debug.DebugPrintable;
import com.discord.utilities.lifecycle.ApplicationProvider;
import com.discord.utilities.logging.LoggingProvider;
2021-11-08 18:25:28 +00:00
import d0.g;
import d0.i;
import d0.z.d.m;
import d0.z.d.o;
2021-07-20 22:20:08 +00:00
import java.util.Objects;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
/* compiled from: ThermalDetector.kt */
@AnyThread
@RequiresApi(29)
2021-08-24 17:45:16 +00:00
public final class i0 implements PowerManager.OnThermalStatusChangedListener, Runnable, DebugPrintable {
2021-12-17 22:03:14 +00:00
public static final Lazy j = g.lazy(i.NONE, a.j);
2021-07-20 22:20:08 +00:00
public static boolean k;
public static boolean l;
2021-12-17 22:03:14 +00:00
public static boolean m;
public static final i0 n = new i0();
2021-07-20 22:20:08 +00:00
/* compiled from: ThermalDetector.kt */
public static final class a extends o implements Function0<Handler> {
2021-12-17 22:03:14 +00:00
public static final a j = new a();
2021-07-20 22:20:08 +00:00
public a() {
super(0);
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
2021-11-08 18:25:28 +00:00
public Handler mo1invoke() {
2021-07-20 22:20:08 +00:00
return new Handler(Looper.getMainLooper());
}
}
public final ThermalStatus a() {
ThermalStatus.a aVar = ThermalStatus.Companion;
Application application = ApplicationProvider.INSTANCE.get();
Objects.requireNonNull(aVar);
m.checkNotNullParameter(application, "context");
Object systemService = application.getSystemService("power");
Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.os.PowerManager");
return aVar.a(((PowerManager) systemService).getCurrentThermalStatus());
}
public final void b(ThermalStatus thermalStatus) {
LoggingProvider.INSTANCE.get().recordBreadcrumb("thermalStatus = " + thermalStatus, "thermal");
switch (thermalStatus.ordinal()) {
case 0:
2021-12-17 22:03:14 +00:00
if (l) {
2022-01-27 00:50:41 +00:00
d.d1("ThermalDetector", "totally cool: no longer in thermal trouble");
2021-12-17 22:03:14 +00:00
l = false;
if (m) {
((Handler) j.getValue()).removeCallbacks(this);
m = false;
2021-07-20 22:20:08 +00:00
return;
}
return;
}
2022-01-27 00:50:41 +00:00
d.e1("ThermalDetector", "totally cool: thermal status is nominal");
2021-07-20 22:20:08 +00:00
return;
case 1:
case 2:
2021-12-17 22:03:14 +00:00
if (l) {
2022-01-27 00:50:41 +00:00
d.d1("ThermalDetector", "cooling down: thermal status = " + thermalStatus);
2021-07-20 22:20:08 +00:00
c();
return;
}
2022-01-27 00:50:41 +00:00
d.e1("ThermalDetector", "pretty warm: ignoring low priority thermal status = " + thermalStatus);
2021-07-20 22:20:08 +00:00
return;
case 3:
case 4:
case 5:
case 6:
2021-12-17 22:03:14 +00:00
if (!l) {
2022-01-27 00:50:41 +00:00
d.f1("ThermalDetector", "we're starting to be in thermal trouble");
2021-12-17 22:03:14 +00:00
l = true;
2021-07-20 22:20:08 +00:00
}
String str = "very toasty: thermal status = " + thermalStatus;
if (thermalStatus.compareTo(ThermalStatus.Emergency) < 0) {
2022-01-27 00:50:41 +00:00
d.f1("ThermalDetector", str);
2021-07-20 22:20:08 +00:00
} else {
2022-01-27 00:50:41 +00:00
d.c1("ThermalDetector", str, new RuntimeException(str));
2021-07-20 22:20:08 +00:00
}
c();
return;
default:
return;
}
}
public final void c() {
2021-12-17 22:03:14 +00:00
if (!m) {
((Handler) j.getValue()).postDelayed(this, 1000);
m = true;
2021-07-20 22:20:08 +00:00
}
}
@Override // com.discord.utilities.debug.DebugPrintable
@AnyThread
public void debugPrint(DebugPrintBuilder debugPrintBuilder) {
m.checkNotNullParameter(debugPrintBuilder, "dp");
2021-12-17 22:03:14 +00:00
debugPrintBuilder.appendKeyValue("registered", Boolean.valueOf(k));
debugPrintBuilder.appendKeyValue("inThermalTrouble", Boolean.valueOf(l));
debugPrintBuilder.appendKeyValue("updateScheduled", Boolean.valueOf(m));
2021-07-20 22:20:08 +00:00
debugPrintBuilder.appendKeyValue("currentThermalStatus", a());
}
@Override // android.os.PowerManager.OnThermalStatusChangedListener
2021-12-17 22:03:14 +00:00
public synchronized void onThermalStatusChanged(int i) {
ThermalStatus a2 = ThermalStatus.Companion.a(i);
2022-01-27 00:50:41 +00:00
d.b1("ThermalDetector", "system update: onThermalStatusChanged( " + a2 + " )");
2021-07-20 22:20:08 +00:00
b(a2);
}
@Override // java.lang.Runnable
public synchronized void run() {
2021-12-17 22:03:14 +00:00
m = false;
2021-07-20 22:20:08 +00:00
ThermalStatus a2 = a();
2022-01-27 00:50:41 +00:00
d.b1("ThermalDetector", "scheduled update: current thermal status = " + a2);
2021-07-20 22:20:08 +00:00
b(a2);
}
@Override // java.lang.Object
public synchronized String toString() {
2021-12-17 22:03:14 +00:00
return "ThermalDetector(registered=" + k + ", inThermalTrouble=" + l + ", updateScheduled=" + m + ')';
2021-07-20 22:20:08 +00:00
}
}