Merge "Add KeyguardStatusViewController"

This commit is contained in:
TreeHugger Robot
2020-10-16 15:25:41 +00:00
committed by Android (Google) Code Review
11 changed files with 660 additions and 444 deletions

View File

@@ -17,24 +17,32 @@
package com.android.keyguard;
import android.app.WallpaperManager;
import android.view.View;
import android.content.res.Resources;
import android.text.format.DateFormat;
import android.util.TypedValue;
import android.view.ViewGroup;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.util.ViewController;
import java.util.Locale;
import java.util.TimeZone;
import javax.inject.Inject;
/**
* Injectable controller for {@link KeyguardClockSwitch}.
*/
public class KeyguardClockSwitchController {
public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> {
private static final boolean CUSTOM_CLOCKS_ENABLED = true;
private final KeyguardClockSwitch mView;
private final Resources mResources;
private final StatusBarStateController mStatusBarStateController;
private final SysuiColorExtractor mColorExtractor;
private final ClockManager mClockManager;
@@ -65,35 +73,15 @@ public class KeyguardClockSwitchController {
private ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
private final View.OnAttachStateChangeListener mOnAttachStateChangeListener =
new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
if (CUSTOM_CLOCKS_ENABLED) {
mClockManager.addOnClockChangedListener(mClockChangedListener);
}
mStatusBarStateController.addCallback(mStateListener);
mColorExtractor.addOnColorsChangedListener(mColorsListener);
mView.updateColors(getGradientColors());
}
@Override
public void onViewDetachedFromWindow(View v) {
if (CUSTOM_CLOCKS_ENABLED) {
mClockManager.removeOnClockChangedListener(mClockChangedListener);
}
mStatusBarStateController.removeCallback(mStateListener);
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
mView.setClockPlugin(null, mStatusBarStateController.getState());
}
};
@Inject
public KeyguardClockSwitchController(KeyguardClockSwitch keyguardClockSwitch,
public KeyguardClockSwitchController(
KeyguardClockSwitch keyguardClockSwitch,
@Main Resources resources,
StatusBarStateController statusBarStateController,
SysuiColorExtractor colorExtractor, ClockManager clockManager,
KeyguardSliceViewController keyguardSliceViewController) {
mView = keyguardClockSwitch;
super(keyguardClockSwitch);
mResources = resources;
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
mClockManager = clockManager;
@@ -103,15 +91,41 @@ public class KeyguardClockSwitchController {
/**
* Attach the controller to the view it relates to.
*/
@Override
public void init() {
if (mView.isAttachedToWindow()) {
mOnAttachStateChangeListener.onViewAttachedToWindow(mView);
}
mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
super.init();
mKeyguardSliceViewController.init();
}
@Override
protected void onViewAttached() {
if (CUSTOM_CLOCKS_ENABLED) {
mClockManager.addOnClockChangedListener(mClockChangedListener);
}
refreshFormat();
mStatusBarStateController.addCallback(mStateListener);
mColorExtractor.addOnColorsChangedListener(mColorsListener);
mView.updateColors(getGradientColors());
}
@Override
protected void onViewDetached() {
if (CUSTOM_CLOCKS_ENABLED) {
mClockManager.removeOnClockChangedListener(mClockChangedListener);
}
mStatusBarStateController.removeCallback(mStateListener);
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
mView.setClockPlugin(null, mStatusBarStateController.getState());
}
/**
* Updates clock's text
*/
public void onDensityOrFontScaleChanged() {
mView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
mResources.getDimensionPixelSize(R.dimen.widget_big_font_size));
}
/**
* Set container for big clock face appearing behind NSSL and KeyguardStatusView.
*/
@@ -119,6 +133,61 @@ public class KeyguardClockSwitchController {
mView.setBigClockContainer(bigClockContainer, mStatusBarStateController.getState());
}
/**
* Set whether or not the lock screen is showing notifications.
*/
public void setHasVisibleNotifications(boolean hasVisibleNotifications) {
mView.setHasVisibleNotifications(hasVisibleNotifications);
}
/**
* If we're presenting a custom clock of just the default one.
*/
public boolean hasCustomClock() {
return mView.hasCustomClock();
}
/**
* Get the clock text size.
*/
public float getClockTextSize() {
return mView.getTextSize();
}
/**
* Returns the preferred Y position of the clock.
*
* @param totalHeight The height available to position the clock.
* @return Y position of clock.
*/
public int getClockPreferredY(int totalHeight) {
return mView.getPreferredY(totalHeight);
}
/**
* Refresh clock. Called in response to TIME_TICK broadcasts.
*/
void refresh() {
mView.refresh();
}
/**
* Update lockscreen mode that may change clock display.
*/
void updateLockScreenMode(int mode) {
mView.updateLockScreenMode(mode);
}
void updateTimeZone(TimeZone timeZone) {
mView.onTimeZoneChanged(timeZone);
}
void refreshFormat() {
Patterns.update(mResources);
mView.setFormat12Hour(Patterns.sClockView12);
mView.setFormat24Hour(Patterns.sClockView24);
}
private void setClockPlugin(ClockPlugin plugin) {
mView.setClockPlugin(plugin, mStatusBarStateController.getState());
}
@@ -126,4 +195,35 @@ public class KeyguardClockSwitchController {
private ColorExtractor.GradientColors getGradientColors() {
return mColorExtractor.getColors(WallpaperManager.FLAG_LOCK);
}
// DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often.
// This is an optimization to ensure we only recompute the patterns when the inputs change.
private static final class Patterns {
static String sClockView12;
static String sClockView24;
static String sCacheKey;
static void update(Resources res) {
final Locale locale = Locale.getDefault();
final String clockView12Skel = res.getString(R.string.clock_12hr_format);
final String clockView24Skel = res.getString(R.string.clock_24hr_format);
final String key = locale.toString() + clockView12Skel + clockView24Skel;
if (key.equals(sCacheKey)) return;
sClockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
// CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
// format. The following code removes the AM/PM indicator if we didn't want it.
if (!clockView12Skel.contains("a")) {
sClockView12 = sClockView12.replaceAll("a", "").trim();
}
sClockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);
// Use fancy colon.
sClockView24 = sClockView24.replace(':', '\uee01');
sClockView12 = sClockView12.replace(':', '\uee01');
sCacheKey = key;
}
}
}

View File

@@ -59,7 +59,6 @@ public class KeyguardSliceViewController implements Dumpable {
private static final String TAG = "KeyguardSliceViewCtrl";
private final KeyguardSliceView mView;
private final KeyguardStatusView mKeyguardStatusView;
private final ActivityStarter mActivityStarter;
private final ConfigurationController mConfigurationController;
private final TunerService mTunerService;
@@ -135,11 +134,10 @@ public class KeyguardSliceViewController implements Dumpable {
@Inject
public KeyguardSliceViewController(KeyguardSliceView keyguardSliceView,
KeyguardStatusView keyguardStatusView, ActivityStarter activityStarter,
ActivityStarter activityStarter,
ConfigurationController configurationController, TunerService tunerService,
DumpManager dumpManager) {
mView = keyguardSliceView;
mKeyguardStatusView = keyguardStatusView;
mActivityStarter = activityStarter;
mConfigurationController = configurationController;
mTunerService = tunerService;
@@ -153,8 +151,6 @@ public class KeyguardSliceViewController implements Dumpable {
}
mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
mView.setOnClickListener(mOnClickListener);
// TODO: remove the line below.
mKeyguardStatusView.setKeyguardSliceViewController(this);
}
/**
@@ -233,7 +229,5 @@ public class KeyguardSliceViewController implements Dumpable {
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
pw.println(" mSlice: " + mSlice);
pw.println(" mClickActions: " + mClickActions);
mKeyguardStatusView.dump(fd, pw, args);
}
}

View File

@@ -19,16 +19,13 @@ package com.android.keyguard;
import android.app.ActivityManager;
import android.app.IActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
import android.util.TypedValue;
import android.view.View;
import android.widget.GridLayout;
@@ -39,15 +36,18 @@ import androidx.core.graphics.ColorUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ConfigurationController;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.TimeZone;
public class KeyguardStatusView extends GridLayout implements
ConfigurationController.ConfigurationListener {
/**
* View consisting of:
* - keyguard clock
* - logout button (on certain managed devices)
* - owner information (if set)
* - notification icons (shown on AOD)
*/
public class KeyguardStatusView extends GridLayout {
private static final boolean DEBUG = KeyguardConstants.DEBUG;
private static final String TAG = "KeyguardStatusView";
private static final int MARQUEE_DELAY_MS = 2000;
@@ -62,9 +62,7 @@ public class KeyguardStatusView extends GridLayout implements
private View mNotificationIcons;
private Runnable mPendingMarqueeStart;
private Handler mHandler;
private KeyguardSliceViewController mKeyguardSliceViewController;
private boolean mPulsing;
private float mDarkAmount = 0;
private int mTextColor;
@@ -76,56 +74,6 @@ public class KeyguardStatusView extends GridLayout implements
private int mIconTopMarginWithHeader;
private boolean mShowingHeader;
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onLockScreenModeChanged(int mode) {
updateLockScreenMode(mode);
}
@Override
public void onTimeChanged() {
refreshTime();
}
@Override
public void onTimeZoneChanged(TimeZone timeZone) {
updateTimeZone(timeZone);
}
@Override
public void onKeyguardVisibilityChanged(boolean showing) {
if (showing) {
if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing);
refreshTime();
updateOwnerInfo();
updateLogoutView();
}
}
@Override
public void onStartedWakingUp() {
setEnableMarquee(true);
}
@Override
public void onFinishedGoingToSleep(int why) {
setEnableMarquee(false);
}
@Override
public void onUserSwitchComplete(int userId) {
refreshFormat();
updateOwnerInfo();
updateLogoutView();
}
@Override
public void onLogoutEnabledChanged() {
updateLogoutView();
}
};
public KeyguardStatusView(Context context) {
this(context, null, 0);
}
@@ -142,21 +90,7 @@ public class KeyguardStatusView extends GridLayout implements
onDensityOrFontScaleChanged();
}
/**
* If we're presenting a custom clock of just the default one.
*/
public boolean hasCustomClock() {
return mClockView.hasCustomClock();
}
/**
* Set whether or not the lock screen is showing notifications.
*/
public void setHasVisibleNotifications(boolean hasVisibleNotifications) {
mClockView.setHasVisibleNotifications(hasVisibleNotifications);
}
private void setEnableMarquee(boolean enabled) {
void setEnableMarquee(boolean enabled) {
if (DEBUG) Log.v(TAG, "Schedule setEnableMarquee: " + (enabled ? "Enable" : "Disable"));
if (enabled) {
if (mPendingMarqueeStart == null) {
@@ -203,7 +137,6 @@ public class KeyguardStatusView extends GridLayout implements
boolean shouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive();
setEnableMarquee(shouldMarquee);
refreshFormat();
updateOwnerInfo();
updateLogoutView();
updateDark();
@@ -238,64 +171,14 @@ public class KeyguardStatusView extends GridLayout implements
layoutOwnerInfo();
}
@Override
public void onDensityOrFontScaleChanged() {
if (mClockView != null) {
mClockView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(R.dimen.widget_big_font_size));
}
if (mOwnerInfo != null) {
mOwnerInfo.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(R.dimen.widget_label_font_size));
}
loadBottomMargin();
}
public void dozeTimeTick() {
refreshTime();
mKeyguardSliceViewController.refresh();
}
private void refreshTime() {
mClockView.refresh();
}
private void updateLockScreenMode(int mode) {
mClockView.updateLockScreenMode(mode);
}
private void updateTimeZone(TimeZone timeZone) {
mClockView.onTimeZoneChanged(timeZone);
}
private void refreshFormat() {
Patterns.update(mContext);
mClockView.setFormat12Hour(Patterns.clockView12);
mClockView.setFormat24Hour(Patterns.clockView24);
}
public int getLogoutButtonHeight() {
int getLogoutButtonHeight() {
if (mLogoutView == null) {
return 0;
}
return mLogoutView.getVisibility() == VISIBLE ? mLogoutView.getHeight() : 0;
}
public float getClockTextSize() {
return mClockView.getTextSize();
}
/**
* Returns the preferred Y position of the clock.
*
* @param totalHeight The height available to position the clock.
* @return Y position of clock.
*/
public int getClockPreferredY(int totalHeight) {
return mClockView.getPreferredY(totalHeight);
}
private void updateLogoutView() {
void updateLogoutView() {
if (mLogoutView == null) {
return;
}
@@ -305,7 +188,16 @@ public class KeyguardStatusView extends GridLayout implements
com.android.internal.R.string.global_action_logout));
}
private void updateOwnerInfo() {
void onDensityOrFontScaleChanged() {
if (mOwnerInfo != null) {
mOwnerInfo.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(
com.android.systemui.R.dimen.widget_label_font_size));
loadBottomMargin();
}
}
void updateOwnerInfo() {
if (mOwnerInfo == null) return;
String info = mLockPatternUtils.getDeviceOwnerInfo();
if (info == null) {
@@ -320,30 +212,36 @@ public class KeyguardStatusView extends GridLayout implements
updateDark();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Dependency.get(KeyguardUpdateMonitor.class).registerCallback(mInfoCallback);
Dependency.get(ConfigurationController.class).addCallback(this);
void setDarkAmount(float darkAmount) {
if (mDarkAmount == darkAmount) {
return;
}
mDarkAmount = darkAmount;
mClockView.setDarkAmount(darkAmount);
updateDark();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
Dependency.get(KeyguardUpdateMonitor.class).removeCallback(mInfoCallback);
Dependency.get(ConfigurationController.class).removeCallback(this);
}
void updateDark() {
boolean dark = mDarkAmount == 1;
if (mLogoutView != null) {
mLogoutView.setAlpha(dark ? 0 : 1);
}
@Override
public void onLocaleListChanged() {
refreshFormat();
if (mOwnerInfo != null) {
boolean hasText = !TextUtils.isEmpty(mOwnerInfo.getText());
mOwnerInfo.setVisibility(hasText ? VISIBLE : GONE);
layoutOwnerInfo();
}
final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, mDarkAmount);
mKeyguardSlice.setDarkAmount(mDarkAmount);
mClockView.setTextColor(blendedTextColor);
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("KeyguardStatusView:");
pw.println(" mOwnerInfo: " + (mOwnerInfo == null
? "null" : mOwnerInfo.getVisibility() == VISIBLE));
pw.println(" mPulsing: " + mPulsing);
pw.println(" mDarkAmount: " + mDarkAmount);
pw.println(" mTextColor: " + Integer.toHexString(mTextColor));
if (mLogoutView != null) {
@@ -363,64 +261,6 @@ public class KeyguardStatusView extends GridLayout implements
R.dimen.widget_vertical_padding_with_header);
}
// DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often.
// This is an optimization to ensure we only recompute the patterns when the inputs change.
private static final class Patterns {
static String clockView12;
static String clockView24;
static String cacheKey;
static void update(Context context) {
final Locale locale = Locale.getDefault();
final Resources res = context.getResources();
final String clockView12Skel = res.getString(R.string.clock_12hr_format);
final String clockView24Skel = res.getString(R.string.clock_24hr_format);
final String key = locale.toString() + clockView12Skel + clockView24Skel;
if (key.equals(cacheKey)) return;
clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
// CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
// format. The following code removes the AM/PM indicator if we didn't want it.
if (!clockView12Skel.contains("a")) {
clockView12 = clockView12.replaceAll("a", "").trim();
}
clockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);
// Use fancy colon.
clockView24 = clockView24.replace(':', '\uee01');
clockView12 = clockView12.replace(':', '\uee01');
cacheKey = key;
}
}
public void setDarkAmount(float darkAmount) {
if (mDarkAmount == darkAmount) {
return;
}
mDarkAmount = darkAmount;
mClockView.setDarkAmount(darkAmount);
updateDark();
}
private void updateDark() {
boolean dark = mDarkAmount == 1;
if (mLogoutView != null) {
mLogoutView.setAlpha(dark ? 0 : 1);
}
if (mOwnerInfo != null) {
boolean hasText = !TextUtils.isEmpty(mOwnerInfo.getText());
mOwnerInfo.setVisibility(hasText ? VISIBLE : GONE);
layoutOwnerInfo();
}
final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, mDarkAmount);
mKeyguardSlice.setDarkAmount(mDarkAmount);
mClockView.setTextColor(blendedTextColor);
}
private void layoutOwnerInfo() {
if (mOwnerInfo != null && mOwnerInfo.getVisibility() != GONE) {
// Animate owner info during wake-up transition
@@ -442,13 +282,6 @@ public class KeyguardStatusView extends GridLayout implements
}
}
public void setPulsing(boolean pulsing) {
if (mPulsing == pulsing) {
return;
}
mPulsing = pulsing;
}
private boolean shouldShowLogout() {
return Dependency.get(KeyguardUpdateMonitor.class).isLogoutEnabled()
&& KeyguardUpdateMonitor.getCurrentUser() != UserHandle.USER_SYSTEM;
@@ -463,9 +296,4 @@ public class KeyguardStatusView extends GridLayout implements
Log.e(TAG, "Failed to logout user", re);
}
}
// TODO: remove this method when a controller is available.
void setKeyguardSliceViewController(KeyguardSliceViewController keyguardSliceViewController) {
mKeyguardSliceViewController = keyguardSliceViewController;
}
}

View File

@@ -0,0 +1,329 @@
/*
* Copyright (C) 2020 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.keyguard;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import android.util.Slog;
import android.view.View;
import com.android.systemui.Interpolators;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ViewController;
import java.util.TimeZone;
import javax.inject.Inject;
/**
* Injectable controller for {@link KeyguardStatusView}.
*/
public class KeyguardStatusViewController extends ViewController<KeyguardStatusView> {
private static final boolean DEBUG = KeyguardConstants.DEBUG;
private static final String TAG = "KeyguardStatusViewController";
private static final AnimationProperties CLOCK_ANIMATION_PROPERTIES =
new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
private final KeyguardSliceViewController mKeyguardSliceViewController;
private final KeyguardClockSwitchController mKeyguardClockSwitchController;
private final KeyguardStateController mKeyguardStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final ConfigurationController mConfigurationController;
private boolean mKeyguardStatusViewAnimating;
@Inject
public KeyguardStatusViewController(
KeyguardStatusView keyguardStatusView,
KeyguardSliceViewController keyguardSliceViewController,
KeyguardClockSwitchController keyguardClockSwitchController,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
ConfigurationController configurationController) {
super(keyguardStatusView);
mKeyguardSliceViewController = keyguardSliceViewController;
mKeyguardClockSwitchController = keyguardClockSwitchController;
mKeyguardStateController = keyguardStateController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mConfigurationController = configurationController;
}
@Override
public void init() {
super.init();
mKeyguardClockSwitchController.init();
}
@Override
protected void onViewAttached() {
mKeyguardUpdateMonitor.registerCallback(mInfoCallback);
mConfigurationController.addCallback(mConfigurationListener);
}
@Override
protected void onViewDetached() {
mKeyguardUpdateMonitor.removeCallback(mInfoCallback);
mConfigurationController.removeCallback(mConfigurationListener);
}
/**
* Updates views on doze time tick.
*/
public void dozeTimeTick() {
refreshTime();
mKeyguardSliceViewController.refresh();
}
/**
* The amount we're in doze.
*/
public void setDarkAmount(float darkAmount) {
mView.setDarkAmount(darkAmount);
}
/**
* Set whether or not the lock screen is showing notifications.
*/
public void setHasVisibleNotifications(boolean hasVisibleNotifications) {
mKeyguardClockSwitchController.setHasVisibleNotifications(hasVisibleNotifications);
}
/**
* If we're presenting a custom clock of just the default one.
*/
public boolean hasCustomClock() {
return mKeyguardClockSwitchController.hasCustomClock();
}
/**
* Get the height of the logout button.
*/
public int getLogoutButtonHeight() {
return mView.getLogoutButtonHeight();
}
/**
* Set keyguard status view alpha.
*/
public void setAlpha(float alpha) {
if (!mKeyguardStatusViewAnimating) {
mView.setAlpha(alpha);
}
}
/**
* Set pivot x.
*/
public void setPivotX(float pivot) {
mView.setPivotX(pivot);
}
/**
* Set pivot y.
*/
public void setPivotY(float pivot) {
mView.setPivotY(pivot);
}
/**
* Get the clock text size.
*/
public float getClockTextSize() {
return mKeyguardClockSwitchController.getClockTextSize();
}
/**
* Returns the preferred Y position of the clock.
*
* @param totalHeight The height available to position the clock.
* @return Y position of clock.
*/
public int getClockPreferredY(int totalHeight) {
return mKeyguardClockSwitchController.getClockPreferredY(totalHeight);
}
/**
* Get the height of the keyguard status view.
*/
public int getHeight() {
return mView.getHeight();
}
/**
* Set whether the view accessibility importance mode.
*/
public void setStatusAccessibilityImportance(int mode) {
mView.setImportantForAccessibility(mode);
}
/**
* Update position of the view with an optional animation
*/
public void updatePosition(int clockTranslationX, int clockTranslationY,
boolean animateClock) {
PropertyAnimator.setProperty(mView, AnimatableProperty.X,
clockTranslationX, CLOCK_ANIMATION_PROPERTIES, animateClock);
PropertyAnimator.setProperty(mView, AnimatableProperty.Y,
clockTranslationY, CLOCK_ANIMATION_PROPERTIES, animateClock);
}
/**
* Set the visibility of the keyguard status view based on some new state.
*/
public void setKeyguardStatusViewVisibility(
int statusBarState,
boolean keyguardFadingAway,
boolean goingToFullShade,
int oldStatusBarState) {
mView.animate().cancel();
mKeyguardStatusViewAnimating = false;
if ((!keyguardFadingAway && oldStatusBarState == KEYGUARD
&& statusBarState != KEYGUARD) || goingToFullShade) {
mKeyguardStatusViewAnimating = true;
mView.animate()
.alpha(0f)
.setStartDelay(0)
.setDuration(160)
.setInterpolator(Interpolators.ALPHA_OUT)
.withEndAction(
mAnimateKeyguardStatusViewGoneEndRunnable);
if (keyguardFadingAway) {
mView.animate()
.setStartDelay(mKeyguardStateController.getKeyguardFadingAwayDelay())
.setDuration(mKeyguardStateController.getShortenedFadingAwayDuration())
.start();
}
} else if (oldStatusBarState == StatusBarState.SHADE_LOCKED && statusBarState == KEYGUARD) {
mView.setVisibility(View.VISIBLE);
mKeyguardStatusViewAnimating = true;
mView.setAlpha(0f);
mView.animate()
.alpha(1f)
.setStartDelay(0)
.setDuration(320)
.setInterpolator(Interpolators.ALPHA_IN)
.withEndAction(mAnimateKeyguardStatusViewVisibleEndRunnable);
} else if (statusBarState == KEYGUARD) {
if (keyguardFadingAway) {
mKeyguardStatusViewAnimating = true;
mView.animate()
.alpha(0)
.translationYBy(-getHeight() * 0.05f)
.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN)
.setDuration(125)
.setStartDelay(0)
.withEndAction(mAnimateKeyguardStatusViewInvisibleEndRunnable)
.start();
} else {
mView.setVisibility(View.VISIBLE);
mView.setAlpha(1f);
}
} else {
mView.setVisibility(View.GONE);
mView.setAlpha(1f);
}
}
private void refreshTime() {
mKeyguardClockSwitchController.refresh();
}
private final ConfigurationController.ConfigurationListener mConfigurationListener =
new ConfigurationController.ConfigurationListener() {
@Override
public void onLocaleListChanged() {
refreshTime();
}
@Override
public void onDensityOrFontScaleChanged() {
mKeyguardClockSwitchController.onDensityOrFontScaleChanged();
mView.onDensityOrFontScaleChanged();
}
};
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onLockScreenModeChanged(int mode) {
mKeyguardClockSwitchController.updateLockScreenMode(mode);
}
@Override
public void onTimeChanged() {
refreshTime();
}
@Override
public void onTimeZoneChanged(TimeZone timeZone) {
mKeyguardClockSwitchController.updateTimeZone(timeZone);
}
@Override
public void onKeyguardVisibilityChanged(boolean showing) {
if (showing) {
if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing);
refreshTime();
mView.updateOwnerInfo();
mView.updateLogoutView();
}
}
@Override
public void onStartedWakingUp() {
mView.setEnableMarquee(true);
}
@Override
public void onFinishedGoingToSleep(int why) {
mView.setEnableMarquee(false);
}
@Override
public void onUserSwitchComplete(int userId) {
mKeyguardClockSwitchController.refreshFormat();
mView.updateOwnerInfo();
mView.updateLogoutView();
}
@Override
public void onLogoutEnabledChanged() {
mView.updateLogoutView();
}
};
private final Runnable mAnimateKeyguardStatusViewInvisibleEndRunnable = () -> {
mKeyguardStatusViewAnimating = false;
mView.setVisibility(View.INVISIBLE);
};
private final Runnable mAnimateKeyguardStatusViewGoneEndRunnable = () -> {
mKeyguardStatusViewAnimating = false;
mView.setVisibility(View.GONE);
};
private final Runnable mAnimateKeyguardStatusViewVisibleEndRunnable = () -> {
mKeyguardStatusViewAnimating = false;
};
}

