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

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

Merge "[Dagger] Move OnUserInfoChangedListener out of KeyguardStatusBarView...

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

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

Change-Id: Ifbb9ad33eba2a2ddf5a32537f46b474a364175c3
parents a91d642d 7bc08d28
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -49,9 +49,6 @@ import com.android.systemui.animation.Interpolators;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChangedListener;
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -61,8 +58,7 @@ import java.util.List;
/**
 * The header group on Keyguard.
 */
public class KeyguardStatusBarView extends RelativeLayout implements
        OnUserInfoChangedListener {
public class KeyguardStatusBarView extends RelativeLayout {

    private static final int LAYOUT_NONE = 0;
    private static final int LAYOUT_CUTOUT = 1;
@@ -334,9 +330,6 @@ public class KeyguardStatusBarView extends RelativeLayout implements
    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        UserInfoController userInfoController = Dependency.get(UserInfoController.class);
        userInfoController.addCallback(this);
        userInfoController.reloadUserInfo();
        mIconManager = new TintedIconManager(findViewById(R.id.statusIcons), mFeatureFlags);
        mIconManager.setBlockList(mBlockedIcons);
        Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
@@ -345,12 +338,11 @@ public class KeyguardStatusBarView extends RelativeLayout implements
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Dependency.get(UserInfoController.class).removeCallback(this);
        Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager);
    }

    @Override
    public void onUserInfoChanged(String name, Drawable picture, String userAccount) {
    /** Should only be called from {@link KeyguardStatusBarViewController}. */
    void onUserInfoChanged(Drawable picture) {
        mMultiUserAvatar.setImageDrawable(picture);
    }

@@ -432,9 +424,6 @@ public class KeyguardStatusBarView extends RelativeLayout implements
    void onThemeChanged() {
        mBatteryView.setColorsFromContext(mContext);
        updateIconsAndTextColors();
        // Reload user avatar
        ((UserInfoControllerImpl) Dependency.get(UserInfoController.class))
                .onDensityOrFontScaleChanged();
    }

    /** Should only be called from {@link KeyguardStatusBarViewController}. */
+10 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.statusbar.events.SystemStatusAnimationCallback;
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.util.ViewController;

import java.io.FileDescriptor;
@@ -41,6 +42,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    private final ConfigurationController mConfigurationController;
    private final SystemStatusAnimationScheduler mAnimationScheduler;
    private final BatteryController mBatteryController;
    private final UserInfoController mUserInfoController;

    private final ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
@@ -89,6 +91,9 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
                }
            };

    private final UserInfoController.OnUserInfoChangedListener mOnUserInfoChangedListener =
            (name, picture, userAccount) -> mView.onUserInfoChanged(picture);

    private boolean mBatteryListening;

    @Inject
@@ -97,12 +102,14 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
            CarrierTextController carrierTextController,
            ConfigurationController configurationController,
            SystemStatusAnimationScheduler animationScheduler,
            BatteryController batteryController) {
            BatteryController batteryController,
            UserInfoController userInfoController) {
        super(view);
        mCarrierTextController = carrierTextController;
        mConfigurationController = configurationController;
        mAnimationScheduler = animationScheduler;
        mBatteryController = batteryController;
        mUserInfoController = userInfoController;
    }

    @Override
@@ -115,6 +122,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    protected void onViewAttached() {
        mConfigurationController.addCallback(mConfigurationListener);
        mAnimationScheduler.addCallback(mAnimationCallback);
        mUserInfoController.addCallback(mOnUserInfoChangedListener);
        onThemeChanged();
    }

@@ -122,6 +130,7 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
    protected void onViewDetached() {
        mConfigurationController.removeCallback(mConfigurationListener);
        mAnimationScheduler.removeCallback(mAnimationCallback);
        mUserInfoController.removeCallback(mOnUserInfoChangedListener);
    }

    /** Should be called when the theme changes. */
+7 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.UserInfoController;

import org.junit.Before;
import org.junit.Test;
@@ -45,6 +46,8 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
    private SystemStatusAnimationScheduler mAnimationScheduler;
    @Mock
    private BatteryController mBatteryController;
    @Mock
    private UserInfoController mUserInfoController;

    private KeyguardStatusBarViewController mController;

@@ -57,7 +60,8 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {
                mCarrierTextController,
                mConfigurationController,
                mAnimationScheduler,
                mBatteryController
                mBatteryController,
                mUserInfoController
        );
    }

@@ -67,6 +71,7 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {

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

    @Test
@@ -75,6 +80,7 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase {

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

    @Test