Fix media switch slice doesn't display in panel
Fixes: 140396725 Test: manual Change-Id: Idf0b766ce5f4316ff90a23faf3083cdee9854562
This commit is contained in:
@@ -422,4 +422,9 @@
|
||||
<string-array name="config_reset_app_package_name" translatable="false">
|
||||
<item>com.android.systemui</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Settings panel keeps observe this uri -->
|
||||
<string-array name="config_panel_keep_observe_uri" translatable="false">
|
||||
<item>content://com.android.settings.slices/intent/media_output_indicator</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
@@ -39,9 +39,9 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceMetadata;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
|
||||
@@ -50,9 +50,11 @@ import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import com.google.android.setupdesign.DividerItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PanelFragment extends Fragment {
|
||||
@@ -222,8 +224,9 @@ public class PanelFragment extends Fragment {
|
||||
/**
|
||||
* Watching for the {@link Slice} to load.
|
||||
* <p>
|
||||
* If the Slice comes back {@code null} or with the Error attribute, remove the
|
||||
* Slice data from the list, and mark the Slice as loaded.
|
||||
* If the Slice comes back {@code null} or with the Error attribute, if slice
|
||||
* uri is not in the whitelist, remove the Slice data from the list, otherwise
|
||||
* keep the Slice data.
|
||||
* <p>
|
||||
* If the Slice has come back fully loaded, then mark the Slice as loaded. No
|
||||
* other actions required since we already have the Slice data in the list.
|
||||
@@ -235,7 +238,12 @@ public class PanelFragment extends Fragment {
|
||||
*/
|
||||
final SliceMetadata metadata = SliceMetadata.from(getActivity(), slice);
|
||||
if (slice == null || metadata.isErrorSlice()) {
|
||||
mSliceLiveData.remove(sliceLiveData);
|
||||
final List<String> whiteList = Arrays.asList(
|
||||
getResources().getStringArray(
|
||||
R.array.config_panel_keep_observe_uri));
|
||||
if (!whiteList.contains(uri.toString())) {
|
||||
mSliceLiveData.remove(sliceLiveData);
|
||||
}
|
||||
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
||||
} else if (metadata.getLoadingState() == SliceMetadata.LOADED_ALL) {
|
||||
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
||||
|
@@ -117,7 +117,7 @@ public class PanelSlicesAdapter
|
||||
|
||||
// Do not show the divider above media devices switcher slice per request
|
||||
final Slice slice = sliceLiveData.getValue();
|
||||
if (slice != null && slice.getUri().equals(MEDIA_OUTPUT_INDICATOR_SLICE_URI)) {
|
||||
if (slice == null || slice.getUri().equals(MEDIA_OUTPUT_INDICATOR_SLICE_URI)) {
|
||||
mDividerAllowedAbove = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user