Fixed startActivity bugs on Android 6.0 and below
This commit is contained in:
parent
885b1f1779
commit
1f4957a476
@ -78,9 +78,9 @@ public class Daedalus extends Application {
|
|||||||
|
|
||||||
public static Configurations configurations;
|
public static Configurations configurations;
|
||||||
|
|
||||||
public static String hostsPath;
|
public static String hostsPath = null;
|
||||||
public static String dnsmasqPath;
|
public static String dnsmasqPath = null;
|
||||||
private static String configPath;
|
private static String configPath = null;
|
||||||
|
|
||||||
private static Daedalus instance = null;
|
private static Daedalus instance = null;
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences prefs;
|
||||||
@ -93,12 +93,14 @@ public class Daedalus extends Application {
|
|||||||
mHostsResolver = new Thread(new RulesResolver());
|
mHostsResolver = new Thread(new RulesResolver());
|
||||||
mHostsResolver.start();
|
mHostsResolver.start();
|
||||||
|
|
||||||
|
if (getExternalFilesDir(null) != null) {
|
||||||
hostsPath = getExternalFilesDir(null).getPath() + "/hosts";
|
hostsPath = getExternalFilesDir(null).getPath() + "/hosts";
|
||||||
dnsmasqPath = getExternalFilesDir(null).getPath() + "/dnsmasq/";
|
dnsmasqPath = getExternalFilesDir(null).getPath() + "/dnsmasq/";
|
||||||
configPath = getExternalFilesDir(null).getPath() + "/config.json";
|
configPath = getExternalFilesDir(null).getPath() + "/config.json";
|
||||||
|
|
||||||
File file = new File(dnsmasqPath);
|
File file = new File(dnsmasqPath);
|
||||||
Log.d(TAG, "mkdir result: " + file.mkdirs());
|
Log.d(TAG, "mkdir result: " + file.mkdirs());
|
||||||
|
}
|
||||||
|
|
||||||
initData();
|
initData();
|
||||||
|
|
||||||
@ -109,7 +111,11 @@ public class Daedalus extends Application {
|
|||||||
PreferenceManager.setDefaultValues(this, R.xml.perf_settings, false);
|
PreferenceManager.setDefaultValues(this, R.xml.perf_settings, false);
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
if (configPath != null) {
|
||||||
configurations = Configurations.load(new File(configPath));
|
configurations = Configurations.load(new File(configPath));
|
||||||
|
} else {
|
||||||
|
configurations = new Configurations();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseJson(Class<T> beanClass, JsonReader reader) throws JsonParseException {
|
public static <T> T parseJson(Class<T> beanClass, JsonReader reader) throws JsonParseException {
|
||||||
|
@ -26,6 +26,7 @@ public class BootBroadcastReceiver extends BroadcastReceiver {
|
|||||||
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
|
if (Daedalus.getPrefs().getBoolean("settings_boot", false)) {
|
||||||
Intent vIntent = VpnService.prepare(context);
|
Intent vIntent = VpnService.prepare(context);
|
||||||
if (vIntent != null) {
|
if (vIntent != null) {
|
||||||
|
vIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(vIntent);
|
context.startActivity(vIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public class StatusBarBroadcastReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (intent.getAction().equals(STATUS_BAR_BTN_SETTINGS_CLICK_ACTION)) {
|
if (intent.getAction().equals(STATUS_BAR_BTN_SETTINGS_CLICK_ACTION)) {
|
||||||
Intent settingsIntent = new Intent(context, MainActivity.class).putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS);
|
Intent settingsIntent = new Intent(context, MainActivity.class).putExtra(MainActivity.LAUNCH_FRAGMENT, MainActivity.FRAGMENT_SETTINGS);
|
||||||
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(settingsIntent);
|
context.startActivity(settingsIntent);
|
||||||
try {
|
try {
|
||||||
Object statusBarManager = context.getSystemService("statusbar");
|
Object statusBarManager = context.getSystemService("statusbar");
|
||||||
|
@ -173,7 +173,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
|||||||
try {
|
try {
|
||||||
Builder builder = new Builder();
|
Builder builder = new Builder();
|
||||||
String format = null;
|
String format = null;
|
||||||
for (String prefix : new String[]{"192.0.2", "198.51.100", "203.0.113", "10.0.0", "192.168.50"}) {
|
for (String prefix : new String[]{"10.0.0", "192.0.2", "198.51.100", "203.0.113", "192.168.50"}) {
|
||||||
try {
|
try {
|
||||||
builder.addAddress(prefix + ".1", 24);
|
builder.addAddress(prefix + ".1", 24);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user