Fix context leak in AudioSwitchPreferenceController.

In this controller the context is stored into a global singleton but was
not cleared, thus leaking context and associated views.

Change-Id: I4247f8ff753bc0a331c6c81a0e4b5b4bc41588de
Bug: 80507279
Test: robotests
Test: inspected hprof before/after change
This commit is contained in:
Fan Zhang
2018-06-07 11:51:09 -07:00
parent 60f2f06855
commit d9f7fba943
2 changed files with 4 additions and 1 deletions

View File

@@ -118,7 +118,6 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
Log.e(TAG, "Bluetooth is not supported on this device");
return;
}
mLocalBluetoothManager.setForegroundActivity(mContext);
mProfileManager = mLocalBluetoothManager.getProfileManager();
}
@@ -171,11 +170,13 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
@Override
public void onStart() {
mLocalBluetoothManager.setForegroundActivity(mContext);
register();
}
@Override
public void onStop() {
mLocalBluetoothManager.setForegroundActivity(null);
unregister();
}