밤친구 v4.7.3版本的 MD5 值为:a58175795b36d9d722726efa7eb4c52a
以下内容为反编译后的 b.java 源代码,内容仅作参考
package ld;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import cl.d;
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.utils.FileUtils;
import com.shuyu.gsyvideoplayer.utils.StorageUtils;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import ld.a;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import tv.danmaku.ijk.media.player.IjkMediaMeta;
import w.f;
import w.g;
import w.p;
public final class b implements a, w.b {
public static b f12309f;
public f f12310a;
public File f12311b;
public boolean f12312c;
public a.InterfaceC0179a f12313d;
public final c f12314e = new c();
public static f b(Context context, File file) {
String str;
File file2 = null;
if (file == null) {
f fVar = c().f12310a;
if (fVar == null) {
b c10 = c();
b c11 = c();
c11.getClass();
Context applicationContext = context.getApplicationContext();
z.a aVar = new z.a(applicationContext);
try {
str = Environment.getExternalStorageState();
} catch (NullPointerException unused) {
str = "";
}
if ("mounted".equals(str) && Build.VERSION.SDK_INT <= 28) {
File file3 = new File(new File(new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data"), applicationContext.getPackageName()), "cache");
if (!file3.exists() && !file3.mkdirs()) {
d.P0("Unable to create external cache directory");
} else {
file2 = file3;
}
}
if (file2 == null) {
file2 = applicationContext.getCacheDir();
}
if (file2 == null) {
String str2 = "/data/data/" + applicationContext.getPackageName() + "/cache/";
d.P0("Can't define system cache directory! '" + str2 + "%s' will be used.");
file2 = new File(str2);
}
File file4 = new File(file2, "video-cache");
x.f fVar2 = new x.f(IjkMediaMeta.AV_CH_STEREO_LEFT);
d dVar = new d();
c cVar = c11.f12314e;
cVar.getClass();
f fVar3 = new f(new w.c(file4, dVar, fVar2, aVar, cVar));
c10.f12310a = fVar3;
return fVar3;
}
return fVar;
}
if (c().f12311b != null && !c().f12311b.getAbsolutePath().equals(file.getAbsolutePath())) {
f fVar4 = c().f12310a;
if (fVar4 != null) {
d.O0("Shutdown proxy server");
synchronized (fVar4.f17409a) {
for (g gVar : fVar4.f17411c.values()) {
gVar.f17424d.clear();
if (gVar.f17423c != null) {
gVar.f17423c.f17408k = null;
gVar.f17423c.e();
gVar.f17423c = null;
}
gVar.f17421a.set(0);
}
fVar4.f17411c.clear();
}
fVar4.f17415g.f17400d.release();
fVar4.f17414f.interrupt();
try {
if (!fVar4.f17412d.isClosed()) {
fVar4.f17412d.close();
}
} catch (IOException e10) {
String message = new p("Error shutting down proxy server", e10).getMessage();
if (!TextUtils.isEmpty(message)) {
Log.e("HttpProxyCacheServer error", message);
}
}
}
b c12 = c();
f d4 = c().d(context, file);
c12.f12310a = d4;
return d4;
}
f fVar5 = c().f12310a;
if (fVar5 == null) {
b c13 = c();
f d10 = c().d(context, file);
c13.f12310a = d10;
return d10;
}
return fVar5;
}
public static synchronized b c() {
b bVar;
synchronized (b.class) {
if (f12309f == null) {
f12309f = new b();
}
bVar = f12309f;
}
return bVar;
}
@Override
public final void a(int i, File file) {
a.InterfaceC0179a interfaceC0179a = this.f12313d;
if (interfaceC0179a != null) {
((kd.b) interfaceC0179a).f11669m = i;
}
}
@Override
public final boolean cachePreview(Context context, File file, String str) {
return !b(context.getApplicationContext(), file).c(str).startsWith("http");
}
@Override
public final void clearCache(Context context, File file, String str) {
if (TextUtils.isEmpty(str)) {
FileUtils.deleteFiles(new File(StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath()));
return;
}
String b10 = new d().b(str);
if (file != null) {
StringBuilder sb2 = new StringBuilder();
sb2.append(file.getAbsolutePath());
String str2 = File.separator;
sb2.append(str2);
sb2.append(b10);
sb2.append(".download");
String sb3 = sb2.toString();
String str3 = file.getAbsolutePath() + str2 + b10;
CommonUtil.deleteFile(sb3);
CommonUtil.deleteFile(str3);
return;
}
StringBuilder sb4 = new StringBuilder();
sb4.append(StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath());
String str4 = File.separator;
sb4.append(str4);
sb4.append(b10);
sb4.append(".download");
String sb5 = sb4.toString();
String str5 = StorageUtils.getIndividualCacheDirectory(context.getApplicationContext()).getAbsolutePath() + str4 + b10;
CommonUtil.deleteFile(sb5);
CommonUtil.deleteFile(str5);
}
public final f d(Context context, File file) {
String str;
File file2;
if (!file.exists()) {
file.mkdirs();
}
z.a aVar = new z.a(context);
try {
str = Environment.getExternalStorageState();
} catch (NullPointerException unused) {
str = "";
}
if ("mounted".equals(str) && Build.VERSION.SDK_INT <= 28) {
file2 = new File(new File(new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data"), context.getPackageName()), "cache");
if (!file2.exists() && !file2.mkdirs()) {
d.P0("Unable to create external cache directory");
}
if (file2 == null) {
file2 = context.getCacheDir();
}
if (file2 == null) {
String str2 = "/data/data/" + context.getPackageName() + "/cache/";
d.P0("Can't define system cache directory! '" + str2 + "%s' will be used.");
file2 = new File(str2);
}
new File(file2, "video-cache");
Executors.newSingleThreadExecutor();
if (IjkMediaMeta.AV_CH_STEREO_LEFT <= 0) {
d dVar = new d();
x.f fVar = new x.f(536870912);
c cVar = this.f12314e;
cVar.getClass();
this.f12311b = file;
return new f(new w.c(file, dVar, fVar, aVar, cVar));
}
throw new IllegalArgumentException("Max size must be positive number!");
}
file2 = null;
if (file2 == null) {
}
if (file2 == null) {
}
new File(file2, "video-cache");
Executors.newSingleThreadExecutor();
if (IjkMediaMeta.AV_CH_STEREO_LEFT <= 0) {
}
}
@Override
public final void doCacheLogic(Context context, IMediaPlayer iMediaPlayer, String str, Map<String, String> map, File file) {
HashMap hashMap = c.f12315a;
hashMap.clear();
if (map != null) {
hashMap.putAll(map);
}
if (str.startsWith("http") && !str.contains("127.0.0.1") && !str.contains(".m3u8")) {
f b10 = b(context.getApplicationContext(), file);
String c10 = b10.c(str);
boolean z10 = !c10.startsWith("http");
this.f12312c = z10;
if (!z10) {
Object[] objArr = {this, str};
for (int i = 0; i < 2; i++) {
objArr[i].getClass();
}
synchronized (b10.f17409a) {
try {
b10.a(str).f17424d.add(this);
} catch (p e10) {
String message = e10.getMessage();
if (message != null && !TextUtils.isEmpty(message)) {
Log.w("Error registering cache listener", message);
}
} finally {
}
}
}
str = c10;
} else if (!str.startsWith("http") && !str.startsWith("rtmp") && !str.startsWith("rtsp") && !str.contains(".m3u8")) {
this.f12312c = true;
}
try {
iMediaPlayer.setDataSource(context, Uri.parse(str), map);
} catch (IOException e11) {
e11.printStackTrace();
}
}
@Override
public final boolean hadCached() {
return this.f12312c;
}
@Override
public final void release() {
f fVar = this.f12310a;
if (fVar != null) {
try {
fVar.f(this);
} catch (Exception e10) {
e10.printStackTrace();
}
}
}
@Override
public final void setCacheAvailableListener(a.InterfaceC0179a interfaceC0179a) {
this.f12313d = interfaceC0179a;
}
}