AdGuard v3.6.45版本的 MD5 值为:ce30a13dcef92cf942973fffcc6d20fb
以下内容为反编译后的 AdguardApplication.java 源代码,内容仅作参考
package com.adguard.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.view.ViewConfiguration;
import androidx.multidex.MultiDex;
import com.adguard.android.a.n;
import com.adguard.android.a.p;
import com.adguard.android.events.EventsApplication;
import com.adguard.android.filtering.commons.DeviceName;
import com.adguard.android.filtering.commons.f;
import com.adguard.android.model.enums.Theme;
import com.adguard.android.receivers.ExclusionsReceiver;
import com.adguard.android.receivers.LocaleChangeReceiver;
import com.adguard.android.receivers.NetworkStateReceiver;
import com.adguard.android.receivers.PackageReceiver;
import com.adguard.android.receivers.PowerModeReceiver;
import com.adguard.android.receivers.ProtectionActionsReceiver;
import com.adguard.android.receivers.ScreenStateReceiver;
import com.adguard.android.service.PreferencesService;
import com.adguard.android.service.ProtectionService;
import com.adguard.corelibs.CoreLibs;
import com.adguard.kit.net.http.g;
import java.lang.Thread;
import java.lang.reflect.Field;
import org.slf4j.d;
public class AdguardApplication extends EventsApplication {
private static final org.slf4j.c LOG = d.a(AdguardApplication.class);
private static Context context;
public static Context getContext() {
return context;
}
public void initApplication() {
LOG.info("Start initializing application service");
b a2 = b.a(getApplicationContext());
g.CC.d(a.a().p(), a.a().i());
com.adguard.android.a.c.a(getApplicationContext());
registerBroadcastReceivers();
a2.A.a();
LOG.info("Finished initializing application service");
PreferencesService preferencesService = a2.d;
ProtectionService protectionService = a2.g;
com.adguard.android.service.b.a aVar = a2.z;
if (preferencesService.y() == ProtectionService.ProtectionStatus.STARTED) {
if (preferencesService.aU() && !aVar.a()) {
a2.t.o();
}
if (!preferencesService.a()) {
LOG.info("Autostart is disabled. Doing nothing.");
return;
} else {
LOG.info("AdGuard was probably killed by the system. Restoring protection automatically.");
protectionService.b();
}
}
a2.E.a(this);
}
private void registerBroadcastReceivers() {
registerReceiver(new LocaleChangeReceiver(), (String) null, "android.intent.action.LOCALE_CHANGED");
if (com.adguard.kit.compatibility.a.c()) {
registerReceiver(new NetworkStateReceiver(false), (String) null, "android.net.conn.CONNECTIVITY_CHANGE", "android.net.wifi.WIFI_STATE_CHANGED", "android.net.wifi.WIFI_AP_STATE_CHANGED", "android.hardware.usb.action.USB_STATE", "android.bluetooth.device.action.ACL_CONNECTED", "android.bluetooth.device.action.ACL_DISCONNECTED");
}
if (com.adguard.kit.compatibility.a.a()) {
registerReceiver(new PowerModeReceiver(), (String) null, "android.os.action.POWER_SAVE_MODE_CHANGED");
}
registerReceiver(new ScreenStateReceiver(), (String) null, "android.intent.action.SCREEN_ON", "android.intent.action.SCREEN_OFF");
registerReceiver(new PackageReceiver(), "package", "android.intent.action.PACKAGE_REPLACED", "android.intent.action.PACKAGE_ADDED", "android.intent.action.PACKAGE_REMOVED", "android.intent.action.PACKAGE_FULLY_REMOVED");
registerReceiver(new ProtectionActionsReceiver(), (String) null, (String[]) ProtectionActionsReceiver.f209a.toArray(new String[0]));
registerReceiver(new ExclusionsReceiver(), (String) null, "com.adguard.android.EXCLUDE_HTTPS_DOMAIN", "com.adguard.android.EXCLUDE_HTTPS_PACKAGE");
}
private void registerReceiver(BroadcastReceiver broadcastReceiver, String str, String... strArr) {
IntentFilter intentFilter = new IntentFilter();
for (String str2 : strArr) {
intentFilter.addAction(str2);
}
if (str != null) {
intentFilter.addDataScheme(str);
}
registerReceiver(broadcastReceiver, intentFilter);
}
private void setShowMenuButton(Context context2) {
try {
ViewConfiguration viewConfiguration = ViewConfiguration.get(context2);
Field declaredField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (declaredField != null) {
declaredField.setAccessible(true);
declaredField.setBoolean(viewConfiguration, false);
}
} catch (Exception e) {
LOG.warn("Cannot show menu button: {}", e.getMessage());
}
}
@Override
protected void attachBaseContext(Context context2) {
super.attachBaseContext(n.a(context2, PreferenceManager.getDefaultSharedPreferences(context2).getString(PreferencesService.Options.KEY_APP_LANGUAGE.toString(), a.a().e())));
MultiDex.install(this);
}
@Override
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
String a2 = n.a(n.a(configuration));
String w = b.a(context).d.w();
if (!a2.equals(w)) {
n.b(context, w);
}
}
@Override
public void onCreate() {
super.onCreate();
context = this;
String a2 = f.a(this);
String k = a.a().k();
String c = p.c(context);
CoreLibs.Versions coreLibsVersions = CoreLibs.getCoreLibsVersions();
String str = coreLibsVersions.core;
String str2 = coreLibsVersions.contentScript;
String str3 = coreLibsVersions.stealthScript;
String str4 = coreLibsVersions.userScriptWrapper;
String str5 = coreLibsVersions.scriptletsLibrary;
String a3 = com.adguard.kit.h.a.a(context);
com.adguard.android.filtering.commons.c.a(context);
int i = 0 >> 6;
LOG.info("Creating AdGuard application. Process name: '{}', app version title: '{}', app version: {}, corelibs version: {}, contentScript version: {}, stealthScript version: {}, userScriptWrapper version: {}, scriptletsLibrary version: {}, kitlibs version: {}", a2, k, c, str, str2, str3, str4, str5, "2.0.74.3");
LOG.info("AdGuard APK size: {} Mb", a3);
LOG.info("Device information: {}", DeviceName.getDeviceInformation());
LOG.info("Cache directory: {}", context.getExternalCacheDir());
Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(defaultUncaughtExceptionHandler instanceof com.adguard.android.a.f)) {
Thread.setDefaultUncaughtExceptionHandler(new com.adguard.android.a.f(context, defaultUncaughtExceptionHandler));
}
if (a.a().g()) {
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectNetwork().penaltyLog().penaltyDeath().build());
}
int i2 = PreferenceManager.getDefaultSharedPreferences(context).getInt(PreferencesService.Options.KEY_THEME.toString(), Theme.LIGHT.ordinal());
context.setTheme(com.adguard.android.ui.utils.g.a(i2 == Theme.LIGHT.ordinal() ? Theme.LIGHT : (i2 == Theme.SYSTEM.ordinal() && com.adguard.kit.compatibility.a.f()) ? Theme.SYSTEM : Theme.DARK).getResId());
setShowMenuButton(getApplicationContext());
com.adguard.commons.concurrent.b.b(new Runnable() {
@Override
public final void run() {
AdguardApplication.this.initApplication();
}
});
LOG.info("AdGuard application created.");
}
}