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

Commit e1e623e7 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Log.wtf when expanding a goup that's not attached

This seems like it can happen very rarely, though we're not quite sure
how. It's not really an issue since we can just ignore the expansion, so
it shouldn't crash sysui, but made it a Log.wtf so we can still keep an
eye on it.

Bug: 318317068
Test: GroupExpansionManagerTest
Flag: NONE
Change-Id: I16a3f6ced860fee337ccfc8468738ab7cf7b7fca
parent 7a92cfa3
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@

package com.android.systemui.statusbar.notification.collection.render

import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
import com.android.systemui.log.assertLogsWtf
import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder
import com.android.systemui.statusbar.notification.collection.ListEntry
import com.android.systemui.statusbar.notification.collection.NotifPipeline
@@ -30,7 +32,7 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.withArgCaptor
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertThrows
import org.junit.Assume
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -116,9 +118,9 @@ class GroupExpansionManagerTest : SysuiTestCase() {
        underTest.setGroupExpanded(summary1, false)

        // Expanding again should throw.
        assertThrows(IllegalArgumentException::class.java) {
            underTest.setGroupExpanded(summary1, true)
        }
        // TODO(b/320238410): Remove this check when robolectric supports wtf assertions.
        Assume.assumeFalse(Build.FINGERPRINT.contains("robolectric"))
        assertLogsWtf { underTest.setGroupExpanded(summary1, true) }
    }

    @Test
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.notification.collection.render;

import android.util.Log;

import androidx.annotation.NonNull;

import com.android.systemui.Dumpable;
@@ -40,6 +42,8 @@ import javax.inject.Inject;
 */
@SysUISingleton
public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpable {
    private static final String TAG = "GroupExpansionaManagerImpl";

    private final DumpManager mDumpManager;
    private final GroupMembershipManager mGroupMembershipManager;
    private final Set<OnGroupExpansionChangeListener> mOnGroupChangeListeners = new HashSet<>();
@@ -100,7 +104,7 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
        NotificationEntry groupSummary = mGroupMembershipManager.getGroupSummary(entry);
        if (entry.getParent() == null) {
            if (expanded) {
                throw new IllegalArgumentException("Cannot expand group that is not attached");
                Log.wtf(TAG, "Cannot expand group that is not attached");
            } else {
                // The entry is no longer attached, but we still want to make sure we don't have
                // a stale expansion state.