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

Commit 530b0516 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes I6ed5a493,If180894e into main

* changes:
  Add NotificationRowContentBinderRefactor flag
  Re-enable NotificationContentInflaterTest
parents e0340e86 9d982343
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -32,6 +32,13 @@ flag {
   bug: "340294566"
}

flag {
   name: "notification_row_content_binder_refactor"
   namespace: "systemui"
   description: "Convert the NotificationContentInflater to Kotlin and restructure it to support modern views"
   bug: "343942780"
}

flag {
   name: "notification_minimalism_prototype"
   namespace: "systemui"
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.notification.row.shared

import com.android.systemui.Flags
import com.android.systemui.flags.FlagToken
import com.android.systemui.flags.RefactorFlagUtils

/** Helper for reading or using the notification row content binder refactor flag state. */
@Suppress("NOTHING_TO_INLINE")
object NotificationRowContentBinderRefactor {
    /** The aconfig flag name */
    const val FLAG_NAME = Flags.FLAG_NOTIFICATION_ROW_CONTENT_BINDER_REFACTOR

    /** A token used for dependency declaration */
    val token: FlagToken
        get() = FlagToken(FLAG_NAME, isEnabled)

    /** Is the refactor enabled */
    @JvmStatic
    inline val isEnabled
        get() = Flags.notificationRowContentBinderRefactor()

    /**
     * Called to ensure code is only run when the flag is enabled. This protects users from the
     * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
     * build to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun isUnexpectedlyInLegacyMode() =
        RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)

    /**
     * Called to ensure code is only run when the flag is disabled. This will throw an exception if
     * the flag is enabled to ensure that the refactor author catches issues in testing.
     */
    @JvmStatic
    inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
}
+4 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -50,7 +51,6 @@ import android.widget.TextView;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.filters.Suppress;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.media.controls.util.MediaFeatureFlag;
@@ -81,7 +81,6 @@ import java.util.concurrent.TimeUnit;
@SmallTest
@RunWith(AndroidJUnit4.class)
@RunWithLooper(setAsMainLooper = true)
@Suppress
public class NotificationContentInflaterTest extends SysuiTestCase {

    private NotificationContentInflater mNotificationInflater;
@@ -128,7 +127,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
                TestableLooper.get(this));
        ExpandableNotificationRow row = mHelper.createRow(mBuilder.build());
        mRow = spy(row);
        when(mNotifLayoutInflaterFactoryProvider.provide(any(), any()))
        when(mNotifLayoutInflaterFactoryProvider.provide(any(), anyInt()))
                .thenReturn(mNotifLayoutInflaterFactory);

        mNotificationInflater = new NotificationContentInflater(
@@ -282,6 +281,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
    }

    @Test
    @Ignore
    public void testUsesSameViewWhenCachedPossibleToReuse() throws Exception {
        // GIVEN a cached view.
        RemoteViews contractedRemoteView = mBuilder.createContentView();
@@ -347,6 +347,7 @@ public class NotificationContentInflaterTest extends SysuiTestCase {
    }

    @Test
    @Ignore
    public void testNotificationViewHeightTooSmallFailsValidation() {
        View view = mock(View.class);
        when(view.getHeight())