View File

@@ -18,6 +18,7 @@ package com.android.keyguard.dagger;
import com.android.keyguard.KeyguardClockSwitchController;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
import dagger.BindsInstance;
import dagger.Subcomponent;
@@ -36,4 +37,7 @@ public interface KeyguardStatusViewComponent {
/** Builds a {@link com.android.keyguard.KeyguardClockSwitchController}. */
KeyguardClockSwitchController getKeyguardClockSwitchController();
/** Builds a {@link com.android.keyguard.KeyguardStatusViewController}. */
KeyguardStatusViewController getKeyguardStatusViewController();
}

View File

@@ -70,6 +70,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.LatencyTracker;
import com.android.keyguard.KeyguardClockSwitchController;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
@@ -202,9 +203,6 @@ public class NotificationPanelViewController extends PanelViewController {
private static final Rect M_DUMMY_DIRTY_RECT = new Rect(0, 0, 1, 1);
private static final Rect EMPTY_RECT = new Rect();
private static final AnimationProperties
CLOCK_ANIMATION_PROPERTIES =
new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
private final AnimatableProperty KEYGUARD_HEADS_UP_SHOWING_AMOUNT = AnimatableProperty.from(
"KEYGUARD_HEADS_UP_SHOWING_AMOUNT",
(notificationPanelView, aFloat) -> setKeyguardHeadsUpShowingAmount(aFloat),
@@ -280,7 +278,7 @@ public class NotificationPanelViewController extends PanelViewController {
private ViewGroup mBigClockContainer;
private QS mQs;
private FrameLayout mQsFrame;
private KeyguardStatusView mKeyguardStatusView;
private KeyguardStatusViewController mKeyguardStatusViewController;
private View mQsNavbarScrim;
private NotificationsQuickSettingsContainer mNotificationContainerParent;
private boolean mAnimateNextPositionUpdate;
@@ -344,7 +342,6 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean mIsLaunchTransitionRunning;
private Runnable mLaunchAnimationEndRunnable;
private boolean mOnlyAffordanceInThisMotion;
private boolean mKeyguardStatusViewAnimating;
private ValueAnimator mQsSizeChangeAnimator;
private boolean mQsScrimEnabled = true;
@@ -606,16 +603,8 @@ public class NotificationPanelViewController extends PanelViewController {
private void onFinishInflate() {
loadDimens();
mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
mKeyguardStatusView = mView.findViewById(R.id.keyguard_status_view);
KeyguardClockSwitchController keyguardClockSwitchController =
mKeyguardStatusViewComponentFactory
.build(mKeyguardStatusView)
.getKeyguardClockSwitchController();
keyguardClockSwitchController.init();
mBigClockContainer = mView.findViewById(R.id.big_clock_container);
keyguardClockSwitchController.setBigClockContainer(mBigClockContainer);
updateViewControllers(mView.findViewById(R.id.keyguard_status_view));
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
R.id.notification_stack_scroller);
@@ -689,11 +678,24 @@ public class NotificationPanelViewController extends PanelViewController {
R.dimen.heads_up_status_bar_padding);
}
private void updateViewControllers(KeyguardStatusView keyguardStatusView) {
// Re-associate the KeyguardStatusViewController
KeyguardStatusViewComponent statusViewComponent =
mKeyguardStatusViewComponentFactory.build(keyguardStatusView);
mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController();
mKeyguardStatusViewController.init();
// Re-associate the clock container with the keyguard clock switch.
KeyguardClockSwitchController keyguardClockSwitchController =
statusViewComponent.getKeyguardClockSwitchController();
keyguardClockSwitchController.setBigClockContainer(mBigClockContainer);
}
/**
* Returns if there's a custom clock being presented.
*/
public boolean hasCustomClock() {
return mKeyguardStatusView.hasCustomClock();
return mKeyguardStatusViewController.hasCustomClock();
}
private void setStatusBar(StatusBar bar) {
@@ -730,21 +732,16 @@ public class NotificationPanelViewController extends PanelViewController {
private void reInflateViews() {
// Re-inflate the status view group.
int index = mView.indexOfChild(mKeyguardStatusView);
mView.removeView(mKeyguardStatusView);
mKeyguardStatusView = (KeyguardStatusView) mInjectionInflationController.injectable(
KeyguardStatusView keyguardStatusView = mView.findViewById(R.id.keyguard_status_view);
int index = mView.indexOfChild(keyguardStatusView);
mView.removeView(keyguardStatusView);
keyguardStatusView = (KeyguardStatusView) mInjectionInflationController.injectable(
LayoutInflater.from(mView.getContext())).inflate(
R.layout.keyguard_status_view, mView, false);
mView.addView(mKeyguardStatusView, index);
mView.addView(keyguardStatusView, index);
// Re-associate the clock container with the keyguard clock switch.
mBigClockContainer.removeAllViews();
KeyguardClockSwitchController keyguardClockSwitchController =
mKeyguardStatusViewComponentFactory
.build(mKeyguardStatusView)
.getKeyguardClockSwitchController();
keyguardClockSwitchController.init();
keyguardClockSwitchController.setBigClockContainer(mBigClockContainer);
updateViewControllers(keyguardStatusView);
// Update keyguard bottom area
index = mView.indexOfChild(mKeyguardBottomArea);
@@ -764,7 +761,11 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardStatusBar.onThemeChanged();
}
setKeyguardStatusViewVisibility(mBarState, false, false);
mKeyguardStatusViewController.setKeyguardStatusViewVisibility(
mBarState,
false,
false,
mBarState);
setKeyguardBottomAreaVisibility(mBarState, false);
if (mOnReinflationListener != null) {
mOnReinflationListener.run();
@@ -858,23 +859,23 @@ public class NotificationPanelViewController extends PanelViewController {
} else {
int totalHeight = mView.getHeight();
int bottomPadding = Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding);
int clockPreferredY = mKeyguardStatusView.getClockPreferredY(totalHeight);
int clockPreferredY = mKeyguardStatusViewController.getClockPreferredY(totalHeight);
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
final boolean hasVisibleNotifications = !bypassEnabled
&& mNotificationStackScrollLayoutController.getVisibleNotificationCount() != 0;
mKeyguardStatusView.setHasVisibleNotifications(hasVisibleNotifications);
mKeyguardStatusViewController.setHasVisibleNotifications(hasVisibleNotifications);
mClockPositionAlgorithm.setup(mStatusBarMinHeight, totalHeight - bottomPadding,
mNotificationStackScrollLayoutController.getIntrinsicContentHeight(),
getExpandedFraction(),
totalHeight, (int) (mKeyguardStatusView.getHeight() - mShelfHeight / 2.0f
- mDarkIconSize / 2.0f), clockPreferredY, hasCustomClock(),
totalHeight,
(int) (mKeyguardStatusViewController.getHeight()
- mShelfHeight / 2.0f - mDarkIconSize / 2.0f),
clockPreferredY, hasCustomClock(),
hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
bypassEnabled, getUnlockedStackScrollerPadding());
mClockPositionAlgorithm.run(mClockPositionResult);
PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.X,
mClockPositionResult.clockX, CLOCK_ANIMATION_PROPERTIES, animateClock);
PropertyAnimator.setProperty(mKeyguardStatusView, AnimatableProperty.Y,
mClockPositionResult.clockY, CLOCK_ANIMATION_PROPERTIES, animateClock);
mKeyguardStatusViewController.updatePosition(
mClockPositionResult.clockX, mClockPositionResult.clockY, animateClock);
updateNotificationTranslucency();
updateClock();
stackScrollerPadding = mClockPositionResult.stackScrollerPaddingExpanded;
@@ -910,7 +911,7 @@ public class NotificationPanelViewController extends PanelViewController {
float availableSpace =
mNotificationStackScrollLayoutController.getHeight() - minPadding - shelfSize
- Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)
- mKeyguardStatusView.getLogoutButtonHeight();
- mKeyguardStatusViewController.getLogoutButtonHeight();
int count = 0;
ExpandableView previousView = null;
for (int i = 0; i < mNotificationStackScrollLayoutController.getChildCount(); i++) {
@@ -1005,9 +1006,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
private void updateClock() {
if (!mKeyguardStatusViewAnimating) {
mKeyguardStatusView.setAlpha(mClockPositionResult.clockAlpha);
}
mKeyguardStatusViewController.setAlpha(mClockPositionResult.clockAlpha);
}
public void animateToFullShade(long delay) {
@@ -1605,29 +1604,6 @@ public class NotificationPanelViewController extends PanelViewController {
}
}
private final Runnable mAnimateKeyguardStatusViewInvisibleEndRunnable = new Runnable() {
@Override
public void run() {
mKeyguardStatusViewAnimating = false;
mKeyguardStatusView.setVisibility(View.INVISIBLE);
}
};
private final Runnable mAnimateKeyguardStatusViewGoneEndRunnable = new Runnable() {
@Override
public void run() {
mKeyguardStatusViewAnimating = false;
mKeyguardStatusView.setVisibility(View.GONE);
}
};
private final Runnable mAnimateKeyguardStatusViewVisibleEndRunnable = new Runnable() {
@Override
public void run() {
mKeyguardStatusViewAnimating = false;
}
};
private final Runnable mAnimateKeyguardStatusBarInvisibleEndRunnable = new Runnable() {
@Override
public void run() {
@@ -1705,46 +1681,6 @@ public class NotificationPanelViewController extends PanelViewController {
}
}
private void setKeyguardStatusViewVisibility(int statusBarState, boolean keyguardFadingAway,
boolean goingToFullShade) {
mKeyguardStatusView.animate().cancel();
mKeyguardStatusViewAnimating = false;
if ((!keyguardFadingAway && mBarState == KEYGUARD
&& statusBarState != KEYGUARD) || goingToFullShade) {
mKeyguardStatusViewAnimating = true;
mKeyguardStatusView.animate().alpha(0f).setStartDelay(0).setDuration(
160).setInterpolator(Interpolators.ALPHA_OUT).withEndAction(
mAnimateKeyguardStatusViewGoneEndRunnable);
if (keyguardFadingAway) {
mKeyguardStatusView.animate().setStartDelay(
mKeyguardStateController.getKeyguardFadingAwayDelay()).setDuration(
mKeyguardStateController.getShortenedFadingAwayDuration()).start();
}
} else if (mBarState == StatusBarState.SHADE_LOCKED
&& statusBarState == KEYGUARD) {
mKeyguardStatusView.setVisibility(View.VISIBLE);
mKeyguardStatusViewAnimating = true;
mKeyguardStatusView.setAlpha(0f);
mKeyguardStatusView.animate().alpha(1f).setStartDelay(0).setDuration(
320).setInterpolator(Interpolators.ALPHA_IN).withEndAction(
mAnimateKeyguardStatusViewVisibleEndRunnable);
} else if (statusBarState == KEYGUARD) {
if (keyguardFadingAway) {
mKeyguardStatusViewAnimating = true;
mKeyguardStatusView.animate().alpha(0).translationYBy(
-getHeight() * 0.05f).setInterpolator(
Interpolators.FAST_OUT_LINEAR_IN).setDuration(125).setStartDelay(
0).withEndAction(mAnimateKeyguardStatusViewInvisibleEndRunnable).start();
} else {
mKeyguardStatusView.setVisibility(View.VISIBLE);
mKeyguardStatusView.setAlpha(1f);
}
} else {
mKeyguardStatusView.setVisibility(View.GONE);
mKeyguardStatusView.setAlpha(1f);
}
}
private void updateQsState() {
mNotificationStackScrollLayoutController.setQsExpanded(mQsExpanded);
mNotificationStackScrollLayoutController.setScrollingEnabled(
@@ -2075,7 +2011,7 @@ public class NotificationPanelViewController extends PanelViewController {
private int getMaxPanelHeightBypass() {
int position =
mClockPositionAlgorithm.getExpandedClockPosition()
+ mKeyguardStatusView.getHeight();
+ mKeyguardStatusViewController.getHeight();
if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() != 0) {
position += mShelfHeight / 2.0f + mDarkIconSize / 2.0f;
}
@@ -2156,7 +2092,7 @@ public class NotificationPanelViewController extends PanelViewController {
int
minKeyguardPanelBottom =
mClockPositionAlgorithm.getExpandedClockPosition()
+ mKeyguardStatusView.getHeight()
+ mKeyguardStatusViewController.getHeight()
+ mNotificationStackScrollLayoutController.getIntrinsicContentHeight();
return Math.max(maxHeight, minKeyguardPanelBottom);
} else {
@@ -2604,7 +2540,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
public void onScreenTurningOn() {
mKeyguardStatusView.dozeTimeTick();
mKeyguardStatusViewController.dozeTimeTick();
}
@Override
@@ -2989,7 +2925,6 @@ public class NotificationPanelViewController extends PanelViewController {
mAnimateNextPositionUpdate = false;
}
mNotificationStackScrollLayoutController.setPulsing(pulsing, animatePulse);
mKeyguardStatusView.setPulsing(pulsing);
}
public void setAmbientIndicationBottomPadding(int ambientIndicationBottomPadding) {
@@ -3001,14 +2936,14 @@ public class NotificationPanelViewController extends PanelViewController {
public void dozeTimeTick() {
mKeyguardBottomArea.dozeTimeTick();
mKeyguardStatusView.dozeTimeTick();
mKeyguardStatusViewController.dozeTimeTick();
if (mInterpolatedDarkAmount > 0) {
positionClockAndNotifications();
}
}
public void setStatusAccessibilityImportance(int mode) {
mKeyguardStatusView.setImportantForAccessibility(mode);
mKeyguardStatusViewController.setStatusAccessibilityImportance(mode);
}
/**
@@ -3068,8 +3003,11 @@ public class NotificationPanelViewController extends PanelViewController {
* security view of the bouncer.
*/
public void onBouncerPreHideAnimation() {
setKeyguardStatusViewVisibility(mBarState, true /* keyguardFadingAway */,
false /* goingToFullShade */);
mKeyguardStatusViewController.setKeyguardStatusViewVisibility(
mBarState,
true /* keyguardFadingAway */,
false /* goingToFullShade */,
mBarState);
}
/**
@@ -3639,7 +3577,11 @@ public class NotificationPanelViewController extends PanelViewController {
int oldState = mBarState;
boolean keyguardShowing = statusBarState == KEYGUARD;
setKeyguardStatusViewVisibility(statusBarState, keyguardFadingAway, goingToFullShade);
mKeyguardStatusViewController.setKeyguardStatusViewVisibility(
statusBarState,
keyguardFadingAway,
goingToFullShade,
mBarState);
setKeyguardBottomAreaVisibility(statusBarState, goingToFullShade);
mBarState = statusBarState;
@@ -3690,7 +3632,7 @@ public class NotificationPanelViewController extends PanelViewController {
public void onDozeAmountChanged(float linearAmount, float amount) {
mInterpolatedDarkAmount = amount;
mLinearDarkAmount = linearAmount;
mKeyguardStatusView.setDarkAmount(mInterpolatedDarkAmount);
mKeyguardStatusViewController.setDarkAmount(mInterpolatedDarkAmount);
mKeyguardBottomArea.setDarkAmount(mInterpolatedDarkAmount);
positionClockAndNotifications();
}
@@ -3736,9 +3678,10 @@ public class NotificationPanelViewController extends PanelViewController {
setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth());
// Update Clock Pivot
mKeyguardStatusView.setPivotX(mView.getWidth() / 2);
mKeyguardStatusView.setPivotY(
(FONT_HEIGHT - CAP_HEIGHT) / 2048f * mKeyguardStatusView.getClockTextSize());
mKeyguardStatusViewController.setPivotX(mView.getWidth() / 2);
mKeyguardStatusViewController.setPivotY(
(FONT_HEIGHT - CAP_HEIGHT) / 2048f
* mKeyguardStatusViewController.getClockTextSize());
// Calculate quick setting heights.
int oldMaxHeight = mQsMaxExpansionHeight;

View File

@@ -24,6 +24,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.res.Resources;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.view.View;
@@ -64,6 +65,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
ColorExtractor.GradientColors mGradientColors;
@Mock
KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
Resources mResources;
private KeyguardClockSwitchController mController;
@@ -72,9 +75,13 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
when(mView.isAttachedToWindow()).thenReturn(true);
when(mResources.getString(anyInt())).thenReturn("h:mm");
mController = new KeyguardClockSwitchController(
mView, mStatusBarStateController, mColorExtractor, mClockManager,
mView,
mResources,
mStatusBarStateController,
mColorExtractor,
mClockManager,
mKeyguardSliceViewController);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);

View File

@@ -44,9 +44,7 @@ import org.mockito.MockitoAnnotations;
@RunWithLooper(setAsMainLooper = true)
public class KeyguardSliceViewControllerTest extends SysuiTestCase {
@Mock
private KeyguardSliceView mView;;
@Mock
private KeyguardStatusView mKeyguardStatusView;
private KeyguardSliceView mView;
@Mock
private TunerService mTunerService;
@Mock
@@ -63,7 +61,7 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase {
when(mView.isAttachedToWindow()).thenReturn(true);
when(mView.getContext()).thenReturn(mContext);
mController = new KeyguardSliceViewController(
mView, mKeyguardStatusView, mActivityStarter, mConfigurationController,
mView, mActivityStarter, mConfigurationController,
mTunerService, mDumpManager);
mController.setupUri(KeyguardSliceProvider.KEYGUARD_SLICE_URI);
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2020 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.keyguard;
import static org.mockito.Mockito.verify;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class KeyguardStatusViewControllerTest extends SysuiTestCase {
@Mock
private KeyguardStatusView mKeyguardStatusView;
@Mock
private KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
private KeyguardClockSwitchController mKeyguardClockSwitchController;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
ConfigurationController mConfigurationController;
private KeyguardStatusViewController mController;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mController = new KeyguardStatusViewController(
mKeyguardStatusView,
mKeyguardSliceViewController,
mKeyguardClockSwitchController,
mKeyguardStateController,
mKeyguardUpdateMonitor,
mConfigurationController);
}
@Test
public void dozeTimeTick_updatesSlice() {
mController.dozeTimeTick();
verify(mKeyguardSliceViewController).refresh();
}
@Test
public void dozeTimeTick_updatesClock() {
mController.dozeTimeTick();
verify(mKeyguardClockSwitchController).refresh();
}
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (C) 2018 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.keyguard;
import static org.mockito.Mockito.verify;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@SmallTest
@RunWithLooper
@RunWith(AndroidTestingRunner.class)
public class KeyguardStatusViewTest extends SysuiTestCase {
@Mock
KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
KeyguardClockSwitch mClockView;
@InjectMocks
KeyguardStatusView mKeyguardStatusView;
@Before
public void setUp() {
allowTestableLooperAsMainThread();
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
mKeyguardStatusView =
(KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null);
org.mockito.MockitoAnnotations.initMocks(this);
}
@Test
public void dozeTimeTick_updatesSlice() {
mKeyguardStatusView.dozeTimeTick();
verify(mKeyguardSliceViewController).refresh();
}
@Test
public void dozeTimeTick_updatesClock() {
mKeyguardStatusView.dozeTimeTick();
verify(mClockView).refresh();
}
}

View File

@@ -53,6 +53,7 @@ import com.android.internal.util.LatencyTracker;
import com.android.keyguard.KeyguardClockSwitch;
import com.android.keyguard.KeyguardClockSwitchController;
import com.android.keyguard.KeyguardStatusView;
import com.android.keyguard.KeyguardStatusViewController;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
import com.android.systemui.R;
@@ -190,6 +191,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private KeyguardClockSwitchController mKeyguardClockSwitchController;
@Mock
private KeyguardStatusViewController mKeyguardStatusViewController;
@Mock
private NotificationStackScrollLayoutController mNotificationStackScrollLayoutController;
private NotificationPanelViewController mNotificationPanelViewController;
@@ -246,6 +249,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
.thenReturn(mKeyguardStatusViewComponent);
when(mKeyguardStatusViewComponent.getKeyguardClockSwitchController())
.thenReturn(mKeyguardClockSwitchController);
when(mKeyguardStatusViewComponent.getKeyguardStatusViewController())
.thenReturn(mKeyguardStatusViewController);
mNotificationPanelViewController = new NotificationPanelViewController(mView,
mResources,
mInjectionInflationController,