Merge "AOD - Notif icon location" into sc-v2-dev

This commit is contained in:
Matt Pietal
2021-10-14 15:21:35 +00:00
committed by Android (Google) Code Review
19 changed files with 85 additions and 247 deletions

View File

@@ -51,7 +51,7 @@
android:id="@+id/lockscreen_clock_view_large"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/keyguard_status_area"
android:layout_below="@id/keyguard_slice_view"
android:visibility="gone">
<com.android.keyguard.AnimatableClockView
android:id="@+id/animatable_clock_view_large"
@@ -68,19 +68,28 @@
lockScreenWeight="400"
/>
</FrameLayout>
<include layout="@layout/keyguard_status_area"
<!-- Not quite optimal but needed to translate these items as a group. The
NotificationIconContainer has its own logic for translation. -->
<LinearLayout
android:id="@+id/keyguard_status_area"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/lockscreen_clock_view" />
android:layout_below="@id/lockscreen_clock_view">
<com.android.systemui.statusbar.phone.NotificationIconContainer
android:id="@+id/left_aligned_notification_icon_container"
android:layout_width="match_parent"
android:layout_height="@dimen/notification_shelf_height"
android:layout_below="@id/keyguard_status_area"
android:paddingStart="@dimen/below_clock_padding_start_icons"
android:visibility="invisible"
/>
<include layout="@layout/keyguard_slice_view"
android:id="@+id/keyguard_slice_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.android.systemui.statusbar.phone.NotificationIconContainer
android:id="@+id/left_aligned_notification_icon_container"
android:layout_width="match_parent"
android:layout_height="@dimen/notification_shelf_height"
android:paddingStart="@dimen/below_clock_padding_start_icons"
android:visibility="invisible"
/>
</LinearLayout>
</com.android.keyguard.KeyguardClockSwitch>

View File

@@ -22,11 +22,10 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="start"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingStart="@dimen/below_clock_padding_start"
android:layout_centerHorizontal="true">
android:paddingStart="@dimen/below_clock_padding_start">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
@@ -42,6 +41,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:gravity="start"
/>
</com.android.keyguard.KeyguardSliceView>

View File

@@ -24,9 +24,6 @@
<bool name="flag_monet">true</bool>
<!-- AOD/Lockscreen alternate layout -->
<bool name="flag_keyguard_layout">true</bool>
<!-- People Tile flag -->
<bool name="flag_conversations">false</bool>

View File

