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

Commit 87231445 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix DeviceProvisioned on PhoneStatusBarPolicy

With the new DeviceProvisionedController, adding the callback does not
immediately call it back. Instead, we need to retrieve the value on
subscription. This was causing the alarm icon not to show in QS headers
(it's blocked in other surfaces using a blocklist).

Keep it disabled (using ignore) for regular headers, but do not ignore
it in the combined headers.

Test: atest PhoneStatusBarPolicyTest QuickStatusBarHeaderControllerTest
Test: atest com.android.systemui.shade
Fixes: 204159738
Change-Id: I2eabfa6c61ed9eea66c9127449250919618a47fd
parent cbe2a51d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
        mPrivacyIconsController.setChipVisibilityListener(this);
        mIconContainer.addIgnoredSlot(
                getResources().getString(com.android.internal.R.string.status_bar_managed_profile));
        mIconContainer.addIgnoredSlot(
                getResources().getString(com.android.internal.R.string.status_bar_alarm_clock));
        mIconContainer.setShouldRestrictIcons(false);
        mStatusBarIconController.addIconGroup(mIconManager);

+8 −0
Original line number Diff line number Diff line
@@ -270,6 +270,14 @@ class LargeScreenShadeHeaderController @Inject constructor(
        qsCarrierGroupController = qsCarrierGroupControllerBuilder
            .setQSCarrierGroup(qsCarrierGroup)
            .build()

        if (!combinedHeaders) {
            // In the new header, we display alarm icon but we ignore it when not using the new
            // headers.
            iconContainer.addIgnoredSlot(
                    context.getString(com.android.internal.R.string.status_bar_alarm_clock)
            )
        }
    }

    override fun onViewAttached() {
+6 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@@ -127,7 +128,7 @@ public class PhoneStatusBarPolicy
    private final DateFormatUtil mDateFormatUtil;
    private final TelecomManager mTelecomManager;

    private final Handler mHandler = new Handler();
    private final Handler mHandler;
    private final CastController mCast;
    private final HotspotController mHotspot;
    private final NextAlarmController mNextAlarmController;
@@ -166,7 +167,7 @@ public class PhoneStatusBarPolicy
    @Inject
    public PhoneStatusBarPolicy(StatusBarIconController iconController,
            CommandQueue commandQueue, BroadcastDispatcher broadcastDispatcher,
            @UiBackground Executor uiBgExecutor, @Main Resources resources,
            @UiBackground Executor uiBgExecutor, @Main Looper looper, @Main Resources resources,
            CastController castController, HotspotController hotspotController,
            BluetoothController bluetoothController, NextAlarmController nextAlarmController,
            UserInfoController userInfoController, RotationLockController rotationLockController,
@@ -185,6 +186,7 @@ public class PhoneStatusBarPolicy
        mIconController = iconController;
        mCommandQueue = commandQueue;
        mBroadcastDispatcher = broadcastDispatcher;
        mHandler = new Handler(looper);
        mResources = resources;
        mCast = castController;
        mHotspot = hotspotController;
@@ -332,6 +334,7 @@ public class PhoneStatusBarPolicy
        mRotationLockController.addCallback(this);
        mBluetooth.addCallback(this);
        mProvisionedController.addCallback(this);
        mCurrentUserSetup = mProvisionedController.isCurrentUserSetup();
        mZenController.addCallback(this);
        mCast.addCallback(mCastCallback);
        mHotspot.addCallback(mHotspotCallback);
@@ -562,6 +565,7 @@ public class PhoneStatusBarPolicy
                    mHandler.post(() -> {
                        updateAlarm();
                        updateManagedProfile();
                        onUserSetupChanged();
                    });
                }
            };
+8 −0
Original line number Diff line number Diff line
@@ -192,6 +192,14 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
        verify(view).setIsSingleCarrier(false)
    }

    @Test
    fun testAlarmIconIgnored() {
        controller.init()

        verify(iconContainer).addIgnoredSlot(
                mContext.getString(com.android.internal.R.string.status_bar_alarm_clock))
    }

    private fun stubViews() {
        `when`(view.findViewById<View>(anyInt())).thenReturn(mockView)
        `when`(view.findViewById<QSCarrierGroup>(R.id.carrier_group)).thenReturn(qsCarrierGroup)
+7 −0
Original line number Diff line number Diff line
@@ -607,6 +607,13 @@ class LargeScreenShadeHeaderControllerCombinedTest : SysuiTestCase() {
        verify(mockConstraintsChanges.largeScreenConstraintsChanges)!!.invoke(any())
    }

    @Test
    fun alarmIconNotIgnored() {
        verify(statusIcons, never()).addIgnoredSlot(
                context.getString(com.android.internal.R.string.status_bar_alarm_clock)
        )
    }

    private fun createWindowInsets(
        topCutout: Rect? = Rect()
    ): WindowInsets {
Loading