Make KeyguardPresentation inherit Theme.SystemUI

Theme.SystemUI has some attrs that aren't present on Theme.Material
and SysUI views are expected to use them.

Fixes: 133597861
Test: cast to secondary screen, go to keyguard
Test: atest KeyguardPresentationTest
Change-Id: I756dfc6db73090a6ebe1db4b1cd1bc775b6c47c2
diff --git a/packages/SystemUI/res-keyguard/values/styles.xml b/packages/SystemUI/res-keyguard/values/styles.xml
index bcdcb3b..9a04222 100644
--- a/packages/SystemUI/res-keyguard/values/styles.xml
+++ b/packages/SystemUI/res-keyguard/values/styles.xml
@@ -103,9 +103,12 @@
         <item name="android:colorControlActivated">?attr/wallpaperTextColor</item>
     </style>
 
-    <style name="keyguard_presentation_theme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
-        <item name="wallpaperTextColor">@*android:color/primary_text_material_dark</item>
-        <item name="wallpaperTextColorSecondary">@*android:color/secondary_text_material_dark</item>
+    <style name="Theme.SystemUI.KeyguardPresentation">
+        <item name="android:windowActionBar">false</item>
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:windowFullscreen">true</item>
+        <item name="android:windowContentOverlay">@null</item>
+        <item name="android:colorBackground">@*android:color/background_material_dark</item>
     </style>
 
     <style name="TextAppearance.Keyguard" parent="Theme.SystemUI">
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index 050655c..0ec60e5 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
@@ -33,6 +33,7 @@
 import android.view.View;
 import android.view.WindowManager;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.systemui.Dependency;
 import com.android.systemui.statusbar.NavigationBarController;
 import com.android.systemui.statusbar.phone.NavigationBarView;
@@ -234,7 +235,8 @@
 
     }
 
-    private final static class KeyguardPresentation extends Presentation {
+    @VisibleForTesting
+    static final class KeyguardPresentation extends Presentation {
         private static final int VIDEO_SAFE_REGION = 80; // Percentage of display width & height
         private static final int MOVE_CLOCK_TIMEOUT = 10000; // 10s
         private final InjectionInflationController mInjectableInflater;
@@ -256,7 +258,7 @@
 
         KeyguardPresentation(Context context, Display display,
                 InjectionInflationController injectionInflater) {
-            super(context, display, R.style.keyguard_presentation_theme);
+            super(context, display, R.style.Theme_SystemUI_KeyguardPresentation);
             mInjectableInflater = injectionInflater;
             getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
             setCancelable(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPresentationTest.java
similarity index 73%
rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java
rename to packages/SystemUI/tests/src/com/android/keyguard/KeyguardPresentationTest.java
index dfe2913..8138420 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardPresentationTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPresentationTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 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,18 +11,18 @@
  * 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.systemui.statusbar.phone;
+package com.android.keyguard;
 
+import android.content.Context;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
-import android.view.LayoutInflater;
 
 import androidx.test.filters.SmallTest;
 
-import com.android.systemui.R;
+import com.android.keyguard.KeyguardDisplayManager.KeyguardPresentation;
 import com.android.systemui.SystemUIFactory;
 import com.android.systemui.SysuiTestCase;
 import com.android.systemui.util.InjectionInflationController;
@@ -39,8 +39,9 @@
         com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper();
         InjectionInflationController inflationController = new InjectionInflationController(
                 SystemUIFactory.getInstance().getRootComponent());
-        LayoutInflater inflater = inflationController
-                .injectable(LayoutInflater.from(getContext()));
-        inflater.inflate(R.layout.keyguard_presentation, null);
+        Context context = getContext();
+        KeyguardPresentation keyguardPresentation =
+                new KeyguardPresentation(context, context.getDisplay(), inflationController);
+        keyguardPresentation.onCreate(null /*savedInstanceState */);
     }
 }