@@ -41,7 +41,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
private static final long CLOCK_OUT_MILLIS = 150;
private static final long CLOCK_IN_MILLIS = 200;
private static final long SMARTSPACE_MOVE_MILLIS = 350;
private static final long STATUS_AREA_MOVE_MILLIS = 350;
@IntDef({LARGE, SMALL})
@Retention(RetentionPolicy.SOURCE)
@@ -63,13 +63,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
private AnimatableClockView mClockView;
private AnimatableClockView mLargeClockView;
/**
* Status area (date and other stuff) shown below the clock. Plugin can decide whether or not to
* show it below the alternate clock.
*/
private View mKeyguardStatusArea;
/** Mutually exclusive with mKeyguardStatusArea */
private View mSmartspaceView;
private View mStatusArea;
private int mSmartspaceTopOffset;
/**
@@ -85,7 +79,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
@VisibleForTesting AnimatorSet mClockInAnim = null;
@VisibleForTesting AnimatorSet mClockOutAnim = null;
private ObjectAnimator mSmartspaceAnim = null;
private ObjectAnimator mStatusAreaAnim = null;
/**
* If the Keyguard Slice has a header (big center-aligned text.)
@@ -131,7 +125,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
mClockView = findViewById(R.id.animatable_clock_view);
mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large);
mLargeClockView = findViewById(R.id.animatable_clock_view_large);
mKeyguardStatusArea = findViewById(R.id.keyguard_status_area);
mStatusArea = findViewById(R.id.keyguard_status_area);
onDensityOrFontScaleChanged();
}
@@ -200,22 +194,22 @@ public class KeyguardClockSwitch extends RelativeLayout {
private void animateClockChange(boolean useLargeClock) {
if (mClockInAnim != null) mClockInAnim.cancel();
if (mClockOutAnim != null) mClockOutAnim.cancel();
if (mSmartspaceAnim != null) mSmartspaceAnim.cancel();
if (mStatusAreaAnim != null) mStatusAreaAnim.cancel();
View in, out;
int direction = 1;
float smartspaceYTranslation;
float statusAreaYTranslation;
if (useLargeClock) {
out = mClockFrame;
in = mLargeClockFrame;
if (indexOfChild(in) == -1) addView(in);
direction = -1;
smartspaceYTranslation = mSmartspaceView == null ? 0
: mClockFrame.getTop() - mSmartspaceView.getTop() + mSmartspaceTopOffset;
statusAreaYTranslation = mClockFrame.getTop() - mStatusArea.getTop()
+ mSmartspaceTopOffset;
} else {
in = mClockFrame;
out = mLargeClockFrame;
smartspaceYTranslation = 0f;
statusAreaYTranslation = 0f;
// Must remove in order for notifications to appear in the proper place
removeView(out);
@@ -251,18 +245,16 @@ public class KeyguardClockSwitch extends RelativeLayout {
mClockInAnim.start();
mClockOutAnim.start();
if (mSmartspaceView != null) {
mSmartspaceAnim = ObjectAnimator.ofFloat(mSmartspaceView, View.TRANSLATION_Y,
smartspaceYTranslation);
mSmartspaceAnim.setDuration(SMARTSPACE_MOVE_MILLIS);
mSmartspaceAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mSmartspaceAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
mSmartspaceAnim = null;
}
});
mSmartspaceAnim.start();
}
mStatusAreaAnim = ObjectAnimator.ofFloat(mStatusArea, View.TRANSLATION_Y,
statusAreaYTranslation);
mStatusAreaAnim.setDuration(STATUS_AREA_MOVE_MILLIS);
mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
mStatusAreaAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
mStatusAreaAnim = null;
}
});
mStatusAreaAnim.start();
}
/**
@@ -352,10 +344,6 @@ public class KeyguardClockSwitch extends RelativeLayout {
}
}
void setSmartspaceView(View smartspaceView) {
mSmartspaceView = smartspaceView;
}
void updateColors(ColorExtractor.GradientColors colors) {
mSupportsDarkText = colors.supportsDarkText();
mColorPalette = colors.getColorPalette();
@@ -369,8 +357,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
pw.println(" mClockPlugin: " + mClockPlugin);
pw.println(" mClockFrame: " + mClockFrame);
pw.println(" mLargeClockFrame: " + mLargeClockFrame);
pw.println(" mKeyguardStatusArea: " + mKeyguardStatusArea);
pw.println(" mSmartspaceView: " + mSmartspaceView);
pw.println(" mStatusArea: " + mStatusArea);
pw.println(" mDarkAmount: " + mDarkAmount);
pw.println(" mSupportsDarkText: " + mSupportsDarkText);
pw.println(" mColorPalette: " + Arrays.toString(mColorPalette));

View File

@@ -25,7 +25,9 @@ import android.app.WallpaperManager;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.android.internal.colorextraction.ColorExtractor;
@@ -99,7 +101,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
// If set, will replace keyguard_status_area
private ViewGroup mStatusArea;
// If set will replace keyguard_slice_view
private View mSmartspaceView;
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
@@ -191,8 +194,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin);
if (mOnlyClock) {
View ksa = mView.findViewById(R.id.keyguard_status_area);
ksa.setVisibility(View.GONE);
View ksv = mView.findViewById(R.id.keyguard_slice_view);
ksv.setVisibility(View.GONE);
View nic = mView.findViewById(
R.id.left_aligned_notification_icon_container);
@@ -201,19 +204,18 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
updateAodIcons();
mStatusArea = mView.findViewById(R.id.keyguard_status_area);
if (mSmartspaceController.isEnabled()) {
mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
View ksv = mView.findViewById(R.id.keyguard_slice_view);
int ksvIndex = mStatusArea.indexOfChild(ksv);
ksv.setVisibility(View.GONE);
View ksa = mView.findViewById(R.id.keyguard_status_area);
int ksaIndex = mView.indexOfChild(ksa);
ksa.setVisibility(View.GONE);
// Place smartspace view below normal clock...
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
MATCH_PARENT, WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view);
mView.addView(mSmartspaceView, ksaIndex, lp);
mStatusArea.addView(mSmartspaceView, ksvIndex, lp);
int startPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.below_clock_padding_start);
int endPadding = getContext().getResources()
@@ -221,14 +223,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0);
updateClockLayout();
View nic = mView.findViewById(
R.id.left_aligned_notification_icon_container);
lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
nic.setLayoutParams(lp);
mView.setSmartspaceView(mSmartspaceView);
mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceView);
}
}
@@ -244,8 +238,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
mView.setClockPlugin(null, mStatusBarStateController.getState());
mSmartspaceController.disconnect();
}
/**
@@ -328,8 +320,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
scale, props, animate);
if (mSmartspaceView != null) {
PropertyAnimator.setProperty(mSmartspaceView, AnimatableProperty.TRANSLATION_X,
if (mStatusArea != null) {
PropertyAnimator.setProperty(mStatusArea, AnimatableProperty.TRANSLATION_X,
x, props, animate);
// If we're unlocking with the SmartSpace shared element transition, let the controller
@@ -340,7 +332,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
mKeyguardSliceViewController.updatePosition(x, props, animate);
mNotificationIconAreaController.updatePosition(x, props, animate);
}
/** Sets an alpha value on every child view except for the smartspace. */

