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

Commit 68270b21 authored by Evan Laird's avatar Evan Laird
Browse files

[Decor] Remove unused properties and Tunable

Before adding support for runtime debugging, we can remove the `Tunable`
implementation from ScreenDecorations, as well as the unused fields
declared.

Tunable was added to the screen decor when the assumption was that a
single path was suitable for all rounded corners. Therefore, the only
supported tuning was `SIZE`, which simply changes the size of the
rounded corners. With the proposed changes, this tuning size is no
longer relevant. The CLI that will be implemented can handle arbitrary
paths, viewport sizes, and colors, and does not require registering
entries with the TunerService.

Test: ScreenDecorationsTest
Test: RoundedCornerResDelegateTest
Bug: 285941724
Change-Id: If9f3e28c641590c04d19315970359bed04521bc6
parent a05a2b4c
Loading
Loading
Loading
Loading
+1 −49
Original line number Diff line number Diff line
@@ -84,8 +84,6 @@ import com.android.systemui.qs.SettingObserver;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.ThreadFactory;
import com.android.systemui.util.settings.SecureSettings;
@@ -105,18 +103,15 @@ import javax.inject.Inject;
 * for antialiasing and emulation purposes.
 */
@SysUISingleton
public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
public class ScreenDecorations implements CoreStartable, Dumpable {
    private static final boolean DEBUG = false;
    private static final String TAG = "ScreenDecorations";

    public static final String SIZE = "sysui_rounded_size";
    public static final String PADDING = "sysui_rounded_content_padding";
    // Provide a way for factory to disable ScreenDecorations to run the Display tests.
    private static final boolean DEBUG_DISABLE_SCREEN_DECORATIONS =
            SystemProperties.getBoolean("debug.disable_screen_decorations", false);
    private static final boolean DEBUG_SCREENSHOT_ROUNDED_CORNERS =
            SystemProperties.getBoolean("debug.screenshot_rounded_corners", false);
    private static final boolean VERBOSE = false;
    static final boolean DEBUG_COLOR = DEBUG_SCREENSHOT_ROUNDED_CORNERS;

