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

Commit f39ce10e authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Update views when next slice is null

Otherwise invalid content would be presented after switching users

Test: manual, switch users, look at smart clock
Test: atest tests/src/com/android/keyguard/KeyguardSliceViewTest.java
Change-Id: Id3bd5e9cfedd17870d00f7a55386661f5b22ff59
Fixes: 78891765
parent 9f88bbc0
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -145,17 +145,13 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
    }

    private void showSlice() {
        if (mPulsing) {
        if (mPulsing || mSlice == null) {
            mTitle.setVisibility(GONE);
            mRow.setVisibility(GONE);
            mContentChangeListener.accept(getLayoutTransition() != null);
            return;
        }

        if (mSlice == null) {
            return;
        }

        ListContent lc = new ListContent(getContext(), mSlice);
        mHasHeader = lc.hasHeader();
        List<SliceItem> subItems = lc.getRowItems();
+16 −6
Original line number Diff line number Diff line
@@ -21,9 +21,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.keyguard.KeyguardSliceProvider;
@@ -35,6 +32,7 @@ import org.junit.runner.RunWith;

import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;

import androidx.slice.SliceProvider;
import androidx.slice.SliceSpecs;
@@ -58,12 +56,24 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
    @Test
    public void showSlice_notifiesListener() {
        ListBuilder builder = new ListBuilder(getContext(), mSliceUri);
        boolean[] notified = {false};
        AtomicBoolean notified = new AtomicBoolean();
        mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
            notified[0] = true;
            notified.set(true);
        });
        mKeyguardSliceView.onChanged(builder.build());
        Assert.assertTrue("Listener should be notified about slice changes.", notified[0]);
        Assert.assertTrue("Listener should be notified about slice changes.",
                notified.get());
    }

    @Test
    public void showSlice_emptySliceNotifiesListener() {
        AtomicBoolean notified = new AtomicBoolean();
        mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
            notified.set(true);
        });
        mKeyguardSliceView.onChanged(null);
        Assert.assertTrue("Listener should be notified about slice changes.",
                notified.get());
    }

    @Test