Fix the memory leak in TetherSettings
https://code.google.com/p/android/issues/detail?id=210848 We need to close the bluetooth adapter's profile proxy in OnDestroy method, or it will cause TetherSettings object to be held and won't release. And finally it will cause OOM issue. Change-Id: Id7667f751697c8ef9fccaaabfed28a91d4fa4960 Signed-off-by: 宋凯伦 <songkailun@xiaomi.com>
This commit is contained in:
@@ -182,6 +182,16 @@ public class TetherSettings extends SettingsPreferenceFragment
|
|||||||
com.android.internal.R.array.config_mobile_hotspot_provision_app);
|
com.android.internal.R.array.config_mobile_hotspot_provision_app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
BluetoothProfile profile = mBluetoothPan.getAndSet(null);
|
||||||
|
if (profile != null && adapter != null) {
|
||||||
|
adapter.closeProfileProxy(BluetoothProfile.PAN, profile);
|
||||||
|
}
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
savedInstanceState.putInt(TETHER_CHOICE, mTetherChoice);
|
savedInstanceState.putInt(TETHER_CHOICE, mTetherChoice);
|
||||||
|
Reference in New Issue
Block a user