Update SlicePreferenceController

Make sure setSliceUri is invoked even when it is null, where we create
SliceLiveData.

Then in lifecycle, if LiveData is not null, we will register observer.

Bug: 120803703
Test: Manual

Change-Id: I56caf2abf04c4a251ebafa5deb599d44b1c7fe92
This commit is contained in:
jackqdyulei
2019-01-15 20:03:10 -08:00
parent 2b80334b41
commit 511b5fe9f2
2 changed files with 11 additions and 7 deletions

View File

@@ -109,12 +109,14 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
mCachedDevice = getCachedDevice(mDeviceAddress);
super.onAttach(context);
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SLICE_INJECTION)) {
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(context)
.getBluetoothFeatureProvider(context);
use(BlockingSlicePrefController.class).setSliceUri(
featureProvider.getBluetoothDeviceSettingsUri(mDeviceAddress));
}
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
context).getBluetoothFeatureProvider(context);
final boolean injectionEnabled = FeatureFlagUtils.isEnabled(context,
FeatureFlags.SLICE_INJECTION);
use(BlockingSlicePrefController.class).setSliceUri(injectionEnabled
? featureProvider.getBluetoothDeviceSettingsUri(mDeviceAddress)
: null);
}
@Override

View File

@@ -82,6 +82,8 @@ public class SlicePreferenceController extends BasePreferenceController implemen
@Override
public void onChanged(Slice slice) {
if (slice != null) {
mSlicePreference.onSliceUpdated(slice);
}
}
}