Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad004e9b authored by Raff Tsai's avatar Raff Tsai
Browse files

Fix media switch slice doesn't display in panel

Fixes: 140396725
Test: manual
Change-Id: Idf0b766ce5f4316ff90a23faf3083cdee9854562
parent d8a94e75
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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>
+12 −4
Original line number Diff line number Diff line
@@ -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()) {
                    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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
            }