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

Commit db66abb3 authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Automerger Merge Worker
Browse files

Merge "[Dagger] Move ConfigurationController out of KeyguardStatusBarView and...

Merge "[Dagger] Move ConfigurationController out of KeyguardStatusBarView and into its controller." into sc-v2-dev am: e7b7e88b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15303238

Change-Id: Ic30dadfb14c291f1f6b495c299e29307703a1175
parents c54961d1 e7b7e88b
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
@@ -73,7 +71,6 @@ import java.util.List;
public class KeyguardStatusBarView extends RelativeLayout implements
        BatteryStateChangeCallback,
        OnUserInfoChangedListener,
        ConfigurationListener,
        SystemStatusAnimationCallback {

    private static final int LAYOUT_NONE = 0;
@@ -190,7 +187,7 @@ public class KeyguardStatusBarView extends RelativeLayout implements
        setLayoutParams(lp);
    }

    private void loadDimens() {
    void loadDimens() {
        Resources res = getResources();
        mSystemIconsSwitcherHiddenExpandedMargin = res.getDimensionPixelSize(
                R.dimen.system_icons_switcher_hidden_expanded_margin);
@@ -366,12 +363,10 @@ public class KeyguardStatusBarView extends RelativeLayout implements
        UserInfoController userInfoController = Dependency.get(UserInfoController.class);
        userInfoController.addCallback(this);
        userInfoController.reloadUserInfo();
        Dependency.get(ConfigurationController.class).addCallback(this);
        mIconManager = new TintedIconManager(findViewById(R.id.statusIcons), mFeatureFlags);
        mIconManager.setBlockList(mBlockedIcons);
        Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
        mAnimationScheduler.addCallback(this);
        onThemeChanged();
    }

    @Override
@@ -379,7 +374,6 @@ public class KeyguardStatusBarView extends RelativeLayout implements
        super.onDetachedFromWindow();
        Dependency.get(UserInfoController.class).removeCallback(this);
        Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager);
        Dependency.get(ConfigurationController.class).removeCallback(this);
        mAnimationScheduler.removeCallback(this);
    }

@@ -467,7 +461,8 @@ public class KeyguardStatusBarView extends RelativeLayout implements
        return false;
    }

    public void onThemeChanged() {
    /** Should only be called from {@link KeyguardStatusBarViewController}. */
    void onThemeChanged() {
        mBatteryView.setColorsFromContext(mContext);
        updateIconsAndTextColors();
        // Reload user avatar
@@ -475,16 +470,10 @@ public class KeyguardStatusBarView extends RelativeLayout implements
                .onDensityOrFontScaleChanged();
    }

    @Override
    public void onDensityOrFontScaleChanged() {
        loadDimens();
    }

    @Override
    public void onOverlayChanged() {
    /** Should only be called from {@link KeyguardStatusBarViewController}. */
    void onOverlayChanged() {
        mCarrierLabel.setTextAppearance(
                Utils.getThemeAttr(mContext, com.android.internal.R.attr.textAppearanceSmall));
        onThemeChanged();
        mBatteryView.updatePercentView();
    }

+33 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone;

import com.android.keyguard.CarrierTextController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;

import javax.inject.Inject;
@@ -24,12 +25,35 @@ import javax.inject.Inject;
/** View Controller for {@link com.android.systemui.statusbar.phone.KeyguardStatusBarView}. */
public class KeyguardStatusBarViewController extends ViewController<KeyguardStatusBarView> {
    private final CarrierTextController mCarrierTextController;
    private final ConfigurationController mConfigurationController;

    private final ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
                @Override
                public void onDensityOrFontScaleChanged() {
                    mView.loadDimens();
                }

                @Override
                public void onOverlayChanged() {
                    KeyguardStatusBarViewController.this.onThemeChanged();
                    mView.onOverlayChanged();
                }

                @Override
                public void onThemeChanged() {
                    KeyguardStatusBarViewController.this.onThemeChanged();
                }
            };

    @Inject
    public KeyguardStatusBarViewController(
            KeyguardStatusBarView view, CarrierTextController carrierTextController) {
            KeyguardStatusBarView view,
            CarrierTextController carrierTextController,
            ConfigurationController configurationController) {
        super(view);
        mCarrierTextController = carrierTextController;
        mConfigurationController = configurationController;
    }

    @Override
@@ -40,9 +64,17 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat

    @Override
    protected void onViewAttached() {
        mConfigurationController.addCallback(mConfigurationListener);
        onThemeChanged();
    }

    @Override
    protected void onViewDetached() {
        mConfigurationController.removeCallback(mConfigurationListener);
    }

    /** Should be called when the theme changes. */
    public void onThemeChanged() {
        mView.onThemeChanged();
    }
}
+3 −7
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private KeyguardQsUserSwitchController mKeyguardQsUserSwitchController;
    private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
    private KeyguardStatusBarView mKeyguardStatusBar;
    private KeyguardStatusBarViewController mKeyguarStatusBarViewController;
    private KeyguardStatusBarViewController mKeyguardStatusBarViewController;
    private ViewGroup mBigClockContainer;
    @VisibleForTesting QS mQs;
    private FrameLayout mQsFrame;
@@ -971,9 +971,9 @@ public class NotificationPanelViewController extends PanelViewController {

        KeyguardStatusBarViewComponent statusBarViewComponent =
                mKeyguardStatusBarViewComponentFactory.build(keyguardStatusBarView);
        mKeyguarStatusBarViewController =
        mKeyguardStatusBarViewController =
                statusBarViewComponent.getKeyguardStatusBarViewController();
        mKeyguarStatusBarViewController.init();
        mKeyguardStatusBarViewController.init();

        if (mKeyguardUserSwitcherController != null) {
            // Try to close the switcher so that callbacks are triggered if necessary.
@@ -1150,10 +1150,6 @@ public class NotificationPanelViewController extends PanelViewController {
        mStatusBarStateListener.onDozeAmountChanged(mStatusBarStateController.getDozeAmount(),
                mStatusBarStateController.getInterpolatedDozeAmount());

        if (mKeyguardStatusBar != null) {
            mKeyguardStatusBar.onThemeChanged();
        }

        mKeyguardStatusViewController.setKeyguardStatusViewVisibility(
                mBarState,
                false,
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.phone;


import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;

import androidx.test.filters.SmallTest;

import com.android.keyguard.CarrierTextController;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.policy.ConfigurationController;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

@SmallTest
public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
    @Mock
    private KeyguardStatusBarView mKeyguardStatusBarView;
    @Mock
    private CarrierTextController mCarrierTextController;
    @Mock
    private ConfigurationController mConfigurationController;

    private KeyguardStatusBarViewController mController;

    @Before
    public void setup() throws Exception {
        MockitoAnnotations.initMocks(this);

        mController = new KeyguardStatusBarViewController(
                mKeyguardStatusBarView,
                mCarrierTextController,
                mConfigurationController
        );
    }

    @Test
    public void onViewAttached_callbacksRegistered() {
        mController.onViewAttached();

        verify(mConfigurationController).addCallback(any());
    }

    @Test
    public void onViewDetached_callbacksUnregistered() {
        mController.onViewDetached();

        verify(mConfigurationController).removeCallback(any());
    }
}