Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-11-29 09:28:46 -08:00
23 changed files with 122 additions and 112 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -4,9 +4,9 @@
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.
@@ -15,43 +15,44 @@
-->
<!-- Layout used for ProgressCategory in bluetooth settings. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/listSeparatorTextViewStyle">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/listSeparatorTextViewStyle"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<!-- This and the other text view have the style of the list separator text view without the background and padding -->
<TextView
<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:background="@null"
android:paddingLeft="0dip"
android:paddingLeft="32dip"
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:layout_gravity="center_vertical"
/>
<ProgressBar
android:id="@+id/scanning_progress"
android:text="@string/progress_scanning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="?android:attr/scrollbarSize"
style="?android:attr/progressBarStyleSmallTitle"
/>
<TextView
<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:background="@null"
android:paddingLeft="0dip"
android:id="@+id/scanning_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/scanning_progress"
android:layout_gravity="center_vertical"
android:layout_marginRight="5sp"
android:text="@string/progress_scanning"
/>
</RelativeLayout>
<ProgressBar
android:id="@+id/scanning_progress"
android:text="@string/progress_scanning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dip"
style="?android:attr/progressBarStyleSmallTitle"
/>
</LinearLayout>

View File

@@ -18,6 +18,4 @@
android:id="@+id/signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4sp"
android:layout_gravity="center_vertical"
android:src="@drawable/wifi_signal" />

View File

@@ -25,6 +25,7 @@ import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
@@ -584,42 +585,12 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getName());
boolean printUuids = true;
BluetoothClass bluetoothClass = mDevice.getBluetoothClass();
if (bluetoothClass != null) {
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HEADSET) !=
mProfiles.contains(Profile.HEADSET)) {
Log.v(TAG, "headset classbits != uuid");
printUuids = true;
}
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_A2DP) !=
mProfiles.contains(Profile.A2DP)) {
Log.v(TAG, "a2dp classbits != uuid");
printUuids = true;
}
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_OPP) !=
mProfiles.contains(Profile.OPP)) {
Log.v(TAG, "opp classbits != uuid");
printUuids = true;
}
if (bluetoothClass.doesClassMatch(BluetoothClass.PROFILE_HID) !=
mProfiles.contains(Profile.HID)) {
Log.v(TAG, "hid classbits != uuid");
printUuids = true;
}
}
if (printUuids) {
if (bluetoothClass != null) Log.v(TAG, "Class: " + bluetoothClass.toString());
Log.v(TAG, "UUID:");
for (int i = 0; i < uuids.length; i++) {
Log.v(TAG, " " + uuids[i]);
}
if (bluetoothClass != null) Log.v(TAG, "Class: " + bluetoothClass.toString());
Log.v(TAG, "UUID:");
for (int i = 0; i < uuids.length; i++) {
Log.v(TAG, " " + uuids[i]);
}
}
return true;

View File

@@ -26,13 +26,13 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.ParcelUuid;
import android.util.Config;
import android.util.Log;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
// TODO: have some notion of shutting down. Maybe a minute after they leave BT settings?
/**
@@ -48,7 +48,6 @@ public class LocalBluetoothManager {
/** Singleton instance. */
private static LocalBluetoothManager sInstance;
private boolean mInitialized;
private Context mContext;
/** If a BT-related activity is in the foreground, this will be it. */
@@ -89,22 +88,17 @@ public class LocalBluetoothManager {
synchronized (LocalBluetoothManager.class) {
if (sInstance == null) {
sInstance = new LocalBluetoothManager();
if (!sInstance.init(context)) {
return null;
}
LocalBluetoothProfileManager.init(sInstance);
}
if (!sInstance.init(context)) {
return null;
}
LocalBluetoothProfileManager.init(sInstance);
return sInstance;
}
}
private boolean init(Context context) {
if (mInitialized) return true;
mInitialized = true;
// This will be around as long as this process is
mContext = context.getApplicationContext();
@@ -226,6 +220,12 @@ public class LocalBluetoothManager {
void setBluetoothStateInt(int state) {
mState = state;
if (state == BluetoothAdapter.STATE_ON) {
ParcelUuid[] uuids = mAdapter.getUuids();
LocalBluetoothProfileManager.updateLocalProfiles(getInstance(mContext), uuids);
}
if (state == BluetoothAdapter.STATE_ON ||
state == BluetoothAdapter.STATE_OFF) {
mCachedDeviceManager.onBluetoothStateChanged(state ==

View File

@@ -121,6 +121,30 @@ public abstract class LocalBluetoothProfileManager {
}
}
// TODO(): Combine the init and updateLocalProfiles codes.
// init can get called from various paths, it makes no sense to add and then delete.
public static void updateLocalProfiles(LocalBluetoothManager localManager, ParcelUuid[] uuids) {
if (!BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS)) {
sProfileMap.remove(Profile.HEADSET);
}
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS)) {
sProfileMap.remove(Profile.A2DP);
}
if (BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS)) {
sProfileMap.remove(Profile.OPP);
}
if (BluetoothUuid.containsAnyUuid(uuids, HID_PROFILE_UUIDS)) {
sProfileMap.remove(Profile.HID);
}
if (BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) {
sProfileMap.remove(Profile.PAN);
}
}
private static LinkedList<ServiceListener> mServiceListeners =
new LinkedList<ServiceListener>();
@@ -171,23 +195,28 @@ public abstract class LocalBluetoothProfileManager {
return;
}
if (BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS)) {
if (BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.HEADSET)) {
profiles.add(Profile.HEADSET);
}
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS)) {
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.A2DP)) {
profiles.add(Profile.A2DP);
}
if (BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS)) {
if (BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.OPP)) {
profiles.add(Profile.OPP);
}
if (BluetoothUuid.containsAnyUuid(uuids, HID_PROFILE_UUIDS)) {
if (BluetoothUuid.containsAnyUuid(uuids, HID_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.HID)) {
profiles.add(Profile.HID);
}
if (BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) {
if (BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS) &&
sProfileMap.containsKey(Profile.PAN)) {
profiles.add(Profile.PAN);
}
}

