diff options
-rw-r--r-- | api/current.xml | 24 | ||||
-rw-r--r-- | core/java/android/view/View.java | 12 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 3 | ||||
-rw-r--r-- | core/java/android/widget/SearchView.java | 26 | ||||
-rw-r--r-- | core/res/res/layout/alert_dialog_holo.xml | 155 | ||||
-rw-r--r-- | core/res/res/layout/select_dialog_holo.xml | 36 | ||||
-rw-r--r-- | core/res/res/layout/select_dialog_item_holo.xml | 36 | ||||
-rw-r--r-- | core/res/res/layout/select_dialog_multichoice_holo.xml | 29 | ||||
-rw-r--r-- | core/res/res/layout/select_dialog_singlechoice_holo.xml | 29 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/NetworkUpdateResult.java | 61 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 58 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 14 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 72 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateTracker.java | 4 |
14 files changed, 493 insertions, 66 deletions
diff --git a/api/current.xml b/api/current.xml index 00e242e..1687d5a 100644 --- a/api/current.xml +++ b/api/current.xml @@ -243571,6 +243571,17 @@ <parameter name="attrs" type="android.util.AttributeSet"> </parameter> </constructor> +<method name="getQuery" + return="java.lang.CharSequence" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getSuggestionsAdapter" return="android.widget.CursorAdapter" abstract="false" @@ -243704,6 +243715,19 @@ <parameter name="listener" type="android.view.View.OnFocusChangeListener"> </parameter> </method> +<method name="setOnSearchClickListener" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="listener" type="android.view.View.OnClickListener"> +</parameter> +</method> <method name="setOnSuggestionSelectionListener" return="void" abstract="false" diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index daf9ac4..e3a0715 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6453,6 +6453,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility mPrivateFlags &= ~DRAWING_CACHE_VALID; final ViewParent p = mParent; final AttachInfo ai = mAttachInfo; + if (p != null && ai != null && ai.mHardwareAccelerated) { + // fast-track for GL-enabled applications; just invalidate the whole hierarchy + // with a null dirty rect, which tells the ViewRoot to redraw everything + p.invalidateChild(this, null); + return; + } if (p != null && ai != null && l < r && t < b) { final int scrollX = mScrollX; final int scrollY = mScrollY; @@ -6496,6 +6502,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } final AttachInfo ai = mAttachInfo; final ViewParent p = mParent; + if (p != null && ai != null && ai.mHardwareAccelerated) { + // fast-track for GL-enabled applications; just invalidate the whole hierarchy + // with a null dirty rect, which tells the ViewRoot to redraw everything + p.invalidateChild(this, null); + return; + } if (p != null && ai != null) { final Rect r = ai.mTmpInvalRect; diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index ac63742..7b81b8f 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2349,9 +2349,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager child.draw(canvas); } } else { + child.mPrivateFlags &= ~DIRTY_MASK; ((HardwareCanvas) canvas).drawDisplayList(displayList); } } else if (cache != null) { + child.mPrivateFlags &= ~DIRTY_MASK; final Paint cachePaint = mCachePaint; if (alpha < 1.0f) { cachePaint.setAlpha((int) (alpha * 255)); @@ -2583,6 +2585,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // addViewInner() will call child.requestLayout() when setting the new LayoutParams // therefore, we call requestLayout() on ourselves before, so that the child's request // will be blocked at our level + child.mPrivateFlags &= ~DIRTY_MASK; requestLayout(); invalidate(); addViewInner(child, index, params, false); diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index b296b77..b32bd42 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -44,6 +44,7 @@ import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; @@ -76,6 +77,7 @@ public class SearchView extends LinearLayout { private OnCloseListener mOnCloseListener; private OnFocusChangeListener mOnQueryTextFocusChangeListener; private OnSuggestionSelectionListener mOnSuggestionListener; + private OnClickListener mOnSearchClickListener; private boolean mIconifiedByDefault; private boolean mIconified; @@ -301,6 +303,27 @@ public class SearchView extends LinearLayout { } /** + * Sets a listener to inform when the search button is pressed. This is only + * relevant when the text field is not visible by default. Calling #setIconified(false) + * can also cause this listener to be informed. + * + * @param listener the listener to inform when the search button is clicked or + * the text field is programmatically de-iconified. + */ + public void setOnSearchClickListener(OnClickListener listener) { + mOnSearchClickListener = listener; + } + + /** + * Returns the query string currently in the text field. + * + * @return the query string + */ + public CharSequence getQuery() { + return mQueryTextView.getText(); + } + + /** * Sets a query string in the text field and optionally submits the query as well. * * @param query the query string. This replaces any query text already present in the @@ -831,6 +854,9 @@ public class SearchView extends LinearLayout { mQueryTextView.requestFocus(); updateViewsVisibility(false); setImeVisibility(true); + if (mOnSearchClickListener != null) { + mOnSearchClickListener.onClick(this); + } } private void onVoiceClicked() { diff --git a/core/res/res/layout/alert_dialog_holo.xml b/core/res/res/layout/alert_dialog_holo.xml new file mode 100644 index 0000000..9579bcb --- /dev/null +++ b/core/res/res/layout/alert_dialog_holo.xml @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2010, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<com.android.internal.widget.WeightedLinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/parentPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingTop="9dip" + android:paddingBottom="3dip" + android:paddingLeft="3dip" + android:paddingRight="1dip" + android:majorWeightMin="0.65" + android:minorWeightMin="0.9"> + + <LinearLayout android:id="@+id/topPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="48dip" + android:orientation="vertical"> + <LinearLayout android:id="@+id/title_template" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="center_vertical" + android:layout_marginTop="8dip" + android:layout_marginBottom="8dip" + android:layout_marginLeft="32dip" + android:layout_marginRight="32dip"> + <ImageView android:id="@+id/icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingRight="16dip" + android:src="@null" /> + <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle" + style="?android:attr/textAppearanceMedium" + android:singleLine="true" + android:ellipsize="end" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + </LinearLayout> + <ImageView android:id="@+id/titleDivider" + android:layout_width="match_parent" + android:layout_height="1dip" + android:visibility="gone" + android:scaleType="fitXY" + android:gravity="fill_horizontal" + android:src="@android:drawable/divider_horizontal_dark" /> + <!-- If the client uses a customTitle, it will be added here. --> + </LinearLayout> + + <LinearLayout android:id="@+id/contentPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical"> + <ScrollView android:id="@+id/scrollView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="16dip" + android:layout_marginRight="16dip" + android:paddingTop="32dip" + android:paddingBottom="32dip" + android:clipToPadding="false"> + <TextView android:id="@+id/message" + style="?android:attr/textAppearanceMedium" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingLeft="16dip" + android:paddingRight="16dip" /> + </ScrollView> + </LinearLayout> + + <FrameLayout android:id="@+id/customPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1"> + <FrameLayout android:id="@+android:id/custom" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="8dip" + android:paddingBottom="8dip" + android:paddingLeft="32dip" + android:paddingRight="32dip" /> + </FrameLayout> + + <LinearLayout android:id="@+id/buttonPanel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="54dip" + android:orientation="vertical" + android:divider="?android:attr/dividerHorizontal" + android:showDividers="beginning" + android:dividerPadding="16dip"> + <LinearLayout + style="?android:attr/buttonGroupStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingLeft="2dip" + android:paddingRight="2dip" + android:measureWithLargestChild="true"> + <LinearLayout android:id="@+id/leftSpacer" + android:layout_weight="0.25" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" /> + <Button android:id="@+id/button1" + android:layout_width="0dip" + android:layout_gravity="left" + android:layout_weight="1" + android:maxLines="2" + style="?android:attr/borderlessButtonStyle" + android:layout_height="wrap_content" /> + <Button android:id="@+id/button3" + android:layout_width="0dip" + android:layout_gravity="center_horizontal" + android:layout_weight="1" + android:maxLines="2" + style="?android:attr/borderlessButtonStyle" + android:layout_height="wrap_content" /> + <Button android:id="@+id/button2" + android:layout_width="0dip" + android:layout_gravity="right" + android:layout_weight="1" + android:maxLines="2" + style="?android:attr/borderlessButtonStyle" + android:layout_height="wrap_content" /> + <LinearLayout android:id="@+id/rightSpacer" + android:layout_width="0dip" + android:layout_weight="0.25" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:visibility="gone" /> + </LinearLayout> + </LinearLayout> +</com.android.internal.widget.WeightedLinearLayout> diff --git a/core/res/res/layout/select_dialog_holo.xml b/core/res/res/layout/select_dialog_holo.xml new file mode 100644 index 0000000..7c95693 --- /dev/null +++ b/core/res/res/layout/select_dialog_holo.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2010, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- + This layout file is used by the AlertDialog when displaying a list of items. + This layout file is inflated and used as the ListView to display the items. + Assign an ID so its state will be saved/restored. +--> +<view class="com.android.internal.app.AlertController$RecycleListView" + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+android:id/select_dialog_listview" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginTop="5dip" + android:paddingLeft="16dip" + android:paddingRight="16dip" + android:cacheColorHint="@null" + android:divider="?android:attr/listDividerAlertDialog" + android:scrollbars="vertical" + android:overScrollMode="ifContentScrolls" /> diff --git a/core/res/res/layout/select_dialog_item_holo.xml b/core/res/res/layout/select_dialog_item_holo.xml new file mode 100644 index 0000000..396092e --- /dev/null +++ b/core/res/res/layout/select_dialog_item_holo.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2010, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- + This layout file is used by the AlertDialog when displaying a list of items. + This layout file is inflated and used as the TextView to display individual + items. +--> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorAlertDialogListItem" + android:gravity="center_vertical" + android:paddingLeft="16dip" + android:paddingRight="16dip" + android:ellipsize="marquee" +/> diff --git a/core/res/res/layout/select_dialog_multichoice_holo.xml b/core/res/res/layout/select_dialog_multichoice_holo.xml new file mode 100644 index 0000000..8027035 --- /dev/null +++ b/core/res/res/layout/select_dialog_multichoice_holo.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorAlertDialogListItem" + android:gravity="center_vertical" + android:paddingLeft="16dip" + android:paddingRight="16dip" + android:checkMark="?android:attr/listChoiceIndicatorMultiple" + android:ellipsize="marquee" +/> diff --git a/core/res/res/layout/select_dialog_singlechoice_holo.xml b/core/res/res/layout/select_dialog_singlechoice_holo.xml new file mode 100644 index 0000000..cab519f --- /dev/null +++ b/core/res/res/layout/select_dialog_singlechoice_holo.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="?android:attr/listPreferredItemHeight" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorAlertDialogListItem" + android:gravity="center_vertical" + android:paddingLeft="16dip" + android:paddingRight="16dip" + android:checkMark="?android:attr/listChoiceIndicatorSingle" + android:ellipsize="marquee" +/> diff --git a/wifi/java/android/net/wifi/NetworkUpdateResult.java b/wifi/java/android/net/wifi/NetworkUpdateResult.java new file mode 100644 index 0000000..6b7b68b --- /dev/null +++ b/wifi/java/android/net/wifi/NetworkUpdateResult.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net.wifi; + +import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID; + +class NetworkUpdateResult { + int netId; + boolean ipChanged; + boolean proxyChanged; + + public NetworkUpdateResult(int id) { + netId = id; + ipChanged = false; + proxyChanged = false; + } + + public NetworkUpdateResult(boolean ip, boolean proxy) { + netId = INVALID_NETWORK_ID; + ipChanged = ip; + proxyChanged = proxy; + } + + public void setNetworkId(int id) { + netId = id; + } + + public int getNetworkId() { + return netId; + } + + public void setIpChanged(boolean ip) { + ipChanged = ip; + } + + public boolean hasIpChanged() { + return ipChanged; + } + + public void setProxyChanged(boolean proxy) { + proxyChanged = proxy; + } + + public boolean hasProxyChanged() { + return proxyChanged; + } +} diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index 24f6f31..c6b0299 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -16,7 +16,6 @@ package android.net.wifi; -import android.app.ActivityManagerNative; import android.content.Context; import android.content.Intent; import android.net.DhcpInfo; @@ -28,6 +27,7 @@ import android.net.wifi.WifiConfiguration.IpAssignment; import android.net.wifi.WifiConfiguration.KeyMgmt; import android.net.wifi.WifiConfiguration.ProxySettings; import android.net.wifi.WifiConfiguration.Status; +import android.net.wifi.NetworkUpdateResult; import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID; import android.os.Environment; import android.text.TextUtils; @@ -42,7 +42,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.BitSet; @@ -178,7 +177,7 @@ class WifiConfigStore { } WifiNative.saveConfigCommand(); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); } /** @@ -194,7 +193,8 @@ class WifiConfigStore { */ static void selectNetwork(WifiConfiguration config) { if (config != null) { - int netId = addOrUpdateNetworkNative(config); + NetworkUpdateResult result = addOrUpdateNetworkNative(config); + int netId = result.getNetworkId(); if (netId != INVALID_NETWORK_ID) { selectNetwork(netId); } else { @@ -248,9 +248,10 @@ class WifiConfigStore { * * @param config WifiConfiguration to be saved */ - static void saveNetwork(WifiConfiguration config) { + static NetworkUpdateResult saveNetwork(WifiConfiguration config) { boolean newNetwork = (config.networkId == INVALID_NETWORK_ID); - int netId = addOrUpdateNetworkNative(config); + NetworkUpdateResult result = addOrUpdateNetworkNative(config); + int netId = result.getNetworkId(); /* enable a new network */ if (newNetwork && netId != INVALID_NETWORK_ID) { WifiNative.enableNetworkCommand(netId, false); @@ -259,7 +260,8 @@ class WifiConfigStore { } } WifiNative.saveConfigCommand(); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); + return result; } /** @@ -274,7 +276,7 @@ class WifiConfigStore { sConfiguredNetworks.remove(netId); } writeIpAndProxyConfigurations(); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); } else { Log.e(TAG, "Failed to remove network " + netId); } @@ -289,9 +291,9 @@ class WifiConfigStore { * @param config wifi configuration to add/update */ static int addOrUpdateNetwork(WifiConfiguration config) { - int ret = addOrUpdateNetworkNative(config); - sendConfigChangeBroadcast(); - return ret; + NetworkUpdateResult result = addOrUpdateNetworkNative(config); + sendConfiguredNetworksChangedBroadcast(); + return result.getNetworkId(); } /** @@ -307,7 +309,7 @@ class WifiConfigStore { synchronized (sConfiguredNetworks) { if (ret) sConfiguredNetworks.remove(netId); } - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); return ret; } @@ -321,7 +323,7 @@ class WifiConfigStore { */ static boolean enableNetwork(int netId, boolean disableOthers) { boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); return ret; } @@ -349,7 +351,7 @@ class WifiConfigStore { WifiConfiguration config = sConfiguredNetworks.get(netId); if (config != null) config.status = Status.DISABLED; } - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); return ret; } @@ -475,9 +477,9 @@ class WifiConfigStore { return false; } - private static void sendConfigChangeBroadcast() { - if (!ActivityManagerNative.isSystemReady()) return; - Intent intent = new Intent(WifiManager.SUPPLICANT_CONFIG_CHANGED_ACTION); + private static void sendConfiguredNetworksChangedBroadcast() { + Intent intent = new Intent(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); sContext.sendBroadcast(intent); } @@ -522,7 +524,7 @@ class WifiConfigStore { } } readIpAndProxyConfigurations(); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); } /* Mark all networks except specified netId as disabled */ @@ -748,7 +750,7 @@ class WifiConfigStore { } } - private static int addOrUpdateNetworkNative(WifiConfiguration config) { + private static NetworkUpdateResult addOrUpdateNetworkNative(WifiConfiguration config) { /* * If the supplied networkId is INVALID_NETWORK_ID, we create a new empty * network configuration. Otherwise, the networkId should @@ -756,14 +758,14 @@ class WifiConfigStore { */ int netId = config.networkId; boolean updateFailed = true; - boolean newNetwork = (netId == INVALID_NETWORK_ID); // networkId of INVALID_NETWORK_ID means we want to create a new network + boolean newNetwork = (netId == INVALID_NETWORK_ID); if (newNetwork) { netId = WifiNative.addNetworkCommand(); if (netId < 0) { Log.e(TAG, "Failed to add a network!"); - return INVALID_NETWORK_ID; + return new NetworkUpdateResult(INVALID_NETWORK_ID); } } @@ -937,7 +939,7 @@ class WifiConfigStore { "Failed to set a network variable, removed network: " + netId); } - return INVALID_NETWORK_ID; + return new NetworkUpdateResult(INVALID_NETWORK_ID); } /* An update of the network variables requires reading them @@ -959,12 +961,15 @@ class WifiConfigStore { } } readNetworkVariables(sConfig); - writeIpAndProxyConfigurationsOnChange(sConfig, config); - return netId; + + NetworkUpdateResult result = writeIpAndProxyConfigurationsOnChange(sConfig, config); + result.setNetworkId(netId); + return result; } /* Compare current and new configuration and write to file on change */ - private static void writeIpAndProxyConfigurationsOnChange(WifiConfiguration currentConfig, + private static NetworkUpdateResult writeIpAndProxyConfigurationsOnChange( + WifiConfiguration currentConfig, WifiConfiguration newConfig) { boolean ipChanged = false; boolean proxyChanged = false; @@ -1056,8 +1061,9 @@ class WifiConfigStore { if (ipChanged || proxyChanged) { currentConfig.linkProperties = linkProperties; writeIpAndProxyConfigurations(); - sendConfigChangeBroadcast(); + sendConfiguredNetworksChangedBroadcast(); } + return new NetworkUpdateResult(ipChanged, proxyChanged); } private static void addIpSettingsFromConfig(LinkProperties linkProperties, diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 8d97ea0..e3be5b3 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -131,7 +131,6 @@ public class WifiManager { * * @hide */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String WIFI_AP_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_AP_STATE_CHANGED"; @@ -276,13 +275,12 @@ public class WifiManager { */ public static final String EXTRA_SUPPLICANT_ERROR = "supplicantError"; /** - * Broadcast intent action indicating that the supplicant configuration changed. + * Broadcast intent action indicating that the configured networks changed. * This can be as a result of adding/updating/deleting a network * @hide */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String SUPPLICANT_CONFIG_CHANGED_ACTION = - "android.net.wifi.supplicant.CONFIG_CHANGE"; + public static final String CONFIGURED_NETWORKS_CHANGED_ACTION = + "android.net.wifi.CONFIGURED_NETWORKS_CHANGE"; /** * An access point scan has completed, and results are available from the supplicant. * Call {@link #getScanResults()} to obtain the results. @@ -301,12 +299,12 @@ public class WifiManager { public static final String EXTRA_NEW_RSSI = "newRssi"; /** - * Broadcast intent action indicating that the IP configuration + * Broadcast intent action indicating that the link configuration * changed on wifi. * @hide */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String CONFIG_CHANGED_ACTION = "android.net.wifi.CONFIG_CHANGED"; + public static final String LINK_CONFIGURATION_CHANGED_ACTION = + "android.net.wifi.LINK_CONFIGURATION_CHANGED"; /** * The lookup key for a {@link android.net.LinkProperties} object associated with the diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 7e3df1a..4828700b 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -37,7 +37,6 @@ import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED; import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING; import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED; -import android.app.ActivityManagerNative; import android.app.AlarmManager; import android.app.PendingIntent; import android.net.LinkAddress; @@ -47,6 +46,7 @@ import android.net.NetworkUtils; import android.net.ConnectivityManager; import android.net.NetworkInfo.DetailedState; import android.net.LinkProperties; +import android.net.wifi.NetworkUpdateResult; import android.os.Binder; import android.os.Message; import android.os.IBinder; @@ -193,9 +193,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { static final int CMD_IP_CONFIG_SUCCESS = 15; /* Indicates DHCP failed */ static final int CMD_IP_CONFIG_FAILURE = 16; - /* Re-configure interface */ - static final int CMD_RECONFIGURE_IP = 17; - /* Start the soft access point */ static final int CMD_START_AP = 21; @@ -1336,15 +1333,14 @@ public class WifiStateMachine extends HierarchicalStateMachine { }; private void sendScanResultsAvailableBroadcast() { - if (!ActivityManagerNative.isSystemReady()) return; - - mContext.sendBroadcast(new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); + Intent intent = new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); + mContext.sendBroadcast(intent); } private void sendRssiChangeBroadcast(final int newRssi) { - if (!ActivityManagerNative.isSystemReady()) return; - Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi); mContext.sendBroadcast(intent); } @@ -1360,18 +1356,16 @@ public class WifiStateMachine extends HierarchicalStateMachine { mContext.sendStickyBroadcast(intent); } - /* TODO: Unused for now, will be used when ip change on connected network is handled */ - private void sendConfigChangeBroadcast() { - if (!ActivityManagerNative.isSystemReady()) return; - Intent intent = new Intent(WifiManager.CONFIG_CHANGED_ACTION); + private void sendLinkConfigurationChangedBroadcast() { + Intent intent = new Intent(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties); mContext.sendBroadcast(intent); } private void sendSupplicantConnectionChangedBroadcast(boolean connected) { - if (!ActivityManagerNative.isSystemReady()) return; - Intent intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, connected); mContext.sendBroadcast(intent); } @@ -1380,7 +1374,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { * Record the detailed state of a network. * @param state the new @{code DetailedState} */ - private void setDetailedState(NetworkInfo.DetailedState state) { + private void setNetworkDetailedState(NetworkInfo.DetailedState state) { Log.d(TAG, "setDetailed state, old =" + mNetworkInfo.getDetailedState() + " and new state=" + state); if (state != mNetworkInfo.getDetailedState()) { @@ -1388,6 +1382,10 @@ public class WifiStateMachine extends HierarchicalStateMachine { } } + private DetailedState getNetworkDetailedState() { + return mNetworkInfo.getDetailedState(); + } + /** * Resets the Wi-Fi Connections by clearing any state, resetting any sockets * using the interface, stopping DHCP & disabling interface @@ -1408,7 +1406,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { NetworkUtils.disableInterface(mInterfaceName); /* send event to CM & network change broadcast */ - setDetailedState(DetailedState.DISCONNECTED); + setNetworkDetailedState(DetailedState.DISCONNECTED); sendNetworkStateChangeBroadcast(mLastBssid); /* Reset data structures */ @@ -1576,7 +1574,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_DISCONNECT: case CMD_RECONNECT: case CMD_REASSOCIATE: - case CMD_RECONFIGURE_IP: case SUP_CONNECTION_EVENT: case SUP_DISCONNECTION_EVENT: case DRIVER_START_EVENT: @@ -2415,7 +2412,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { mWifiInfo.setNetworkId(stateChangeResult.networkId); mLastNetworkId = stateChangeResult.networkId; /* send event to CM & network change broadcast */ - setDetailedState(DetailedState.OBTAINING_IPADDR); + setNetworkDetailedState(DetailedState.OBTAINING_IPADDR); sendNetworkStateChangeBroadcast(mLastBssid); transitionTo(mConnectingState); break; @@ -2526,8 +2523,12 @@ public class WifiStateMachine extends HierarchicalStateMachine { mWifiInfo.setIpAddress(mDhcpInfo.ipAddress); } configureLinkProperties(); - setDetailedState(DetailedState.CONNECTED); - sendNetworkStateChangeBroadcast(mLastBssid); + if (getNetworkDetailedState() == DetailedState.CONNECTED) { + sendLinkConfigurationChangedBroadcast(); + } else { + setNetworkDetailedState(DetailedState.CONNECTED); + sendNetworkStateChangeBroadcast(mLastBssid); + } //TODO: The framework is not detecting a DHCP renewal and a possible //IP change. we should detect this and send out a config change broadcast transitionTo(mConnectedState); @@ -2565,6 +2566,9 @@ public class WifiStateMachine extends HierarchicalStateMachine { break; } return NOT_HANDLED; + case CMD_SAVE_NETWORK: + deferMessage(message); + break; /* Ignore */ case NETWORK_CONNECTION_EVENT: break; @@ -2582,9 +2586,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { case CMD_START_SCAN: deferMessage(message); break; - case CMD_RECONFIGURE_IP: - deferMessage(message); - break; /* Defer any power mode changes since we must keep active power mode at DHCP */ case CMD_SET_HIGH_PERF_MODE: deferMessage(message); @@ -2632,11 +2633,6 @@ public class WifiStateMachine extends HierarchicalStateMachine { WifiNative.disconnectCommand(); transitionTo(mDisconnectingState); break; - case CMD_RECONFIGURE_IP: - Log.d(TAG,"Reconfiguring IP on connection"); - NetworkUtils.resetConnections(mInterfaceName); - transitionTo(mConnectingState); - break; case CMD_STOP_DRIVER: sendMessage(CMD_DISCONNECT); deferMessage(message); @@ -2663,6 +2659,22 @@ public class WifiStateMachine extends HierarchicalStateMachine { break; } return NOT_HANDLED; + case CMD_SAVE_NETWORK: + WifiConfiguration config = (WifiConfiguration) message.obj; + NetworkUpdateResult result = WifiConfigStore.saveNetwork(config); + if (mWifiInfo.getNetworkId() == result.getNetworkId()) { + if (result.hasIpChanged()) { + Log.d(TAG,"Reconfiguring IP on connection"); + NetworkUtils.resetConnections(mInterfaceName); + transitionTo(mConnectingState); + } + if (result.hasProxyChanged()) { + Log.d(TAG,"Reconfiguring proxy on connection"); + configureLinkProperties(); + sendLinkConfigurationChangedBroadcast(); + } + } + break; /* Ignore */ case NETWORK_CONNECTION_EVENT: break; @@ -2767,7 +2779,7 @@ public class WifiStateMachine extends HierarchicalStateMachine { case SUPPLICANT_STATE_CHANGE_EVENT: StateChangeResult stateChangeResult = (StateChangeResult) message.obj; SupplicantState state = (SupplicantState) stateChangeResult.state; - setDetailedState(WifiInfo.getDetailedStateOf(state)); + setNetworkDetailedState(WifiInfo.getDetailedStateOf(state)); /* DriverStartedState does the rest of the handling */ return NOT_HANDLED; default: diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java index f8c9bd6..d0231be 100644 --- a/wifi/java/android/net/wifi/WifiStateTracker.java +++ b/wifi/java/android/net/wifi/WifiStateTracker.java @@ -86,7 +86,7 @@ public class WifiStateTracker implements NetworkStateTracker { mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); - filter.addAction(WifiManager.CONFIG_CHANGED_ACTION); + filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION); mWifiStateReceiver = new WifiStateReceiver(); mContext.registerReceiver(mWifiStateReceiver, filter); @@ -254,7 +254,7 @@ public class WifiStateTracker implements NetworkStateTracker { } Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); - } else if (intent.getAction().equals(WifiManager.CONFIG_CHANGED_ACTION)) { + } else if (intent.getAction().equals(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION)) { mLinkProperties = (LinkProperties) intent.getParcelableExtra( WifiManager.EXTRA_LINK_PROPERTIES); Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); |