146 lines
3.5 KiB
Java
146 lines
3.5 KiB
Java
package com.tencent.open.a;
|
|
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.os.Message;
|
|
import com.ijm.dataencryption.de.DataDecryptTool;
|
|
import java.io.File;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
import java.io.Writer;
|
|
|
|
/* compiled from: ProGuard */
|
|
/* loaded from: classes.dex */
|
|
public class a extends i implements Handler.Callback {
|
|
private b a;
|
|
private FileWriter b;
|
|
private File c;
|
|
private char[] d;
|
|
private volatile g e;
|
|
private volatile g f;
|
|
private volatile g g;
|
|
private volatile g h;
|
|
private volatile boolean i;
|
|
private HandlerThread j;
|
|
private Handler k;
|
|
|
|
public a(b bVar) {
|
|
this(c.b, true, h.a, bVar);
|
|
}
|
|
|
|
private void f() {
|
|
if (Thread.currentThread() == this.j && !this.i) {
|
|
this.i = true;
|
|
i();
|
|
try {
|
|
this.h.a(g(), this.d);
|
|
} catch (IOException unused) {
|
|
} catch (Throwable th) {
|
|
this.h.b();
|
|
throw th;
|
|
}
|
|
this.h.b();
|
|
this.i = false;
|
|
}
|
|
}
|
|
|
|
private Writer g() {
|
|
File a = c().a();
|
|
if ((a != null && !a.equals(this.c)) || (this.b == null && a != null)) {
|
|
this.c = a;
|
|
h();
|
|
try {
|
|
this.b = new FileWriter(this.c, true);
|
|
} catch (IOException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
return this.b;
|
|
}
|
|
|
|
private void h() {
|
|
try {
|
|
if (this.b != null) {
|
|
this.b.flush();
|
|
this.b.close();
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
private void i() {
|
|
synchronized (this) {
|
|
if (this.g == this.e) {
|
|
this.g = this.f;
|
|
this.h = this.e;
|
|
} else {
|
|
this.g = this.e;
|
|
this.h = this.f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void a() {
|
|
if (this.k.hasMessages(DataDecryptTool.DECRYPT_SP_FILE)) {
|
|
this.k.removeMessages(DataDecryptTool.DECRYPT_SP_FILE);
|
|
}
|
|
this.k.sendEmptyMessage(DataDecryptTool.DECRYPT_SP_FILE);
|
|
}
|
|
|
|
public void b() {
|
|
h();
|
|
this.j.quit();
|
|
}
|
|
|
|
public b c() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // android.os.Handler.Callback
|
|
public boolean handleMessage(Message message) {
|
|
if (message.what != 1024) {
|
|
return true;
|
|
}
|
|
f();
|
|
return true;
|
|
}
|
|
|
|
public a(int i, boolean z, h hVar, b bVar) {
|
|
super(i, z, hVar);
|
|
this.i = false;
|
|
a(bVar);
|
|
this.e = new g();
|
|
this.f = new g();
|
|
this.g = this.e;
|
|
this.h = this.f;
|
|
this.d = new char[bVar.d()];
|
|
g();
|
|
this.j = new HandlerThread(bVar.c(), bVar.f());
|
|
HandlerThread handlerThread = this.j;
|
|
if (handlerThread != null) {
|
|
handlerThread.start();
|
|
}
|
|
if (!this.j.isAlive() || this.j.getLooper() == null) {
|
|
return;
|
|
}
|
|
this.k = new Handler(this.j.getLooper(), this);
|
|
}
|
|
|
|
@Override // com.tencent.open.a.i
|
|
protected void a(int i, Thread thread, long j, String str, String str2, Throwable th) {
|
|
a(e().a(i, thread, j, str, str2, th));
|
|
}
|
|
|
|
protected void a(String str) {
|
|
this.g.a(str);
|
|
if (this.g.a() >= c().d()) {
|
|
a();
|
|
}
|
|
}
|
|
|
|
public void a(b bVar) {
|
|
this.a = bVar;
|
|
}
|
|
}
|