Implemented local hosts resolver on boot
This commit is contained in:
parent
b6ea6ff647
commit
59d080b217
@ -1,13 +1,18 @@
|
|||||||
package org.itxtech.daedalus.receiver;
|
package org.itxtech.daedalus.receiver;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.VpnService;
|
import android.net.VpnService;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.itxtech.daedalus.Daedalus;
|
import org.itxtech.daedalus.Daedalus;
|
||||||
import org.itxtech.daedalus.service.DaedalusVpnService;
|
import org.itxtech.daedalus.service.DaedalusVpnService;
|
||||||
import org.itxtech.daedalus.util.DnsServer;
|
import org.itxtech.daedalus.util.DnsServer;
|
||||||
|
import org.itxtech.daedalus.util.HostsResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
@ -24,6 +29,16 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
|
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
|
||||||
|
|
||||||
|
if (Daedalus.getPrefs().getBoolean("settings_local_host_resolve", false)) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
int permission = ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HostsResolver.startLoad(context.getExternalFilesDir(null).getPath() + "/hosts");
|
||||||
|
}
|
||||||
|
|
||||||
Intent vIntent = VpnService.prepare(context);
|
Intent vIntent = VpnService.prepare(context);
|
||||||
if (vIntent != null) {
|
if (vIntent != null) {
|
||||||
context.startActivity(vIntent);
|
context.startActivity(vIntent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user