diff options
3 files changed, 57 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 32c930132977..543949768f05 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -63,6 +63,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; import android.widget.TextView; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; @@ -228,6 +229,11 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } }; + public void initFrom(KeyguardBottomAreaView oldBottomArea) { + setKeyguardIndicationController(oldBottomArea.mIndicationController); + setStatusBar(oldBottomArea.mStatusBar); + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -578,7 +584,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } } - private void launchVoiceAssist() { + @VisibleForTesting + void launchVoiceAssist() { Runnable runnable = new Runnable() { @Override public void run() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 5ee08237e228..31facb79045e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -467,10 +467,12 @@ public class NotificationPanelView extends PanelView implements // Update keyguard bottom area index = indexOfChild(mKeyguardBottomArea); removeView(mKeyguardBottomArea); + KeyguardBottomAreaView oldBottomArea = mKeyguardBottomArea; mKeyguardBottomArea = (KeyguardBottomAreaView) LayoutInflater.from(mContext).inflate( R.layout.keyguard_bottom_area, this, false); + mKeyguardBottomArea.initFrom(oldBottomArea); addView(mKeyguardBottomArea, index); initBottomArea(); setDarkAmount(mLinearDarkAmount, mInterpolatedDarkAmount); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt new file mode 100644 index 000000000000..96f1976f2b20 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaTest.kt @@ -0,0 +1,47 @@ +package com.android.systemui.statusbar.phone + +import android.support.test.filters.SmallTest +import android.testing.AndroidTestingRunner +import android.testing.TestableLooper +import android.view.LayoutInflater + +import com.android.systemui.R +import com.android.systemui.SysuiTestCase +import com.android.systemui.statusbar.KeyguardIndicationController + +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) +@TestableLooper.RunWithLooper +class KeyguardBottomAreaTest : SysuiTestCase() { + + @Mock + private lateinit var mStatusBar: StatusBar + @Mock + private lateinit var mKeyguardIndicationController: KeyguardIndicationController + private lateinit var mKeyguardBottomArea: KeyguardBottomAreaView + + @Before + fun setup() { + MockitoAnnotations.initMocks(this) + mKeyguardBottomArea = LayoutInflater.from(mContext).inflate( + R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView + mKeyguardBottomArea.setStatusBar(mStatusBar) + mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController) + } + + @Test + fun initFrom_doesntCrash() { + val other = LayoutInflater.from(mContext).inflate( + R.layout.keyguard_bottom_area, null, false) as KeyguardBottomAreaView + + other.initFrom(mKeyguardBottomArea) + other.launchVoiceAssist() + other.onLongClick(null) + } +}
\ No newline at end of file |