Dynamically return the uri of WifiSlice.
WifiSlice is used by both ContextualWifiSlice and WifiSlice itself. In contextual homepage, we provide contextual_wifi slice for the homepage. So in our slice pre-check, contextual_wifi slice will gets pinned and bound. But when it comes to the state where wifi is on but not connected, it actually returns wifi slice instead of contextual_wifi slice, which will hit slice not pinned exception as wifi slice never gets pinned. Thus, we have to dynamically return the corresponding uri to avoid this. Fixes: 124627340 Test: robotests Change-Id: I54ba255871628bb8eb814442f990a5d1149461e0
This commit is contained in:
@@ -93,8 +93,7 @@ public class WifiSlice implements CustomSliceable {
|
|||||||
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
|
final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
|
||||||
null /* actionTitle */, isWifiEnabled);
|
null /* actionTitle */, isWifiEnabled);
|
||||||
|
|
||||||
final ListBuilder listBuilder = new ListBuilder(mContext, WIFI_SLICE_URI,
|
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
|
||||||
ListBuilder.INFINITY)
|
|
||||||
.setAccentColor(color)
|
.setAccentColor(color)
|
||||||
.addRow(new ListBuilder.RowBuilder()
|
.addRow(new ListBuilder.RowBuilder()
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
|
@@ -35,6 +35,7 @@ import androidx.slice.core.SliceAction;
|
|||||||
import androidx.slice.widget.SliceLiveData;
|
import androidx.slice.widget.SliceLiveData;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -97,4 +98,13 @@ public class ContextualWifiSliceTest {
|
|||||||
R.drawable.ic_settings_wireless);
|
R.drawable.ic_settings_wireless);
|
||||||
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
|
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiSlice_contextualWifiSlice_shouldReturnContextualWifiSliceUri() {
|
||||||
|
mWifiSlice.mPreviouslyDisplayed = true;
|
||||||
|
|
||||||
|
final Slice wifiSlice = mWifiSlice.getSlice();
|
||||||
|
|
||||||
|
assertThat(wifiSlice.getUri()).isEqualTo(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user