Merge branch 'master' into honeycomb-release
This commit is contained in:
@@ -127,7 +127,7 @@ public class WirelessSettings extends SettingsPreferenceFragment {
|
||||
}
|
||||
|
||||
// Remove NFC if its not available
|
||||
if (NfcAdapter.getDefaultAdapter() == null) {
|
||||
if (NfcAdapter.getDefaultAdapter(activity) == null) {
|
||||
getPreferenceScreen().removePreference(nfc);
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ public class BluetoothSettings extends SettingsPreferenceFragment
|
||||
case BluetoothDevicePicker.FILTER_TYPE_AUDIO:
|
||||
if (uuids != null) {
|
||||
if (BluetoothUuid.containsAnyUuid(uuids,
|
||||
LocalBluetoothProfileManager.A2DP_PROFILE_UUIDS)) return true;
|
||||
LocalBluetoothProfileManager.A2DP_SINK_PROFILE_UUIDS)) return true;
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids,
|
||||
LocalBluetoothProfileManager.HEADSET_PROFILE_UUIDS)) return true;
|
||||
|
||||
@@ -589,7 +589,11 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
ParcelUuid[] uuids = mDevice.getUuids();
|
||||
if (uuids == null) return false;
|
||||
|
||||
LocalBluetoothProfileManager.updateProfiles(uuids, mProfiles);
|
||||
BluetoothAdapter adapter = mLocalManager.getBluetoothAdapter();
|
||||
ParcelUuid[] localUuids = adapter.getUuids();
|
||||
if (localUuids == null) return false;
|
||||
|
||||
LocalBluetoothProfileManager.updateProfiles(uuids, localUuids, mProfiles);
|
||||
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "updating profiles for " + mDevice.getName());
|
||||
|
||||
@@ -48,11 +48,15 @@ public abstract class LocalBluetoothProfileManager {
|
||||
BluetoothUuid.Handsfree,
|
||||
};
|
||||
|
||||
/* package */ static final ParcelUuid[] A2DP_PROFILE_UUIDS = new ParcelUuid[] {
|
||||
/* package */ static final ParcelUuid[] A2DP_SINK_PROFILE_UUIDS = new ParcelUuid[] {
|
||||
BluetoothUuid.AudioSink,
|
||||
BluetoothUuid.AdvAudioDist,
|
||||
};
|
||||
|
||||
/* package */ static final ParcelUuid[] A2DP_SRC_PROFILE_UUIDS = new ParcelUuid[] {
|
||||
BluetoothUuid.AudioSource
|
||||
};
|
||||
|
||||
/* package */ static final ParcelUuid[] OPP_PROFILE_UUIDS = new ParcelUuid[] {
|
||||
BluetoothUuid.ObexObjectPush
|
||||
};
|
||||
@@ -124,25 +128,24 @@ 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)) {
|
||||
if (!BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree_AG) &&
|
||||
!BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP_AG)) {
|
||||
sProfileMap.remove(Profile.HEADSET);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS)) {
|
||||
if (!BluetoothUuid.containsAnyUuid(uuids, A2DP_SRC_PROFILE_UUIDS)) {
|
||||
sProfileMap.remove(Profile.A2DP);
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, OPP_PROFILE_UUIDS)) {
|
||||
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)) {
|
||||
if (!BluetoothUuid.containsAnyUuid(uuids, PANU_PROFILE_UUIDS)) {
|
||||
sProfileMap.remove(Profile.PAN);
|
||||
}
|
||||
|
||||
// There is no local SDP record for HID and Settings app doesn't control PBAP
|
||||
}
|
||||
|
||||
private static LinkedList<ServiceListener> mServiceListeners =
|
||||
@@ -186,21 +189,28 @@ public abstract class LocalBluetoothProfileManager {
|
||||
* NOTE: This list happens to define the connection order. We should put this logic in a more
|
||||
* well known place when this method is no longer temporary.
|
||||
* @param uuids of the remote device
|
||||
* @param localUuids UUIDs of the local device
|
||||
* @param profiles The list of profiles to fill
|
||||
*/
|
||||
public static void updateProfiles(ParcelUuid[] uuids, List<Profile> profiles) {
|
||||
public static void updateProfiles(ParcelUuid[] uuids, ParcelUuid[] localUuids,
|
||||
List<Profile> profiles) {
|
||||
profiles.clear();
|
||||
|
||||
if (uuids == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, HEADSET_PROFILE_UUIDS) &&
|
||||
sProfileMap.containsKey(Profile.HEADSET)) {
|
||||
profiles.add(Profile.HEADSET);
|
||||
if (sProfileMap.containsKey(Profile.HEADSET)) {
|
||||
if ((BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.HSP_AG) &&
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HSP)) ||
|
||||
(BluetoothUuid.isUuidPresent(localUuids, BluetoothUuid.Handsfree_AG) &&
|
||||
BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree))) {
|
||||
profiles.add(Profile.HEADSET);
|
||||
}
|
||||
}
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_PROFILE_UUIDS) &&
|
||||
|
||||
if (BluetoothUuid.containsAnyUuid(uuids, A2DP_SINK_PROFILE_UUIDS) &&
|
||||
sProfileMap.containsKey(Profile.A2DP)) {
|
||||
profiles.add(Profile.A2DP);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
|
||||
public NfcEnabler(Context context, CheckBoxPreference checkBoxPreference) {
|
||||
mContext = context;
|
||||
mCheckbox = checkBoxPreference;
|
||||
mNfcAdapter = NfcAdapter.getDefaultAdapter();
|
||||
mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
|
||||
|
||||
if (mNfcAdapter == null) {
|
||||
// NFC is not supported
|
||||
|
||||
@@ -30,6 +30,9 @@ import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.IpAssignment;
|
||||
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
|
||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.net.wifi.WpsConfiguration;
|
||||
import android.net.wifi.WpsConfiguration.Setup;
|
||||
|
||||
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
||||
import android.net.wifi.WifiConfiguration.ProxySettings;
|
||||
import android.net.wifi.WifiInfo;
|
||||
@@ -114,6 +117,10 @@ public class WifiConfigController implements TextWatcher,
|
||||
private TextView mProxyPortView;
|
||||
private TextView mProxyExclusionListView;
|
||||
|
||||
private IpAssignment mIpAssignment;
|
||||
private ProxySettings mProxySettings;
|
||||
private LinkProperties mLinkProperties = new LinkProperties();
|
||||
|
||||
static boolean requireKeyStore(WifiConfiguration config) {
|
||||
if (config == null) {
|
||||
return false;
|
||||
@@ -331,28 +338,37 @@ public class WifiConfigController implements TextWatcher,
|
||||
return null;
|
||||
}
|
||||
|
||||
config.ipAssignment = (mIpSettingsSpinner != null &&
|
||||
validateAndFetchIpAndProxyFields();
|
||||
|
||||
config.proxySettings = mProxySettings;
|
||||
config.ipAssignment = mIpAssignment;
|
||||
config.linkProperties = new LinkProperties(mLinkProperties);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private void validateAndFetchIpAndProxyFields() {
|
||||
mLinkProperties.clear();
|
||||
mIpAssignment = (mIpSettingsSpinner != null &&
|
||||
mIpSettingsSpinner.getSelectedItemPosition() == STATIC_IP) ?
|
||||
IpAssignment.STATIC : IpAssignment.DHCP;
|
||||
|
||||
if (config.ipAssignment == IpAssignment.STATIC) {
|
||||
if (mIpAssignment == IpAssignment.STATIC) {
|
||||
//TODO: A better way to do this is to not dismiss the
|
||||
//dialog as long as one of the fields is invalid
|
||||
LinkProperties linkProperties = new LinkProperties();
|
||||
int result = validateIpConfigFields(linkProperties);
|
||||
if (result == 0) {
|
||||
config.linkProperties = linkProperties;
|
||||
} else {
|
||||
int result = validateIpConfigFields(mLinkProperties);
|
||||
if (result != 0) {
|
||||
mLinkProperties.clear();
|
||||
Toast.makeText(mConfigUi.getContext(), result, Toast.LENGTH_LONG).show();
|
||||
config.ipAssignment = IpAssignment.UNASSIGNED;
|
||||
mIpAssignment = IpAssignment.UNASSIGNED;
|
||||
}
|
||||
}
|
||||
|
||||
config.proxySettings = (mProxySettingsSpinner != null &&
|
||||
mProxySettings = (mProxySettingsSpinner != null &&
|
||||
mProxySettingsSpinner.getSelectedItemPosition() == PROXY_STATIC) ?
|
||||
ProxySettings.STATIC : ProxySettings.NONE;
|
||||
|
||||
if (config.proxySettings == ProxySettings.STATIC) {
|
||||
if (mProxySettings == ProxySettings.STATIC) {
|
||||
String host = mProxyHostView.getText().toString();
|
||||
String portStr = mProxyPortView.getText().toString();
|
||||
String exclusionList = mProxyExclusionListView.getText().toString();
|
||||
@@ -366,14 +382,12 @@ public class WifiConfigController implements TextWatcher,
|
||||
}
|
||||
if (result == 0) {
|
||||
ProxyProperties proxyProperties= new ProxyProperties(host, port, exclusionList);
|
||||
config.linkProperties.setHttpProxy(proxyProperties);
|
||||
mLinkProperties.setHttpProxy(proxyProperties);
|
||||
} else {
|
||||
Toast.makeText(mConfigUi.getContext(), result, Toast.LENGTH_LONG).show();
|
||||
config.proxySettings = ProxySettings.UNASSIGNED;
|
||||
mProxySettings = ProxySettings.UNASSIGNED;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private int validateIpConfigFields(LinkProperties linkProperties) {
|
||||
@@ -428,13 +442,32 @@ public class WifiConfigController implements TextWatcher,
|
||||
return MANUAL;
|
||||
}
|
||||
|
||||
int getWpsPin() {
|
||||
try {
|
||||
String wpsPin = ((TextView) mView.findViewById(R.id.wps_pin)).getText().toString();
|
||||
return Integer.parseInt(wpsPin);
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
WpsConfiguration getWpsConfig() {
|
||||
WpsConfiguration config = new WpsConfiguration();
|
||||
switch (mNetworkSetupSpinner.getSelectedItemPosition()) {
|
||||
case WPS_PBC:
|
||||
config.setup = Setup.PBC;
|
||||
break;
|
||||
case WPS_PIN_FROM_ACCESS_POINT:
|
||||
config.setup = Setup.PIN_FROM_ACCESS_POINT;
|
||||
break;
|
||||
case WPS_PIN_FROM_DEVICE:
|
||||
config.setup = Setup.PIN_FROM_DEVICE;
|
||||
break;
|
||||
default:
|
||||
config.setup = Setup.INVALID;
|
||||
Log.e(TAG, "WPS not selected type");
|
||||
return config;
|
||||
}
|
||||
config.pin = ((TextView) mView.findViewById(R.id.wps_pin)).getText().toString();
|
||||
config.BSSID = (mAccessPoint != null) ? mAccessPoint.bssid : null;
|
||||
|
||||
validateAndFetchIpAndProxyFields();
|
||||
|
||||
config.proxySettings = mProxySettings;
|
||||
config.ipAssignment = mIpAssignment;
|
||||
config.linkProperties = new LinkProperties(mLinkProperties);
|
||||
return config;
|
||||
}
|
||||
|
||||
private void showSecurityFields() {
|
||||
|
||||
@@ -559,14 +559,11 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
/* package */ void submit(WifiConfigController configController) {
|
||||
switch(configController.chosenNetworkSetupMethod()) {
|
||||
case WifiConfigController.WPS_PBC:
|
||||
mWifiManager.startWpsPbc(mSelectedAccessPoint.bssid);
|
||||
break;
|
||||
case WifiConfigController.WPS_PIN_FROM_ACCESS_POINT:
|
||||
int apPin = configController.getWpsPin();
|
||||
mWifiManager.startWpsWithPinFromAccessPoint(mSelectedAccessPoint.bssid, apPin);
|
||||
mWifiManager.startWps(configController.getWpsConfig());
|
||||
break;
|
||||
case WifiConfigController.WPS_PIN_FROM_DEVICE:
|
||||
int pin = mWifiManager.startWpsWithPinFromDevice(mSelectedAccessPoint.bssid);
|
||||
String pin = mWifiManager.startWps(configController.getWpsConfig());
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.wifi_wps_pin_method_configuration)
|
||||
.setMessage(getResources().getString(R.string.wifi_wps_pin_output, pin))
|
||||
|
||||
Reference in New Issue
Block a user