Revert "8/N Remove View Injection from KeyguardMessageArea"

Revert submission 12585643-b166448040-keyguard-message-area

Reason for revert: http://b/169081305 & http://b/169020145
Reverted Changes:
I6fa05012c:4/N Setup Controller fo KeyguardSecurityContainer....
Iecf265744:5/N Add KeyguardSecurityViewFlipperController.
I90ab99b2f:6/N Add Controller for KeyguardPatternView
I4b74eddd1:7/N controllers for remaining Keyguard Password Vi...
I805286374:8/N Remove View Injection from KeyguardMessageArea...
I362755980:9/N Clean Up Keyguard Class Structure

Change-Id: Ie84234cb8ae9eaae6ec52900cb215ddf6e6213f1
Fixes: 169081305
Fixes: 169020145
This commit is contained in:
Dave Mankoff
2020-09-22 00:24:04 +00:00
parent b00c929394
commit dd7312c20a
14 changed files with 145 additions and 180 deletions

View File

@@ -81,12 +81,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
abstract void resetState();
@Override
public void init() {
super.init();
mMessageAreaController.init();
}
@Override
protected void onViewAttached() {
mView.setKeyDownListener(mKeyDownListener);

View File

@@ -39,6 +39,7 @@ import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.navigationbar.NavigationBarController;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.util.InjectionInflationController;
import javax.inject.Inject;
@@ -48,6 +49,7 @@ public class KeyguardDisplayManager {
private final MediaRouter mMediaRouter;
private final DisplayManager mDisplayService;
private final InjectionInflationController mInjectableInflater;
private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
private final Context mContext;
@@ -90,8 +92,10 @@ public class KeyguardDisplayManager {
@Inject
public KeyguardDisplayManager(Context context,
InjectionInflationController injectableInflater,
KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory) {
mContext = context;
mInjectableInflater = injectableInflater;
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
mMediaRouter = mContext.getSystemService(MediaRouter.class);
mDisplayService = mContext.getSystemService(DisplayManager.class);
@@ -127,7 +131,8 @@ public class KeyguardDisplayManager {
Presentation presentation = mPresentations.get(displayId);
if (presentation == null) {
final Presentation newPresentation = new KeyguardPresentation(mContext, display,
mKeyguardStatusViewComponentFactory, LayoutInflater.from(mContext));
mKeyguardStatusViewComponentFactory,
mInjectableInflater.injectable(LayoutInflater.from(mContext)));
newPresentation.setOnDismissListener(dialog -> {
if (newPresentation.equals(mPresentations.get(displayId))) {
mPresentations.remove(displayId);
@@ -245,7 +250,7 @@ public class KeyguardDisplayManager {
private static final int VIDEO_SAFE_REGION = 80; // Percentage of display width & height
private static final int MOVE_CLOCK_TIMEOUT = 10000; // 10s
private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
private final LayoutInflater mLayoutInflater;
private final LayoutInflater mInjectableLayoutInflater;
private KeyguardClockSwitchController mKeyguardClockSwitchController;
private View mClock;
private int mUsableWidth;
@@ -265,10 +270,10 @@ public class KeyguardDisplayManager {
KeyguardPresentation(Context context, Display display,
KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory,
LayoutInflater layoutInflater) {
LayoutInflater injectionLayoutInflater) {
super(context, display, R.style.Theme_SystemUI_KeyguardPresentation);
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
mLayoutInflater = layoutInflater;
mInjectableLayoutInflater = injectionLayoutInflater;
getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
setCancelable(false);
}
@@ -294,7 +299,7 @@ public class KeyguardDisplayManager {
mMarginLeft = (100 - VIDEO_SAFE_REGION) * p.x / 200;
mMarginTop = (100 - VIDEO_SAFE_REGION) * p.y / 200;
setContentView(mLayoutInflater.inflate(R.layout.keyguard_presentation, null));
setContentView(mInjectableLayoutInflater.inflate(R.layout.keyguard_presentation, null));
// Logic to make the lock screen fullscreen
getWindow().getDecorView().setSystemUiVisibility(

View File

@@ -16,6 +16,8 @@
package com.android.keyguard;
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
@@ -29,14 +31,20 @@ import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ConfigurationController;
import java.lang.ref.WeakReference;
import javax.inject.Inject;
import javax.inject.Named;
/***
* Manages a number of views inside of the given layout. See below for a list of widgets.
*/
public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay {
public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay,
ConfigurationController.ConfigurationListener {
/** Handler token posted with accessibility announcement runnables. */
private static final Object ANNOUNCE_TOKEN = new Object();
@@ -48,26 +56,71 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
private static final int DEFAULT_COLOR = -1;
private final Handler mHandler;
private final ConfigurationController mConfigurationController;
private ColorStateList mDefaultColorState;
private CharSequence mMessage;
private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR);
private boolean mBouncerVisible;
public KeyguardMessageArea(Context context, AttributeSet attrs) {
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
public void onFinishedGoingToSleep(int why) {
setSelected(false);
}
public void onStartedWakingUp() {
setSelected(true);
}
@Override
public void onKeyguardBouncerChanged(boolean bouncer) {
mBouncerVisible = bouncer;
update();
}
};
public KeyguardMessageArea(Context context) {
super(context, null);
throw new IllegalStateException("This constructor should never be invoked");
}
@Inject
public KeyguardMessageArea(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs,
ConfigurationController configurationController) {
this(context, attrs, Dependency.get(KeyguardUpdateMonitor.class), configurationController);
}
public KeyguardMessageArea(Context context, AttributeSet attrs, KeyguardUpdateMonitor monitor,
ConfigurationController configurationController) {
super(context, attrs);
setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug
monitor.registerCallback(mInfoCallback);
mHandler = new Handler(Looper.myLooper());
mConfigurationController = configurationController;
onThemeChanged();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mConfigurationController.addCallback(this);
onThemeChanged();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mConfigurationController.removeCallback(this);
}
@Override
public void setNextMessageColor(ColorStateList colorState) {
mNextMessageColorState = colorState;
}
void onThemeChanged() {
@Override
public void onThemeChanged() {
TypedArray array = mContext.obtainStyledAttributes(new int[] {
R.attr.wallpaperTextColor
});
@@ -77,7 +130,8 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
update();
}
void onDensityOrFontScaleChanged() {
@Override
public void onDensityOrFontScaleChanged() {
TypedArray array = mContext.obtainStyledAttributes(R.style.Keyguard_TextView, new int[] {
android.R.attr.textSize
});
@@ -123,6 +177,12 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
return messageArea;
}
@Override
protected void onFinishInflate() {
boolean shouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive();
setSelected(shouldMarquee); // This is required to ensure marquee works
}
private void securityMessageChanged(CharSequence message) {
mMessage = message;
update();
@@ -136,7 +196,7 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
update();
}
void update() {
private void update() {
CharSequence status = mMessage;
setVisibility(TextUtils.isEmpty(status) || !mBouncerVisible ? INVISIBLE : VISIBLE);
setText(status);
@@ -148,9 +208,6 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp
setTextColor(colorState);
}
public void setBouncerVisible(boolean bouncerVisible) {
mBouncerVisible = bouncerVisible;
}
/**
* Runnable used to delay accessibility announcements.

View File

@@ -19,7 +19,6 @@ package com.android.keyguard;
import android.content.res.ColorStateList;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.util.ViewController;
import javax.inject.Inject;
@@ -29,35 +28,6 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final ConfigurationController mConfigurationController;
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
public void onFinishedGoingToSleep(int why) {
mView.setSelected(false);
}
public void onStartedWakingUp() {
mView.setSelected(true);
}
@Override
public void onKeyguardBouncerChanged(boolean bouncer) {
mView.setBouncerVisible(bouncer);
mView.update();
}
};
private ConfigurationListener mConfigurationListener = new ConfigurationListener() {
@Override
public void onThemeChanged() {
mView.onThemeChanged();
}
@Override
public void onDensityOrFontScaleChanged() {
mView.onDensityOrFontScaleChanged();
}
};
private KeyguardMessageAreaController(KeyguardMessageArea view,
KeyguardUpdateMonitor keyguardUpdateMonitor,
ConfigurationController configurationController) {
@@ -69,16 +39,10 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
@Override
protected void onViewAttached() {
mConfigurationController.addCallback(mConfigurationListener);
mKeyguardUpdateMonitor.registerCallback(mInfoCallback);
mView.setSelected(mKeyguardUpdateMonitor.isDeviceInteractive());
mView.onThemeChanged();
}
@Override
protected void onViewDetached() {
mConfigurationController.removeCallback(mConfigurationListener);
mKeyguardUpdateMonitor.removeCallback(mInfoCallback);
}
public void setMessage(CharSequence s) {

View File

@@ -190,12 +190,6 @@ public class KeyguardPatternViewController
mLockPatternView = mView.findViewById(R.id.lockPatternView);
}
@Override
public void init() {
super.init();
mMessageAreaController.init();
}
@Override
protected void onViewAttached() {
mLockPatternView.setOnPatternListener(new UnlockPatternListener());

View File

@@ -26,6 +26,7 @@ import com.android.keyguard.KeyguardInputViewController.Factory;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.keyguard.dagger.KeyguardBouncerScope;
import com.android.systemui.R;
import com.android.systemui.util.InjectionInflationController;
import com.android.systemui.util.ViewController;
import java.util.ArrayList;
@@ -50,10 +51,11 @@ public class KeyguardSecurityViewFlipperController
@Inject
protected KeyguardSecurityViewFlipperController(KeyguardSecurityViewFlipper view,
LayoutInflater layoutInflater,
InjectionInflationController injectionInflationController,
KeyguardInputViewController.Factory keyguardSecurityViewControllerFactory) {
super(view);
mKeyguardSecurityViewControllerFactory = keyguardSecurityViewControllerFactory;
mLayoutInflater = layoutInflater;
mLayoutInflater = injectionInflationController.injectable(layoutInflater);
}
@Override

View File

@@ -23,6 +23,7 @@ import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.android.keyguard.KeyguardMessageArea;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.qs.QSFooterImpl;
import com.android.systemui.qs.QSPanel;
@@ -106,6 +107,11 @@ public class InjectionInflationController {
*/
NotificationStackScrollLayout createNotificationStackScrollLayout();
/**
* Creates the KeyguardMessageArea.
*/
KeyguardMessageArea createKeyguardMessageArea();
/**
* Creates the QSPanel.
*/

View File

@@ -19,7 +19,6 @@ package com.android.keyguard;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@@ -95,7 +94,6 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
}
};
mKeyguardAbsKeyInputViewController.init();
reset(mKeyguardMessageAreaController); // Clear out implicit call to init.
}
@Test

View File

@@ -41,9 +41,11 @@ import android.widget.FrameLayout;
import android.widget.TextClock;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
import org.junit.Test;
@@ -76,7 +78,12 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
when(mMockKeyguardSliceView.findViewById(R.id.keyguard_status_area))
.thenReturn(mMockKeyguardSliceView);
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
InjectionInflationController inflationController = new InjectionInflationController(
SystemUIFactory.getInstance()
.getSysUIComponent()
.createViewInstanceCreatorFactory());
LayoutInflater layoutInflater = inflationController
.injectable(LayoutInflater.from(getContext()));
layoutInflater.setPrivateFactory(new LayoutInflater.Factory2() {
@Override

View File

@@ -1,87 +0,0 @@
/*
* 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.ArgumentMatchers.eq;
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.ConfigurationController.ConfigurationListener;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class KeyguardMessageAreaControllerTest extends SysuiTestCase {
@Mock
private ConfigurationController mConfigurationController;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
private KeyguardMessageArea mKeyguardMessageArea;
private KeyguardMessageAreaController mMessageAreaController;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mMessageAreaController = new KeyguardMessageAreaController.Factory(
mKeyguardUpdateMonitor, mConfigurationController).create(mKeyguardMessageArea);
}
@Test
public void onAttachedToWindow_registersConfigurationCallback() {
ArgumentCaptor<ConfigurationListener> configurationListenerArgumentCaptor =
ArgumentCaptor.forClass(ConfigurationListener.class);
mMessageAreaController.onViewAttached();
verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture());
mMessageAreaController.onViewDetached();
verify(mConfigurationController).removeCallback(
eq(configurationListenerArgumentCaptor.getValue()));
}
@Test
public void onAttachedToWindow_registersKeyguardUpdateMontiorCallback() {
ArgumentCaptor<KeyguardUpdateMonitorCallback> keyguardUpdateMonitorCallbackArgumentCaptor =
ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback.class);
mMessageAreaController.onViewAttached();
verify(mKeyguardUpdateMonitor).registerCallback(
keyguardUpdateMonitorCallbackArgumentCaptor.capture());
mMessageAreaController.onViewDetached();
verify(mKeyguardUpdateMonitor).removeCallback(
eq(keyguardUpdateMonitorCallbackArgumentCaptor.getValue()));
}
@Test
public void testClearsTextField() {
mMessageAreaController.setMessage("");
verify(mKeyguardMessageArea).setMessage("");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 The Android Open Source Project
* Copyright (C) 2016 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.
@@ -11,60 +11,65 @@
* 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.
* limitations under the License
*/
package com.android.keyguard;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.policy.ConfigurationController;
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)
@RunWithLooper
public class KeyguardMessageAreaTest extends SysuiTestCase {
private KeyguardMessageArea mKeyguardMessageArea;
@Mock
private ConfigurationController mConfigurationController;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private KeyguardMessageArea mMessageArea;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mKeyguardMessageArea = new KeyguardMessageArea(mContext, null);
mKeyguardMessageArea.setBouncerVisible(true);
mMessageArea = new KeyguardMessageArea(mContext, null, mKeyguardUpdateMonitor,
mConfigurationController);
waitForIdleSync();
}
@Test
public void testShowsTextField() {
mKeyguardMessageArea.setVisibility(View.INVISIBLE);
mKeyguardMessageArea.setMessage("oobleck");
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck");
public void onAttachedToWindow_registersConfigurationCallback() {
mMessageArea.onAttachedToWindow();
verify(mConfigurationController).addCallback(eq(mMessageArea));
mMessageArea.onDetachedFromWindow();
verify(mConfigurationController).removeCallback(eq(mMessageArea));
}
@Test
public void testHiddenWhenBouncerHidden() {
mKeyguardMessageArea.setBouncerVisible(false);
mKeyguardMessageArea.setVisibility(View.INVISIBLE);
mKeyguardMessageArea.setMessage("oobleck");
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE);
assertThat(mKeyguardMessageArea.getText()).isEqualTo("oobleck");
public void clearFollowedByMessage_keepsMessage() {
mMessageArea.setMessage("");
mMessageArea.setMessage("test");
CharSequence[] messageText = new CharSequence[1];
messageText[0] = mMessageArea.getText();
assertEquals("test", messageText[0]);
}
@Test
public void testClearsTextField() {
mKeyguardMessageArea.setVisibility(View.VISIBLE);
mKeyguardMessageArea.setMessage("");
assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE);
assertThat(mKeyguardMessageArea.getText()).isEqualTo("");
}
}

View File

@@ -31,7 +31,9 @@ import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardDisplayManager.KeyguardPresentation;
import com.android.keyguard.dagger.KeyguardStatusViewComponent;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.util.InjectionInflationController;
import org.junit.After;
import org.junit.Before;
@@ -63,6 +65,7 @@ public class KeyguardPresentationTest extends SysuiTestCase {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
when(mMockKeyguardClockSwitch.getContext()).thenReturn(mContext);
when(mMockKeyguardSliceView.getContext()).thenReturn(mContext);
when(mMockKeyguardStatusView.getContext()).thenReturn(mContext);
@@ -74,7 +77,11 @@ public class KeyguardPresentationTest extends SysuiTestCase {
allowTestableLooperAsMainThread();
mLayoutInflater = LayoutInflater.from(mContext);
InjectionInflationController inflationController = new InjectionInflationController(
SystemUIFactory.getInstance()
.getSysUIComponent()
.createViewInstanceCreatorFactory());
mLayoutInflater = inflationController.injectable(LayoutInflater.from(mContext));
mLayoutInflater.setPrivateFactory(new LayoutInflater.Factory2() {
@Override

View File

@@ -35,6 +35,7 @@ import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
import org.junit.Rule;
@@ -57,6 +58,8 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
@Mock
private LayoutInflater mLayoutInflater;
@Mock
private InjectionInflationController mInjectionInflationController;
@Mock
private KeyguardInputViewController.Factory mKeyguardSecurityViewControllerFactory;
@Mock
private KeyguardInputViewController mKeyguardInputViewController;
@@ -71,6 +74,7 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
@Before
public void setup() {
when(mInjectionInflationController.injectable(mLayoutInflater)).thenReturn(mLayoutInflater);
when(mKeyguardSecurityViewControllerFactory.create(
any(KeyguardInputView.class), any(SecurityMode.class),
any(KeyguardSecurityCallback.class)))
@@ -78,7 +82,8 @@ public class KeyguardSecurityViewFlipperControllerTest extends SysuiTestCase {
when(mView.getWindowInsetsController()).thenReturn(mWindowInsetsController);
mKeyguardSecurityViewFlipperController = new KeyguardSecurityViewFlipperController(mView,
mLayoutInflater, mKeyguardSecurityViewControllerFactory);
mLayoutInflater, mInjectionInflationController,
mKeyguardSecurityViewControllerFactory);
}
@Test

View File

@@ -24,7 +24,9 @@ import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.util.InjectionInflationController;
import org.junit.Before;
import org.junit.Test;
@@ -48,7 +50,13 @@ public class KeyguardStatusViewTest extends SysuiTestCase {
@Before
public void setUp() {
allowTestableLooperAsMainThread();
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
InjectionInflationController inflationController = new InjectionInflationController(
SystemUIFactory.getInstance()
.getSysUIComponent()
.createViewInstanceCreatorFactory());
LayoutInflater layoutInflater = inflationController
.injectable(LayoutInflater.from(getContext()));
mKeyguardStatusView =
(KeyguardStatusView) layoutInflater.inflate(R.layout.keyguard_status_view, null);
org.mockito.MockitoAnnotations.initMocks(this);