View File

@@ -225,7 +225,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
} else if (KEY_INPUT_METHOD.equals(preference.getKey())) {
final InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showInputMethodSubtypePicker();
imm.showInputMethodPicker();
} else if (preference.getIntent() == null) {
PreferenceScreen pref = (PreferenceScreen) preference;
String activityName = pref.getKey();

View File

@@ -35,33 +35,6 @@ class AccessPoint extends Preference {
private static final int[] STATE_SECURED = {R.attr.state_encrypted};
private static final int[] STATE_NONE = {};
public static final class Comparater
implements Comparator<AccessPoint> {
@Override
public int compare(AccessPoint accessPoint1, AccessPoint accessPoint2) {
// Active one goes first.
if (accessPoint1.mInfo != accessPoint2.mInfo) {
return (accessPoint1.mInfo != null) ? -1 : 1;
}
// Reachable one goes before unreachable one.
if ((accessPoint1.mRssi ^ accessPoint2.mRssi) < 0) {
return (accessPoint1.mRssi != Integer.MAX_VALUE) ? -1 : 1;
}
// Configured one goes before unconfigured one.
if ((accessPoint1.networkId ^ accessPoint2.networkId) < 0) {
return (accessPoint1.networkId != -1) ? -1 : 1;
}
// Sort by signal strength.
int difference = WifiManager.compareSignalLevel(
accessPoint2.mRssi, accessPoint1.mRssi);
if (difference != 0) {
return difference;
}
// Sort by ssid.
return accessPoint1.ssid.compareToIgnoreCase(accessPoint2.ssid);
}
}
static final int SECURITY_NONE = 0;
static final int SECURITY_WEP = 1;
@@ -140,6 +113,33 @@ class AccessPoint extends Preference {
super.onBindView(view);
}
@Override
public int compareTo(Preference preference) {
if (!(preference instanceof AccessPoint)) {
return 1;
}
AccessPoint other = (AccessPoint) preference;
// Active one goes first.
if (mInfo != other.mInfo) {
return (mInfo != null) ? -1 : 1;
}
// Reachable one goes before unreachable one.
if ((mRssi ^ other.mRssi) < 0) {
return (mRssi != Integer.MAX_VALUE) ? -1 : 1;
}
// Configured one goes before unconfigured one.
if ((networkId ^ other.networkId) < 0) {
return (networkId != -1) ? -1 : 1;
}
// Sort by signal strength.
int difference = WifiManager.compareSignalLevel(other.mRssi, mRssi);
if (difference != 0) {
return difference;
}
// Sort by ssid.
return ssid.compareToIgnoreCase(other.ssid);
}
boolean update(ScanResult result) {
// We do not call refresh() since this is called before onBindView().

View File

@@ -56,9 +56,10 @@ import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* This currently provides three types of UI.
@@ -95,6 +96,8 @@ public class WifiSettings extends SettingsPreferenceFragment
private DetailedState mLastState;
private WifiInfo mLastInfo;
private AtomicBoolean mConnected = new AtomicBoolean(false);
private int mKeyStoreNetworkId = INVALID_NETWORK_ID;
private WifiDialog mDialog;
@@ -184,7 +187,7 @@ public class WifiSettings extends SettingsPreferenceFragment
final ProgressCategoryBase preference =
(ProgressCategoryBase) findPreference("access_points");
mAccessPoints = preference;
mAccessPoints.setOrderingAsAdded(true);
mAccessPoints.setOrderingAsAdded(false);
mAddNetwork = findPreference("add_network");
registerForContextMenu(getListView());
@@ -379,8 +382,7 @@ public class WifiSettings extends SettingsPreferenceFragment
}
private Collection<AccessPoint> constructAccessPoints() {
Collection<AccessPoint> accessPoints =
new TreeSet<AccessPoint>(new AccessPoint.Comparater());
Collection<AccessPoint> accessPoints = new ArrayList<AccessPoint>();
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
if (configs != null) {
@@ -424,11 +426,20 @@ public class WifiSettings extends SettingsPreferenceFragment
WifiManager.SUPPLICANT_CONFIG_CHANGED_ACTION.equals(action)) {
updateAccessPoints();
} else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
updateConnectionState(WifiInfo.getDetailedStateOf((SupplicantState)
intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
//Ignore supplicant state changes when network is connected
//TODO: we should deprecate SUPPLICANT_STATE_CHANGED_ACTION and
//introduce a broadcast that combines the supplicant and network
//network state change events so the apps dont have to worry about
//ignoring supplicant state change when network is connected
//to get more fine grained information.
if (!mConnected.get()) {
updateConnectionState(WifiInfo.getDetailedStateOf((SupplicantState)
intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
}
} else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO);
mConnected.set(info.isConnected());
changeNextButtonState(info.isConnected());
updateConnectionState(info.getDetailedState());
} else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {