forked from M66B/cm10-fxp-extended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wifi_auto_connect2.patch
174 lines (159 loc) · 7.71 KB
/
wifi_auto_connect2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
From 2a79816d3cd9ef16dd426981a0fd862b97abdf58 Mon Sep 17 00:00:00 2001
From: ian <[email protected]>
Date: Mon, 3 Dec 2012 15:15:10 -0500
Subject: [PATCH] Patch Set 2/2: Add an "Automatically Connect" option for
WiFi networks Updated white spaces and boolean logic Added
missing layout file More White space fixes
Change-Id: I21063589809afcfe836790fcbc90eae177aae08c
---
res/layout/wifi_dialog.xml | 11 +++++++-
res/values/strings.xml | 2 ++
src/com/android/settings/wifi/AccessPoint.java | 3 +++
.../settings/wifi/WifiConfigController.java | 27 ++++++++++++++++++++
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index c0e98e7..9011a8f 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -75,7 +75,7 @@
android:prompt="@string/wifi_eap_method"
android:entries="@array/wifi_eap_method" />
</LinearLayout>
-
+
<LinearLayout android:id="@+id/l_phase2"
android:visibility="gone"
style="@style/wifi_item" >
@@ -165,6 +165,15 @@
</LinearLayout>
</LinearLayout>
+ <LinearLayout android:id="@+id/wifi_auto_connect_toggle"
+ style="@style/wifi_item"
+ android:visibility="gone">
+ <CheckBox android:id="@+id/wifi_auto_connect_togglebox"
+ style="@style/wifi_item_content"
+ android:textSize="14sp"
+ android:text="@string/wifi_auto_connect" />
+ </LinearLayout>
+
<LinearLayout android:id="@+id/wifi_advanced_toggle"
style="@style/wifi_item"
android:visibility="gone">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5931dae..5864bb2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1257,6 +1257,8 @@
<string name="wifi_setup_wps">Automatic setup (WPS)</string>
<!-- Dialog for Access Points --> <skip />
+ <!-- Label for automatically_connect -->
+ <string name="wifi_auto_connect">Automatically Connect</string>
<!-- Label to show/hide advanced options -->
<string name="wifi_show_advanced">Show advanced options</string>
<!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 5a7a768..4a73543 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -61,6 +61,7 @@ class AccessPoint extends Preference {
String bssid;
int security;
int networkId;
+ boolean autoConnect;
boolean wpsAvailable = false;
PskType pskType = PskType.UNKNOWN;
@@ -187,6 +188,7 @@ class AccessPoint extends Preference {
bssid = config.BSSID;
security = getSecurity(config);
networkId = config.networkId;
+ autoConnect = config.autoConnect;
mRssi = Integer.MAX_VALUE;
mConfig = config;
}
@@ -199,6 +201,7 @@ class AccessPoint extends Preference {
if (security == SECURITY_PSK)
pskType = getPskType(result);
networkId = -1;
+ autoConnect = true;
mRssi = result.level;
mScanResult = result;
}
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 2598a0e..84e99c5 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -118,6 +118,7 @@ public class WifiConfigController implements TextWatcher,
private IpAssignment mIpAssignment = IpAssignment.UNASSIGNED;
private ProxySettings mProxySettings = ProxySettings.UNASSIGNED;
private LinkProperties mLinkProperties = new LinkProperties();
+ private boolean mAutoConnect;
// True when this instance is used in SetupWizard XL context.
private final boolean mInXlSetupWizard;
@@ -160,6 +161,9 @@ public class WifiConfigController implements TextWatcher,
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
mProxySettingsSpinner.setOnItemSelectedListener(this);
+ boolean showAutoConnectField = false;
+ boolean showAutoConnectFieldValue = false;
+
if (mAccessPoint == null) { // new network
mConfigUi.setTitle(R.string.wifi_add_network);
@@ -182,6 +186,9 @@ public class WifiConfigController implements TextWatcher,
showIpConfigFields();
showProxyFields();
+ mView.findViewById(R.id.wifi_auto_connect_toggle).setVisibility(View.VISIBLE);
+ ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(true);
+ mView.findViewById(R.id.wifi_auto_connect_togglebox).setOnClickListener(this);
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);
@@ -230,12 +237,25 @@ public class WifiConfigController implements TextWatcher,
} else {
mProxySettingsSpinner.setSelection(PROXY_NONE);
}
+
+ showAutoConnectField = true;
+ showAutoConnectFieldValue = config.autoConnect;
}
if (mAccessPoint.networkId == INVALID_NETWORK_ID || mEdit) {
showSecurityFields();
showIpConfigFields();
showProxyFields();
+ mView.findViewById(R.id.wifi_auto_connect_toggle).setVisibility(View.VISIBLE);
+ WifiConfiguration config = mAccessPoint.getConfig();
+ if (mEdit) {
+ showAutoConnectField = false;
+ ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(config.autoConnect);
+ } else {
+ mAutoConnect = true;
+ ((CheckBox) mView.findViewById(R.id.wifi_auto_connect_togglebox)).setChecked(true);
+ }
+ mView.findViewById(R.id.wifi_auto_connect_togglebox).setOnClickListener(this);
mView.findViewById(R.id.wifi_advanced_toggle).setVisibility(View.VISIBLE);
mView.findViewById(R.id.wifi_advanced_togglebox).setOnClickListener(this);
if (showAdvancedFields) {
@@ -243,6 +263,10 @@ public class WifiConfigController implements TextWatcher,
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
}
}
+
+ if (showAutoConnectField) {
+ addRow(group, R.string.wifi_auto_connect, (showAutoConnectFieldValue ? context.getString(R.string.yes) : context.getString(R.string.no)));
+ }
if (mEdit) {
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
@@ -388,6 +412,7 @@ public class WifiConfigController implements TextWatcher,
config.proxySettings = mProxySettings;
config.ipAssignment = mIpAssignment;
config.linkProperties = new LinkProperties(mLinkProperties);
+ config.autoConnect = mAutoConnect;
return config;
}
@@ -752,6 +777,8 @@ public class WifiConfigController implements TextWatcher,
} else {
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.GONE);
}
+ } else if (view.getId() == R.id.wifi_auto_connect_togglebox) {
+ mAutoConnect = ((CheckBox) view).isChecked();
}
}
--
1.7.10.4