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

Commit 56c3b76f authored by kwaky's avatar kwaky Committed by Heemin Seog
Browse files

Make SystemUI crash with warning if SystemBarConfigs is incompatible with...

Make SystemUI crash with warning if SystemBarConfigs is incompatible with NotificationPanelViewMediator.

Bug: 162599873
Bug: 165806308
Test: Manual
Change-Id: I855c03d11e31cf722609f2bb0b0cb6c01624b0c0
Merged-In: I855c03d11e31cf722609f2bb0b0cb6c01624b0c0
parent 51be8f8d
Loading
Loading
Loading
Loading
+32 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ import android.view.WindowManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.car.notification.BottomNotificationPanelViewMediator;
import com.android.systemui.car.notification.TopNotificationPanelViewMediator;
import com.android.systemui.dagger.qualifiers.Main;

import java.lang.annotation.ElementType;
@@ -95,6 +97,7 @@ public class SystemBarConfigs {
        populateMaps();
        readConfigs();
        checkEnabledBarsHaveUniqueBarTypes();
        checkSystemBarEnabledForNotificationPanel();
        setInsetPaddingsForOverlappingCorners();
        sortSystemBarSidesByZOrder();
    }
@@ -221,6 +224,34 @@ public class SystemBarConfigs {
        }
    }

    private void checkSystemBarEnabledForNotificationPanel() throws RuntimeException {

        String notificationPanelMediatorName =
                mResources.getString(R.string.config_notificationPanelViewMediator);
        if (notificationPanelMediatorName == null) {
            return;
        }

        Class<?> notificationPanelMediatorUsed = null;
        try {
            notificationPanelMediatorUsed = Class.forName(notificationPanelMediatorName);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        if (!mTopNavBarEnabled && notificationPanelMediatorUsed.isAssignableFrom(
                TopNotificationPanelViewMediator.class)) {
            throw new RuntimeException(
                    "Top System Bar must be enabled to use " + notificationPanelMediatorName);
        }

        if (!mBottomNavBarEnabled && notificationPanelMediatorUsed.isAssignableFrom(
                BottomNotificationPanelViewMediator.class)) {
            throw new RuntimeException("Bottom System Bar must be enabled to use "
                    + notificationPanelMediatorName);
        }
    }

    private void setInsetPaddingsForOverlappingCorners() {
        setInsetPaddingForOverlappingCorner(TOP, LEFT);
        setInsetPaddingForOverlappingCorner(TOP, RIGHT);