Update Slice APIs to current versions

Change-Id: Icf40673e518534487be77f33427df937717735e5
Fixes: 77982356
Test: robotests
This commit is contained in:
Matthew Fritze
2018-04-12 16:53:41 -07:00
parent 0468f68c02
commit f9f72e8c2c
3 changed files with 46 additions and 38 deletions

View File

@@ -59,10 +59,11 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
switch (action) {
case ACTION_TOGGLE_CHANGED:
handleToggleAction(context, key, isPlatformSlice);
final boolean isChecked = intent.getBooleanExtra(Slice.EXTRA_TOGGLE_STATE, false);
handleToggleAction(context, key, isChecked, isPlatformSlice);
break;
case ACTION_SLIDER_CHANGED:
int newPosition = intent.getIntExtra(Slice.EXTRA_RANGE_VALUE, -1);
final int newPosition = intent.getIntExtra(Slice.EXTRA_RANGE_VALUE, -1);
handleSliderAction(context, key, newPosition, isPlatformSlice);
break;
case ACTION_WIFI_CHANGED:
@@ -81,7 +82,8 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
}
}
private void handleToggleAction(Context context, String key, boolean isPlatformSlice) {
private void handleToggleAction(Context context, String key, boolean isChecked,
boolean isPlatformSlice) {
if (TextUtils.isEmpty(key)) {
throw new IllegalStateException("No key passed to Intent for toggle controller");
}
@@ -101,10 +103,8 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
// TODO post context.getContentResolver().notifyChanged(uri, null) in the Toggle controller
// so that it's automatically broadcast to any slice.
final TogglePreferenceController toggleController = (TogglePreferenceController) controller;
final boolean currentValue = toggleController.isChecked();
final boolean newValue = !currentValue;
toggleController.setChecked(newValue);
logSliceValueChange(context, key, newValue ? 1 : 0);
toggleController.setChecked(isChecked);
logSliceValueChange(context, key, isChecked ? 1 : 0);
updateUri(context, key, isPlatformSlice);
}