[Dagger] Move OnUserInfoChangedListener out of KeyguardStatusBarView

and into its controller.

Bug: 138786270
Test: atest (+ new unit tests) and manual
Change-Id: I9bbe14be2db410cf3511163a9d2d50ad3ef2f5ae
This commit is contained in:
Caitlin Cassidy
2021-07-19 15:13:10 +00:00
parent 3b2f521ac1
commit 6df785404c
3 changed files with 20 additions and 16 deletions

View File

@@ -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}. */

View File

@@ -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. */

View File

@@ -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