Merge "[VpnSettings]Crash when activity has been recycled"
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index eebf47d..b8f7c84 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -202,6 +202,13 @@
android:summary="@string/bluetooth_disable_absolute_volume_summary"/>
<ListPreference
+ android:key="bluetooth_select_avrcp_version"
+ android:title="@string/bluetooth_select_avrcp_version_string"
+ android:dialogTitle="@string/bluetooth_select_avrcp_version_dialog_title"
+ android:entries="@array/bluetooth_avrcp_versions"
+ android:entryValues="@array/bluetooth_avrcp_version_values" />
+
+ <ListPreference
android:key="bluetooth_select_a2dp_codec"
android:title="@string/bluetooth_select_a2dp_codec_type"
android:dialogTitle="@string/bluetooth_select_a2dp_codec_type_dialog_title"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index c96ca61..5958f7b 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -199,7 +199,10 @@
"bluetooth_disable_absolute_volume";
private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
"persist.bluetooth.disableabsvol";
+ private static final String BLUETOOTH_AVRCP_VERSION_PROPERTY =
+ "persist.bluetooth.avrcpversion";
+ private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY = "bluetooth_select_avrcp_version";
private static final String BLUETOOTH_SELECT_A2DP_CODEC_KEY = "bluetooth_select_a2dp_codec";
private static final String BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY = "bluetooth_select_a2dp_sample_rate";
private static final String BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY = "bluetooth_select_a2dp_bits_per_sample";
@@ -280,6 +283,7 @@
private BluetoothA2dp mBluetoothA2dp;
private final Object mBluetoothA2dpLock = new Object();
+ private ListPreference mBluetoothSelectAvrcpVersion;
private ListPreference mBluetoothSelectA2dpCodec;
private ListPreference mBluetoothSelectA2dpSampleRate;
private ListPreference mBluetoothSelectA2dpBitsPerSample;
@@ -474,6 +478,7 @@
mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
+ mBluetoothSelectAvrcpVersion = addListPreference(BLUETOOTH_SELECT_AVRCP_VERSION_KEY);
mBluetoothSelectA2dpCodec = addListPreference(BLUETOOTH_SELECT_A2DP_CODEC_KEY);
mBluetoothSelectA2dpSampleRate = addListPreference(BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY);
mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY);
@@ -1781,6 +1786,14 @@
String[] summaries;
int index;
+ // Init the AVRCP Version - Default
+ values = getResources().getStringArray(R.array.bluetooth_avrcp_version_values);
+ summaries = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
+ String value = SystemProperties.get(BLUETOOTH_AVRCP_VERSION_PROPERTY, values[0]);
+ index = mBluetoothSelectAvrcpVersion.findIndexOfValue(value);
+ mBluetoothSelectAvrcpVersion.setValue(values[index]);
+ mBluetoothSelectAvrcpVersion.setSummary(summaries[index]);
+
// Init the Codec Type - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values);
summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
@@ -1817,6 +1830,15 @@
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);
}
+ private void writeBluetoothAvrcpVersion(Object newValue) {
+ SystemProperties.set(BLUETOOTH_AVRCP_VERSION_PROPERTY, newValue.toString());
+ int index = mBluetoothSelectAvrcpVersion.findIndexOfValue(newValue.toString());
+ if (index >= 0) {
+ String[] titles = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
+ mBluetoothSelectAvrcpVersion.setSummary(titles[index]);
+ }
+ }
+
private void updateBluetoothA2dpConfigurationValues() {
int index;
String[] summaries;
@@ -2544,6 +2566,9 @@
toast.show();
}
return false;
+ } else if (preference == mBluetoothSelectAvrcpVersion) {
+ writeBluetoothAvrcpVersion(newValue);
+ return true;
} else if ((preference == mBluetoothSelectA2dpCodec) ||
(preference == mBluetoothSelectA2dpSampleRate) ||
(preference == mBluetoothSelectA2dpBitsPerSample) ||
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index a24a3f0..5dfd283 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -80,6 +80,7 @@
Log.d(TAG, "Dismiss pairing for " + mDevice.getAddress() + " (" + mDevice.getName() + "), Cancelled.");
}
stopForeground(true);
+ stopSelf();
}
};
@@ -89,6 +90,12 @@
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent == null) {
+ Log.e(TAG, "Can't start: null intent!");
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+
Resources res = getResources();
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
@@ -99,6 +106,12 @@
mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (mDevice.getBondState() != BluetoothDevice.BOND_BONDING) {
+ Log.w(TAG, "Device " + mDevice + " not bonding: " + mDevice.getBondState());
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+
String name = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
if (TextUtils.isEmpty(name)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@@ -119,7 +132,7 @@
registerReceiver(mCancelReceiver, filter);
startForeground(NOTIFICATION_ID, builder.getNotification());
- return START_STICKY;
+ return START_REDELIVER_INTENT;
}
@Override
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index fc6b876..e909afd 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -118,13 +118,6 @@
context, deviceAddress, deviceName)) {
context.startActivity(connectionAccessIntent);
} else {
- // Acquire wakelock so that LCD comes up since screen is off
- PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK |
- PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
- "ConnectionAccessActivity");
- wakeLock.setReferenceCounted(false);
- wakeLock.acquire();
-
// Put up a notification that leads to the dialog
// Create an intent triggered by clicking on the
@@ -181,7 +174,6 @@
notificationManager.notify(getNotificationTag(mRequestType), NOTIFICATION_ID,
notification);
- wakeLock.release();
}
} else if (action.equals(BluetoothDevice.ACTION_CONNECTION_ACCESS_CANCEL)) {
// Remove the notification
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 7ac81f5..eda78a9 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -476,7 +476,7 @@
final ConnectivityManager conn = ConnectivityManager.from(context);
final TelephonyManager tele = TelephonyManager.from(context);
- final int slotId = SubscriptionManager.getSlotId(subId);
+ final int slotId = SubscriptionManager.getSlotIndex(subId);
final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY;
boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
diff --git a/src/com/android/settings/datausage/DataUsageMeteredSettings.java b/src/com/android/settings/datausage/DataUsageMeteredSettings.java
index eb43d47..7a397ad 100644
--- a/src/com/android/settings/datausage/DataUsageMeteredSettings.java
+++ b/src/com/android/settings/datausage/DataUsageMeteredSettings.java
@@ -114,7 +114,8 @@
}
private Preference buildWifiPref(Context context, WifiConfiguration config) {
- final String networkId = config.SSID;
+ final String networkId = config.isPasspoint() ?
+ config.providerFriendlyName : config.SSID;
final NetworkTemplate template = NetworkTemplate.buildTemplateWifi(networkId);
final MeteredPreference pref = new MeteredPreference(context, template);
pref.setTitle(removeDoubleQuotes(networkId));
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 9d0d556..aef5416 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -168,6 +168,7 @@
final Activity activity = getActivity();
if (activity != null) {
mProgressHeader = (ProgressBar) setPinnedHeaderView(R.layout.wifi_progress_header);
+ setProgressBarVisible(false);
}
}
@@ -298,6 +299,8 @@
// On/off switch is hidden for Setup Wizard (returns null)
mWifiEnabler = createWifiEnabler();
+
+ mWifiTracker.startTracking();
}
/**
@@ -317,7 +320,6 @@
mWifiEnabler.resume(activity);
}
- mWifiTracker.startTracking();
activity.invalidateOptionsMenu();
}
@@ -327,7 +329,11 @@
if (mWifiEnabler != null) {
mWifiEnabler.pause();
}
+ }
+ @Override
+ public void onStop() {
+ super.onStop();
mWifiTracker.stopTracking();
}
@@ -602,14 +608,19 @@
public void onAccessPointsChanged() {
// Safeguard from some delayed event handling
if (getActivity() == null) return;
+ final int wifiState = mWifiManager.getWifiState();
if (isUiRestricted()) {
if (!isUiRestrictedByOnlyAdmin()) {
- addMessagePreference(R.string.wifi_empty_list_user_restricted);
+ if (WifiManager.WIFI_STATE_DISABLED == wifiState) {
+ addMessagePreference(R.string.wifi_empty_list_wifi_off);
+ }
+ else {
+ addMessagePreference(R.string.wifi_empty_list_user_restricted);
+ }
}
getPreferenceScreen().removeAll();
return;
}
- final int wifiState = mWifiManager.getWifiState();
switch (wifiState) {
case WifiManager.WIFI_STATE_ENABLED:
@@ -702,7 +713,7 @@
private void setOffMessage() {
if (isUiRestricted()) {
if (!isUiRestrictedByOnlyAdmin()) {
- addMessagePreference(R.string.wifi_empty_list_user_restricted);
+ addMessagePreference(R.string.wifi_empty_list_wifi_off);
}
getPreferenceScreen().removeAll();
return;
@@ -758,7 +769,7 @@
protected void setProgressBarVisible(boolean visible) {
if (mProgressHeader != null) {
- mProgressHeader.setVisibility(visible ? View.VISIBLE : View.GONE);
+ mProgressHeader.setVisibility(visible && !isUiRestricted() ? View.VISIBLE : View.GONE);
}
}