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:
@@ -118,7 +118,6 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
|||||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mLocalBluetoothManager.setForegroundActivity(mContext);
|
|
||||||
mProfileManager = mLocalBluetoothManager.getProfileManager();
|
mProfileManager = mLocalBluetoothManager.getProfileManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,11 +170,13 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
|
mLocalBluetoothManager.setForegroundActivity(mContext);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
|
mLocalBluetoothManager.setForegroundActivity(null);
|
||||||
unregister();
|
unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -230,6 +230,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
|
|||||||
verify(mLocalBluetoothManager.getEventManager()).registerCallback(
|
verify(mLocalBluetoothManager.getEventManager()).registerCallback(
|
||||||
any(BluetoothCallback.class));
|
any(BluetoothCallback.class));
|
||||||
verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
|
verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
|
||||||
|
verify(mLocalBluetoothManager).setForegroundActivity(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -240,6 +241,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
|
|||||||
verify(mLocalBluetoothManager.getEventManager()).unregisterCallback(
|
verify(mLocalBluetoothManager.getEventManager()).unregisterCallback(
|
||||||
any(BluetoothCallback.class));
|
any(BluetoothCallback.class));
|
||||||
verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
|
verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
|
||||||
|
verify(mLocalBluetoothManager).setForegroundActivity(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user