View File

@@ -33,12 +33,10 @@ import android.os.Trace;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.slice.SliceItem;
@@ -85,8 +83,6 @@ public class KeyguardSliceView extends LinearLayout {
private boolean mHasHeader;
private View.OnClickListener mOnClickListener;
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
public KeyguardSliceView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -136,35 +132,6 @@ public class KeyguardSliceView extends LinearLayout {
}
}
/**
* Updates the lockscreen mode which may change the layout of the keyguard slice view.
*/
public void updateLockScreenMode(int mode) {
mLockScreenMode = mode;
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
mTitle.setPaddingRelative(0, 0, 0, 0);
mTitle.setGravity(Gravity.START);
setGravity(Gravity.START);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
lp.removeRule(RelativeLayout.CENTER_HORIZONTAL);
setLayoutParams(lp);
} else {
final int horizontalPaddingDpValue = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
44,
getResources().getDisplayMetrics()
);
mTitle.setPaddingRelative(horizontalPaddingDpValue, 0, horizontalPaddingDpValue, 0);
mTitle.setGravity(Gravity.CENTER_HORIZONTAL);
setGravity(Gravity.CENTER_HORIZONTAL);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
setLayoutParams(lp);
}
mRow.setLockscreenMode(mode);
requestLayout();
}
Map<View, PendingIntent> showSlice(RowContent header, List<SliceContent> subItems) {
Trace.beginSection("KeyguardSliceView#showSlice");
mHasHeader = header != null;
@@ -189,8 +156,7 @@ public class KeyguardSliceView extends LinearLayout {
final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it
mRow.setVisibility(subItemsCount > 0 ? VISIBLE : GONE);
LinearLayout.LayoutParams layoutParams = (LayoutParams) mRow.getLayoutParams();
layoutParams.gravity = mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL
? Gravity.START : Gravity.CENTER;
layoutParams.gravity = Gravity.START;
mRow.setLayoutParams(layoutParams);
for (int i = startIndex; i < subItemsCount; i++) {
@@ -224,8 +190,7 @@ public class KeyguardSliceView extends LinearLayout {
final int iconSize = mHasHeader ? mIconSizeWithHeader : mIconSize;
iconDrawable = icon.getIcon().loadDrawable(mContext);
if (iconDrawable != null) {
if ((iconDrawable instanceof InsetDrawable)
&& mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
if (iconDrawable instanceof InsetDrawable) {
// System icons (DnD) use insets which are fine for centered slice content
// but will cause a slight indent for left/right-aligned slice views
iconDrawable = ((InsetDrawable) iconDrawable).getDrawable();
@@ -321,7 +286,6 @@ public class KeyguardSliceView extends LinearLayout {
pw.println(" mTextColor: " + Integer.toHexString(mTextColor));
pw.println(" mDarkAmount: " + mDarkAmount);
pw.println(" mHasHeader: " + mHasHeader);
pw.println(" mLockScreenMode: " + mLockScreenMode);
}
@Override
@@ -332,7 +296,6 @@ public class KeyguardSliceView extends LinearLayout {
public static class Row extends LinearLayout {
private Set<KeyguardSliceTextView> mKeyguardSliceTextViewSet = new HashSet();
private int mLockScreenModeRow = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
/**
* This view is visible in AOD, which means that the device will sleep if we
@@ -407,11 +370,7 @@ public class KeyguardSliceView extends LinearLayout {
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child instanceof KeyguardSliceTextView) {
if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE);
} else {
((KeyguardSliceTextView) child).setMaxWidth(width / 3);
}
((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE);
}
}
@@ -443,7 +402,6 @@ public class KeyguardSliceView extends LinearLayout {
super.addView(view, index);
if (view instanceof KeyguardSliceTextView) {
((KeyguardSliceTextView) view).setLockScreenMode(mLockScreenModeRow);
mKeyguardSliceTextViewSet.add((KeyguardSliceTextView) view);
}
}
@@ -455,24 +413,6 @@ public class KeyguardSliceView extends LinearLayout {
mKeyguardSliceTextViewSet.remove((KeyguardSliceTextView) view);
}
}
/**
* Updates the lockscreen mode which may change the layout of this view.
*/
public void setLockscreenMode(int mode) {
mLockScreenModeRow = mode;
if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
setOrientation(LinearLayout.VERTICAL);
setGravity(Gravity.START);
} else {
setOrientation(LinearLayout.HORIZONTAL);
setGravity(Gravity.CENTER);
}
for (KeyguardSliceTextView textView : mKeyguardSliceTextViewSet) {
textView.setLockScreenMode(mLockScreenModeRow);
}
}
}
/**
@@ -480,7 +420,6 @@ public class KeyguardSliceView extends LinearLayout {
*/
@VisibleForTesting
static class KeyguardSliceTextView extends TextView {
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
@StyleRes
private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary;
@@ -509,13 +448,8 @@ public class KeyguardSliceView extends LinearLayout {
boolean hasText = !TextUtils.isEmpty(getText());
int padding = (int) getContext().getResources()
.getDimension(R.dimen.widget_horizontal_padding) / 2;
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
// orientation is vertical, so add padding to top & bottom
setPadding(0, padding, 0, hasText ? padding : 0);
} else {
// orientation is horizontal, so add padding to left & right
setPadding(padding, 0, padding * (hasText ? 1 : -1), 0);
}
// orientation is vertical, so add padding to top & bottom
setPadding(0, padding, 0, hasText ? padding : 0);
setCompoundDrawablePadding((int) mContext.getResources()
.getDimension(R.dimen.widget_icon_padding));
@@ -543,18 +477,5 @@ public class KeyguardSliceView extends LinearLayout {
}
}
}
/**
* Updates the lockscreen mode which may change the layout of this view.
*/
public void setLockScreenMode(int mode) {
mLockScreenMode = mode;
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
} else {
setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
}
updatePadding();
}
}
}

View File

@@ -73,7 +73,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
private Uri mKeyguardSliceUri;
private Slice mSlice;
private Map<View, PendingIntent> mClickActions;
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue);
@@ -137,7 +136,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
TAG + "@" + Integer.toHexString(
KeyguardSliceViewController.this.hashCode()),
KeyguardSliceViewController.this);
mView.updateLockScreenMode(mLockScreenMode);
}
@Override
@@ -159,14 +157,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
mView.setLayoutParams(lp);
}
/**
* Updates the lockscreen mode which may change the layout of the keyguard slice view.
*/
public void updateLockScreenMode(int mode) {
mLockScreenMode = mode;
mView.updateLockScreenMode(mLockScreenMode);
}
/**
* Sets the slice provider Uri.
*/
@@ -249,6 +239,5 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
pw.println(" mSlice: " + mSlice);
pw.println(" mClickActions: " + mClickActions);
pw.println(" mLockScreenMode: " + mLockScreenMode);
}
}

View File

@@ -88,7 +88,7 @@ public class KeyguardStatusView extends GridLayout {
mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext));
}
mKeyguardSlice = findViewById(R.id.keyguard_status_area);
mKeyguardSlice = findViewById(R.id.keyguard_slice_view);
mTextColor = mClockView.getCurrentTextColor();
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);

View File

@@ -248,11 +248,6 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
};
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onLockScreenModeChanged(int mode) {
mKeyguardSliceViewController.updateLockScreenMode(mode);
}
@Override
public void onTimeChanged() {
refreshTime();

View File

@@ -188,9 +188,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private static final int MSG_TIME_FORMAT_UPDATE = 344;
private static final int MSG_REQUIRE_NFC_UNLOCK = 345;
public static final int LOCK_SCREEN_MODE_NORMAL = 0;
public static final int LOCK_SCREEN_MODE_LAYOUT_1 = 1;
/** Biometric authentication state: Not listening. */
private static final int BIOMETRIC_STATE_STOPPED = 0;
@@ -1867,9 +1864,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
case MSG_KEYGUARD_GOING_AWAY:
handleKeyguardGoingAway((boolean) msg.obj);
break;
case MSG_LOCK_SCREEN_MODE:
handleLockScreenMode();
break;
case MSG_TIME_FORMAT_UPDATE:
handleTimeFormatUpdate((String) msg.obj);
break;
@@ -2011,8 +2005,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
}
}
updateLockScreenMode(featureFlags.isKeyguardLayoutEnabled());
mTimeFormatChangeObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
@@ -2028,14 +2020,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
false, mTimeFormatChangeObserver, UserHandle.USER_ALL);
}
private void updateLockScreenMode(boolean isEnabled) {
final int newMode = isEnabled ? LOCK_SCREEN_MODE_LAYOUT_1 : LOCK_SCREEN_MODE_NORMAL;
if (newMode != mLockScreenMode) {
mLockScreenMode = newMode;
mHandler.sendEmptyMessage(MSG_LOCK_SCREEN_MODE);
}
}
private void updateUdfpsEnrolled(int userId) {
mIsUdfpsEnrolled = mAuthController.isUdfpsEnrolled(userId);
}
@@ -2665,20 +2649,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
}
}
/**
* Handle {@link #MSG_LOCK_SCREEN_MODE}
*/
private void handleLockScreenMode() {
Assert.isMainThread();
if (DEBUG) Log.d(TAG, "handleLockScreenMode(" + mLockScreenMode + ")");
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onLockScreenModeChanged(mLockScreenMode);
}
}
}
/**
* Handle (@line #MSG_TIMEZONE_UPDATE}
*/
@@ -3057,7 +3027,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
callback.onKeyguardOccludedChanged(mKeyguardOccluded);
callback.onKeyguardVisibilityChangedRaw(mKeyguardIsVisible);
callback.onTelephonyCapable(mTelephonyCapable);
callback.onLockScreenModeChanged(mLockScreenMode);
for (Entry<Integer, SimData> data : mSimDatas.entrySet()) {
final SimData state = data.getValue();

View File

@@ -324,11 +324,6 @@ public class KeyguardUpdateMonitorCallback {
*/
public void onSecondaryLockscreenRequirementChanged(int userId) { }
/**
* Called to switch lock screen layout/clock layouts
*/
public void onLockScreenModeChanged(int mode) { }
/**
* Called when notifying user to unlock in order to use NFC.
*/

View File

@@ -34,6 +34,6 @@ public abstract class KeyguardStatusViewModule {
@Provides
static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) {
return keyguardClockSwitch.findViewById(R.id.keyguard_status_area);
return keyguardClockSwitch.findViewById(R.id.keyguard_slice_view);
}
}

View File

@@ -132,10 +132,6 @@ public class FeatureFlags {
return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2_rendering);
}
public boolean isKeyguardLayoutEnabled() {
return mFlagReader.isEnabled(R.bool.flag_keyguard_layout);
}
/** */
public boolean useNewLockscreenAnimations() {
return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations);

