Merge "Bluetooth: Fix Resource Leak in OPP (1/2)"
diff --git a/src/com/android/settings/ApnPreference.java b/src/com/android/settings/ApnPreference.java
old mode 100644
new mode 100755
index a6ab8b7..0111b26
--- a/src/com/android/settings/ApnPreference.java
+++ b/src/com/android/settings/ApnPreference.java
@@ -23,6 +23,7 @@
import android.provider.Telephony;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
+import android.telephony.SubscriptionManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -35,6 +36,8 @@
CompoundButton.OnCheckedChangeListener, OnClickListener {
final static String TAG = "ApnPreference";
+ private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
public ApnPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@@ -116,7 +119,9 @@
if (context != null) {
int pos = Integer.parseInt(getKey());
Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
- context.startActivity(new Intent(Intent.ACTION_EDIT, url));
+ Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
+ editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
+ context.startActivity(editIntent);
}
}
}
@@ -128,4 +133,8 @@
public boolean getSelectable() {
return mSelectable;
}
+
+ public void setSubId(int subId) {
+ mSubId = subId;
+ }
}
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index 38a3155..e9e5226 100755
--- a/src/com/android/settings/ApnSettings.java
+++ b/src/com/android/settings/ApnSettings.java
@@ -240,8 +240,9 @@
private void fillList() {
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
- final String mccmnc = mSubscriptionInfo == null ? ""
- : tm.getSimOperator(mSubscriptionInfo.getSubscriptionId());
+ final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId()
+ : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ final String mccmnc = mSubscriptionInfo == null ? "" : tm.getSimOperator(subId);
Log.d(TAG, "mccmnc = " + mccmnc);
StringBuilder where = new StringBuilder("numeric=\"" + mccmnc +
"\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0");
@@ -257,8 +258,8 @@
if (cursor != null) {
IccRecords r = null;
if (mUiccController != null && mSubscriptionInfo != null) {
- r = mUiccController.getIccRecords(SubscriptionManager.getPhoneId(
- mSubscriptionInfo.getSubscriptionId()), UiccController.APP_FAM_3GPP);
+ r = mUiccController.getIccRecords(
+ SubscriptionManager.getPhoneId(subId), UiccController.APP_FAM_3GPP);
}
PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
apnList.removeAll();
@@ -285,6 +286,7 @@
pref.setSummary(apn);
pref.setPersistent(false);
pref.setOnPreferenceChangeListener(this);
+ pref.setSubId(subId);
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 7a5cb3c..6c40051 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -2049,6 +2049,20 @@
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC;
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
break;
+ case 6:
+ synchronized (mBluetoothA2dpLock) {
+ if (mBluetoothA2dp != null) {
+ mBluetoothA2dp.enableOptionalCodecs();
+ }
+ }
+ return;
+ case 7:
+ synchronized (mBluetoothA2dpLock) {
+ if (mBluetoothA2dp != null) {
+ mBluetoothA2dp.disableOptionalCodecs();
+ }
+ }
+ return;
default:
break;
}