Fix runtime exception when cachedDevice is null

Finish the activity after call super.onAttach().

Bug: 143187915
Test: make -j42 RunSettingsRoboTests
Change-Id: I8f205ef60797bd9eb96617d413f554613008f65b
This commit is contained in:
hughchen
2019-10-24 14:36:37 +08:00
parent e7f5837319
commit d368c21832
2 changed files with 5 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Bundle;
import android.provider.DeviceConfig;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -107,12 +108,13 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
mManager = getLocalBluetoothManager(context);
mCachedDevice = getCachedDevice(mDeviceAddress);
super.onAttach(context);
if (mCachedDevice == null) {
// Close this page if device is null with invalid device mac address
Log.w(TAG, "onAttach() CachedDevice is null!");
finish();
return;
}
super.onAttach(context);
use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(