Move bitmap recycle to onDestroy()

If we recycle it in OnStop() and this page isn't destoried,
it will crash when we revisit it.

Fixes: 130185099
Test: RunSettingsRoboTests
Change-Id: I4d3c1c12debcccb1ee7d676a1c5accece0b42e09
This commit is contained in:
Lei Yu
2019-04-08 16:16:20 -07:00
parent 5c28e42538
commit 4350317580
2 changed files with 20 additions and 1 deletions

View File

@@ -209,6 +209,18 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
verify(mBluetoothAdapter, never()).unregisterMetadataListener(mBluetoothDevice);
}
@Test
public void onDestroy_isAvailable_recycleBitmap() {
when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET))
.thenReturn("true");
mController.mIconCache.put(ICON_URI, mBitmap);
mController.onDestroy();
assertThat(mController.mIconCache).isEmpty();
verify(mBitmap).recycle();
}
private void assertBatteryLevel(LinearLayout linearLayout, int batteryLevel) {
final TextView textView = linearLayout.findViewById(R.id.bt_battery_summary);
assertThat(textView.getText().toString()).isEqualTo(