    private static final int[] DISPLAY_CUTOUT_IDS = {
@@ -134,7 +129,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
    protected boolean mIsRegistered;
    private final Context mContext;
    private final Executor mMainExecutor;
    private final TunerService mTunerService;
    private final SecureSettings mSecureSettings;
    @VisibleForTesting
    DisplayTracker.Callback mDisplayListener;
@@ -315,7 +309,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
    public ScreenDecorations(Context context,
            @Main Executor mainExecutor,
            SecureSettings secureSettings,
            TunerService tunerService,
            UserTracker userTracker,
            DisplayTracker displayTracker,
            PrivacyDotViewController dotViewController,
@@ -327,7 +320,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
        mContext = context;
        mMainExecutor = mainExecutor;
        mSecureSettings = secureSettings;
        mTunerService = tunerService;
        mUserTracker = userTracker;
        mDisplayTracker = displayTracker;
        mDotViewController = dotViewController;
@@ -608,12 +600,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
                return;
            }

            mMainExecutor.execute(() -> {
                Trace.beginSection("ScreenDecorations#addTunable");
                mTunerService.addTunable(this, SIZE);
                Trace.endSection();
            });

            // Watch color inversion and invert the overlay as needed.
            if (mColorInversionSetting == null) {
                mColorInversionSetting = new SettingObserver(mSecureSettings, mHandler,
@@ -632,12 +618,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
            mUserTracker.addCallback(mUserChangedCallback, mExecutor);
            mIsRegistered = true;
        } else {
            mMainExecutor.execute(() -> {
                Trace.beginSection("ScreenDecorations#removeTunable");
                mTunerService.removeTunable(this);
                Trace.endSection();
            });

            if (mColorInversionSetting != null) {
                mColorInversionSetting.setListening(false);
            }
@@ -1170,34 +1150,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
        Trace.endSection();
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        if (DEBUG_DISABLE_SCREEN_DECORATIONS) {
            Log.i(TAG, "ScreenDecorations is disabled");
            return;
        }
        mExecutor.execute(() -> {
            if (mOverlays == null || !SIZE.equals(key)) {
                return;
            }
            Trace.beginSection("ScreenDecorations#onTuningChanged");
            try {
                final int sizeFactor = Integer.parseInt(newValue);
                mRoundedCornerResDelegate.setTuningSizeFactor(sizeFactor);
            } catch (NumberFormatException e) {
                mRoundedCornerResDelegate.setTuningSizeFactor(null);
            }
            updateOverlayProviderViews(new Integer[] {
                    R.id.rounded_corner_top_left,
                    R.id.rounded_corner_top_right,
                    R.id.rounded_corner_bottom_left,
                    R.id.rounded_corner_bottom_right
            });
            updateHwLayerRoundedCornerExistAndSize();
            Trace.endSection();
        });
    }

    private void updateHwLayerRoundedCornerDrawable() {
        if (mScreenDecorHwcLayer == null) {
            return;
+0 −22
Original line number Diff line number Diff line
@@ -55,15 +55,6 @@ class RoundedCornerResDelegate(
    var bottomRoundedSize = Size(0, 0)
        private set

    var tuningSizeFactor: Int? = null
        set(value) {
            if (field == value) {
                return
            }
            field = value
            reloadMeasures()
        }

    var physicalPixelDisplaySizeRatio: Float = 1f
        set(value) {
            if (field == value) {
@@ -122,19 +113,6 @@ class RoundedCornerResDelegate(
            bottomRoundedSize = Size(it.intrinsicWidth, it.intrinsicHeight)
        }

        tuningSizeFactor?.let {
            if (it <= 0) {
                return
            }
            val length: Int = (it * density).toInt()
            if (topRoundedSize.width > 0) {
                topRoundedSize = Size(length, length)
            }
            if (bottomRoundedSize.width > 0) {
                bottomRoundedSize = Size(length, length)
            }
        }

        if (physicalPixelDisplaySizeRatio != 1f) {
            if (topRoundedSize.width != 0) {
                topRoundedSize = Size(
+2 −36
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -96,7 +95,6 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.settings.FakeDisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.FakeThreadFactory;
import com.android.systemui.util.settings.FakeSettings;
@@ -139,8 +137,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
    @Mock
    private Display mDisplay;
    @Mock
    private TunerService mTunerService;
    @Mock
    private UserTracker mUserTracker;
    @Mock
    private PrivacyDotViewController mDotViewController;
@@ -234,7 +230,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer"))));

        mScreenDecorations = spy(new ScreenDecorations(mContext, mExecutor, mSecureSettings,
                mTunerService, mUserTracker, mDisplayTracker, mDotViewController, mThreadFactory,
                mUserTracker, mDisplayTracker, mDotViewController, mThreadFactory,
                mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory,
                new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer")),
                mAuthController) {
@@ -250,12 +246,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
                mExecutor.runAllReady();
            }

            @Override
            public void onTuningChanged(String key, String newValue) {
                super.onTuningChanged(key, newValue);
                mExecutor.runAllReady();
            }

            @Override
            protected void updateOverlayWindowVisibilityIfViewExists(@Nullable View view) {
                super.updateOverlayWindowVisibilityIfViewExists(view);
@@ -270,7 +260,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        mScreenDecorations.mDisplayInfo = mDisplayInfo;
        doReturn(1f).when(mScreenDecorations).getPhysicalPixelDisplaySizeRatio();
        doNothing().when(mScreenDecorations).updateOverlayProviderViews(any());
        reset(mTunerService);

        try {
            mPrivacyDotShowingListener = mScreenDecorations.mPrivacyDotShowingListener.getClass()
@@ -464,8 +453,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        mScreenDecorations.start();
        // No views added.
        verifyOverlaysExistAndAdded(false, false, false, false, null);
        // No Tuners tuned.
        verify(mTunerService, never()).addTunable(any(), any());
        // No dot controller init
        verify(mDotViewController, never()).initialize(any(), any(), any(), any());
    }
@@ -497,8 +484,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        // Face scanning doesn't exist
        verifyFaceScanningViewExists(false);

        // One tunable.
        verify(mTunerService, times(1)).addTunable(any(), any());
        // Dot controller init
        verify(mDotViewController, times(1)).initialize(
                isA(View.class), isA(View.class), isA(View.class), isA(View.class));
@@ -528,8 +513,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        // Face scanning doesn't exist
        verifyFaceScanningViewExists(false);

        // One tunable.
        verify(mTunerService, times(1)).addTunable(any(), any());
        // No dot controller init
        verify(mDotViewController, never()).initialize(any(), any(), any(), any());
    }
@@ -560,8 +543,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        // Face scanning doesn't exist
        verifyFaceScanningViewExists(false);

        // One tunable.
        verify(mTunerService, times(1)).addTunable(any(), any());
        // Dot controller init
        verify(mDotViewController, times(1)).initialize(
                isA(View.class), isA(View.class), isA(View.class), isA(View.class));
@@ -1076,15 +1057,10 @@ public class ScreenDecorationsTest extends SysuiTestCase {
    public void testRegistration_From_NoOverlay_To_HasOverlays() {
        doReturn(false).when(mScreenDecorations).hasOverlays();
        mScreenDecorations.start();
        verify(mTunerService, times(0)).addTunable(any(), any());
        verify(mTunerService, times(1)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(false));
        reset(mTunerService);

        doReturn(true).when(mScreenDecorations).hasOverlays();
        mScreenDecorations.onConfigurationChanged(new Configuration());
        verify(mTunerService, times(1)).addTunable(any(), any());
        verify(mTunerService, times(0)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(true));
    }

@@ -1093,14 +1069,9 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        doReturn(true).when(mScreenDecorations).hasOverlays();

        mScreenDecorations.start();
        verify(mTunerService, times(1)).addTunable(any(), any());
        verify(mTunerService, times(0)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(true));
        reset(mTunerService);

        mScreenDecorations.onConfigurationChanged(new Configuration());
        verify(mTunerService, times(0)).addTunable(any(), any());
        verify(mTunerService, times(0)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(true));
    }

@@ -1109,15 +1080,10 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        doReturn(true).when(mScreenDecorations).hasOverlays();

        mScreenDecorations.start();
        verify(mTunerService, times(1)).addTunable(any(), any());
        verify(mTunerService, times(0)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(true));
        reset(mTunerService);

        doReturn(false).when(mScreenDecorations).hasOverlays();
        mScreenDecorations.onConfigurationChanged(new Configuration());
        verify(mTunerService, times(0)).addTunable(any(), any());
        verify(mTunerService, times(1)).removeTunable(any());
        assertThat(mScreenDecorations.mIsRegistered, is(false));
    }

@@ -1181,7 +1147,7 @@ public class ScreenDecorationsTest extends SysuiTestCase {
        when(mFaceScanningProviderFactory.getProviders()).thenReturn(mFaceScanningProviders);
        when(mFaceScanningProviderFactory.getHasProviders()).thenReturn(true);
        ScreenDecorations screenDecorations = new ScreenDecorations(mContext, mExecutor,
                mSecureSettings, mTunerService, mUserTracker, mDisplayTracker, mDotViewController,
                mSecureSettings, mUserTracker, mDisplayTracker, mDotViewController,
                mThreadFactory, mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory,
                new ScreenDecorationsLogger(logcatLogBuffer("TestLogBuffer")), mAuthController);
        screenDecorations.start();
+0 −21
Original line number Diff line number Diff line
@@ -108,27 +108,6 @@ class RoundedCornerResDelegateTest : SysuiTestCase() {
        assertEquals(Size(8, 8), roundedCornerResDelegate.bottomRoundedSize)
    }

    @Test
    fun testUpdateTuningSizeFactor() {
        setupResources(radius = 100,
                roundedTopDrawable = getTestsDrawable(R.drawable.rounded3px),
                roundedBottomDrawable = getTestsDrawable(R.drawable.rounded4px))

        roundedCornerResDelegate = RoundedCornerResDelegate(mContext.resources, null)

        val factor = 5
        roundedCornerResDelegate.tuningSizeFactor = factor
        val length = (factor * mContext.resources.displayMetrics.density).toInt()

        assertEquals(Size(length, length), roundedCornerResDelegate.topRoundedSize)
        assertEquals(Size(length, length), roundedCornerResDelegate.bottomRoundedSize)

        roundedCornerResDelegate.tuningSizeFactor = null

        assertEquals(Size(3, 3), roundedCornerResDelegate.topRoundedSize)
        assertEquals(Size(4, 4), roundedCornerResDelegate.bottomRoundedSize)
    }

    @Test
    fun testPhysicalPixelDisplaySizeChanged() {
        setupResources(