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">
|
<string-array name="config_reset_app_package_name" translatable="false">
|
||||||
<item>com.android.systemui</item>
|
<item>com.android.systemui</item>
|
||||||
</string-array>
|
</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>
|
</resources>
|
||||||
|
@@ -39,9 +39,9 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.slice.Slice;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.slice.Slice;
|
||||||
import androidx.slice.SliceMetadata;
|
import androidx.slice.SliceMetadata;
|
||||||
import androidx.slice.widget.SliceLiveData;
|
import androidx.slice.widget.SliceLiveData;
|
||||||
|
|
||||||
@@ -50,9 +50,11 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
|
import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
import com.google.android.setupdesign.DividerItemDecoration;
|
import com.google.android.setupdesign.DividerItemDecoration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PanelFragment extends Fragment {
|
public class PanelFragment extends Fragment {
|
||||||
@@ -222,8 +224,9 @@ public class PanelFragment extends Fragment {
|
|||||||
/**
|
/**
|
||||||
* Watching for the {@link Slice} to load.
|
* Watching for the {@link Slice} to load.
|
||||||
* <p>
|
* <p>
|
||||||
* If the Slice comes back {@code null} or with the Error attribute, remove the
|
* If the Slice comes back {@code null} or with the Error attribute, if slice
|
||||||
* Slice data from the list, and mark the Slice as loaded.
|
* uri is not in the whitelist, remove the Slice data from the list, otherwise
|
||||||
|
* keep the Slice data.
|
||||||
* <p>
|
* <p>
|
||||||
* If the Slice has come back fully loaded, then mark the Slice as loaded. No
|
* 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.
|
* 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);
|
final SliceMetadata metadata = SliceMetadata.from(getActivity(), slice);
|
||||||
if (slice == null || metadata.isErrorSlice()) {
|
if (slice == null || metadata.isErrorSlice()) {
|
||||||
|
final List<String> whiteList = Arrays.asList(
|
||||||
|
getResources().getStringArray(
|
||||||
|
R.array.config_panel_keep_observe_uri));
|
||||||
|
if (!whiteList.contains(uri.toString())) {
|
||||||
mSliceLiveData.remove(sliceLiveData);
|
mSliceLiveData.remove(sliceLiveData);
|
||||||
|
}
|
||||||
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
||||||
} else if (metadata.getLoadingState() == SliceMetadata.LOADED_ALL) {
|
} else if (metadata.getLoadingState() == SliceMetadata.LOADED_ALL) {
|
||||||
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
mPanelSlicesLoaderCountdownLatch.markSliceLoaded(uri);
|
||||||
|
@@ -117,7 +117,7 @@ public class PanelSlicesAdapter
|
|||||||
|
|
||||||
// Do not show the divider above media devices switcher slice per request
|
// Do not show the divider above media devices switcher slice per request
|
||||||
final Slice slice = sliceLiveData.getValue();
|
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;
|
mDividerAllowedAbove = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user