View File

@@ -147,7 +147,6 @@ public class KeyguardIndicationController {
private boolean mBatteryPresent = true;
private long mChargingTimeRemaining;
private String mMessageToShowOnScreenOn;
protected int mLockScreenMode;
private boolean mInited;
private KeyguardUpdateMonitorCallback mUpdateMonitorCallback;
@@ -862,11 +861,6 @@ public class KeyguardIndicationController {
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
public static final int HIDE_DELAY_MS = 5000;
@Override
public void onLockScreenModeChanged(int mode) {
mLockScreenMode = mode;
}
@Override
public void onRefreshBatteryInfo(BatteryStatus status) {
boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING

View File

@@ -29,6 +29,7 @@ import android.net.Uri
import android.os.Handler
import android.os.UserHandle
import android.provider.Settings
import android.util.Log
import android.view.View
import android.view.ViewGroup
import com.android.settingslib.Utils
@@ -73,6 +74,10 @@ class LockscreenSmartspaceController @Inject constructor(
@Main private val handler: Handler,
optionalPlugin: Optional<BcSmartspaceDataPlugin>
) {
companion object {
private const val TAG = "LockscreenSmartspaceController"
}
private var session: SmartspaceSession? = null
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
@@ -210,6 +215,7 @@ class LockscreenSmartspaceController @Inject constructor(
val newSession = smartspaceManager.createSmartspaceSession(
SmartspaceConfig.Builder(context, "lockscreen").build())
Log.d(TAG, "Starting smartspace session for lockscreen")
newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener)
this.session = newSession
@@ -231,6 +237,8 @@ class LockscreenSmartspaceController @Inject constructor(
* Disconnects the smartspace view from the smartspace service and cleans up any resources.
*/
fun disconnect() {
if (!smartspaceViews.isEmpty()) return
execution.assertIsMainThread()
if (session == null) {
@@ -248,6 +256,7 @@ class LockscreenSmartspaceController @Inject constructor(
session = null
plugin?.onTargetsAvailable(emptyList())
Log.d(TAG, "Ending smartspace session for lockscreen")
}
fun addListener(listener: SmartspaceTargetListener) {

View File

@@ -19,7 +19,6 @@ package com.android.keyguard;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -30,6 +29,7 @@ import android.content.res.Resources;
import android.testing.AndroidTestingRunner;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import androidx.test.filters.SmallTest;
@@ -108,7 +108,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
private final View mFakeSmartspaceView = new View(mContext);
private KeyguardClockSwitchController mController;
private View mStatusArea;
private View mSliceView;
@Before
public void setup() {
@@ -149,8 +149,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);
mStatusArea = new View(getContext());
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea);
mSliceView = new View(getContext());
when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView);
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(
new LinearLayout(getContext()));
}
@Test
@@ -215,7 +217,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
assertEquals(View.GONE, mStatusArea.getVisibility());
assertEquals(View.GONE, mSliceView.getVisibility());
}
@Test
@@ -223,22 +225,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
when(mSmartspaceController.isEnabled()).thenReturn(false);
mController.init();
assertEquals(View.VISIBLE, mStatusArea.getVisibility());
}
@Test
public void testDetachDisconnectsSmartspace() {
when(mSmartspaceController.isEnabled()).thenReturn(true);
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
verify(mView).addView(eq(mFakeSmartspaceView), anyInt(), any());
ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView);
verify(mSmartspaceController).disconnect();
assertEquals(View.VISIBLE, mSliceView.getVisibility());
}
@Test

View File

@@ -54,7 +54,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
mKeyguardSliceView = (KeyguardSliceView) layoutInflater
.inflate(R.layout.keyguard_status_area, null);
.inflate(R.layout.keyguard_slice_view, null);
mSliceUri = Uri.parse(KeyguardSliceProvider.KEYGUARD_SLICE_URI);
SliceProvider.setSpecs(new HashSet<>(Collections.singletonList(SliceSpecs.LIST)));
}

View File

@@ -239,8 +239,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);
when(mFeatureFlags.isKeyguardLayoutEnabled()).thenReturn(false);
mMockitoSession = ExtendedMockito.mockitoSession()
.spyStatic(SubscriptionManager.class).startMocking();
ExtendedMockito.doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID)

View File

@@ -246,6 +246,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
clearInvocations(plugin)
// WHEN the session is closed
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
controller.disconnect()
// THEN the listener receives an empty list of targets
@@ -417,6 +418,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
connectSession()
// WHEN we are told to cleanup
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
controller.disconnect()
// THEN we disconnect from the session and unregister any listeners