MinSDK -> 15 Android 4.0.3, support more devices
This commit is contained in:
parent
6c46ab580b
commit
80b23b70d5
@ -7,7 +7,7 @@ android {
|
||||
buildToolsVersion "25.0.2"
|
||||
defaultConfig {
|
||||
applicationId "org.itxtech.daedalus"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 25
|
||||
versionCode 2
|
||||
versionName "1.0.1"
|
||||
|
@ -2,10 +2,12 @@ package org.itxtech.daedalus.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -25,6 +27,7 @@ import org.itxtech.daedalus.util.DnsServer;
|
||||
* the Free Software Foundation, version 3.
|
||||
*/
|
||||
public class SettingsFragment extends PreferenceFragment {
|
||||
private View view = null;
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -37,11 +40,17 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
ListPreference secondaryServer = (ListPreference) findPreference("secondary_server");
|
||||
secondaryServer.setEntries(DnsServer.getDnsServerNames(Daedalus.getInstance()));
|
||||
secondaryServer.setEntryValues(DnsServer.getDnsServerIds());
|
||||
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
SwitchPreference countQueryTimes = (SwitchPreference) findPreference("settings_count_query_times");
|
||||
countQueryTimes.setChecked(false);
|
||||
countQueryTimes.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
ListPreference checkUpdate = (ListPreference) findPreference("settings_check_update");
|
||||
checkUpdate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@ -56,4 +65,20 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (view != null && Build.VERSION.SDK_INT < 21) {
|
||||
Snackbar.make(view, R.string.notice_legacy_api, Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
view = null;
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +143,12 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
if (this.mThread != null) {
|
||||
this.running = false;
|
||||
this.mThread.interrupt();
|
||||
Os.close(mInterruptFd);
|
||||
Os.close(mBlockFd);
|
||||
if (mInterruptFd != null) {
|
||||
Os.close(mInterruptFd);
|
||||
}
|
||||
if (mBlockFd != null) {
|
||||
Os.close(mBlockFd);
|
||||
}
|
||||
this.mThread = null;
|
||||
}
|
||||
if (notification != null) {
|
||||
@ -166,10 +170,6 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FileDescriptor[] pipes = Os.pipe();
|
||||
mInterruptFd = pipes[0];
|
||||
mBlockFd = pipes[1];
|
||||
|
||||
Builder builder = new Builder();
|
||||
String format = null;
|
||||
for (String prefix : new String[]{"192.0.2", "198.51.100", "203.0.113", "10.0.0.", "192.168.50"}) {
|
||||
@ -185,7 +185,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
this.descriptor.close();
|
||||
}
|
||||
|
||||
boolean statisticQuery = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("settings_query", false);
|
||||
boolean statisticQuery = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("settings_count_query_times", false);
|
||||
Log.d(TAG, "tun0 add " + format + " pServ " + primaryServer + " sServ " + secondaryServer);
|
||||
Inet4Address primaryDNSServer = InetAddressUtil.ipv4From(primaryServer);
|
||||
Inet4Address secondaryDNSServer = InetAddressUtil.ipv4From(secondaryServer);
|
||||
@ -194,13 +194,17 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
|
||||
if (statisticQuery) {
|
||||
builder.addRoute(primaryDNSServer, primaryDNSServer.getAddress().length * 8)
|
||||
.addRoute(secondaryDNSServer, secondaryDNSServer.getAddress().length * 8);
|
||||
.addRoute(secondaryDNSServer, secondaryDNSServer.getAddress().length * 8)
|
||||
.setBlocking(true);
|
||||
}
|
||||
|
||||
this.descriptor = builder.setSession("Daedalus").setConfigureIntent(PendingIntent.getActivity(this, 0, new Intent(this, SettingsActivity.class), PendingIntent.FLAG_ONE_SHOT)).setBlocking(true).establish();
|
||||
this.descriptor = builder.setSession("Daedalus").setConfigureIntent(PendingIntent.getActivity(this, 0, new Intent(this, SettingsActivity.class), PendingIntent.FLAG_ONE_SHOT)).establish();
|
||||
|
||||
if (statisticQuery) {
|
||||
Log.d(TAG, "Starting count queries");
|
||||
FileDescriptor[] pipes = Os.pipe();
|
||||
mInterruptFd = pipes[0];
|
||||
mBlockFd = pipes[1];
|
||||
FileInputStream inputStream = new FileInputStream(descriptor.getFileDescriptor());
|
||||
FileOutputStream outputStream = new FileOutputStream(descriptor.getFileDescriptor());
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
<string name="test_domain">测试域名:</string>
|
||||
<string name="test_time_used">耗时:</string>
|
||||
<string name="test_dns_server">DNS 服务器:</string>
|
||||
<string name="test_result_resolved">解析结果:</string>
|
||||
<string name="test_result_resolved">解析地址:</string>
|
||||
<string name="test_failed">查询失败。超时或未知的主机。</string>
|
||||
<string name="test_test_domain">google.com</string>
|
||||
<string name="action_visit_cutedns">访问 CuteDNS!</string>
|
||||
@ -35,4 +35,5 @@
|
||||
<string name="notice_checking_update">正在前往 GitHub Releases 页面……</string>
|
||||
<string name="settings_count_number_of_queries">统计 DNS 查询次数</string>
|
||||
<string name="notification_queries">DNS 查询次数:</string>
|
||||
<string name="notice_legacy_api">当前 Android API 无法支持所有功能。</string>
|
||||
</resources>
|
@ -20,7 +20,7 @@
|
||||
<string name="test_domain">Test domain:</string>
|
||||
<string name="test_time_used">Time used:</string>
|
||||
<string name="test_dns_server">DNS server:</string>
|
||||
<string name="test_result_resolved">Resolved address:</string>
|
||||
<string name="test_result_resolved">Address:</string>
|
||||
<string name="test_failed">Query failed. Timeout or unknown hostname.</string>
|
||||
<string name="test_test_domain">google.com</string>
|
||||
<string name="action_visit_itxtech">Visit iTXTech</string>
|
||||
@ -33,6 +33,7 @@
|
||||
<string name="settings_check_update">Check update</string>
|
||||
<string name="settings_update_summary">Check update via GitHub</string>
|
||||
<string name="notice_checking_update">Going to the GitHub Releases page …</string>
|
||||
<string name="settings_count_number_of_queries">Count number of DNS queries</string>
|
||||
<string name="settings_count_number_of_queries">Count DNS query times</string>
|
||||
<string name="notification_queries">DNS Query times:</string>
|
||||
<string name="notice_legacy_api">The current Android API can not support all the features.</string>
|
||||
</resources>
|
||||
|
@ -26,7 +26,7 @@
|
||||
android:title="@string/settings_boot"
|
||||
android:defaultValue="false"/>
|
||||
<SwitchPreference
|
||||
android:key="settings_query"
|
||||
android:key="settings_count_query_times"
|
||||
android:title="@string/settings_count_number_of_queries"
|
||||
android:defaultValue="false"/>
|
||||
<SwitchPreference
|
||||
|
Loading…
x
Reference in New Issue
Block a user