Update Simulator to launch SpeakEasy

Test:
PiperOrigin-RevId: 182625448
Change-Id: I4fe514c429a6b5a88060f326b0c73c2f3a960c1c
diff --git a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
index 4ef579f..4501190 100644
--- a/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
+++ b/java/com/android/dialer/simulator/impl/SimulatorMainMenu.java
@@ -32,12 +32,16 @@
 import com.android.dialer.persistentlog.PersistentLogger;
 import com.android.dialer.preferredsim.PreferredSimFallbackContract;
 import com.android.incallui.rtt.impl.RttChatActivity;
+import com.android.incallui.speakeasy.SpeakEasy;
+import com.android.incallui.speakeasy.SpeakEasyActivity;
+import com.android.incallui.speakeasy.SpeakEasyComponent;
 
 /** Implements the top level simulator menu. */
 final class SimulatorMainMenu {
 
   static ActionProvider getActionProvider(@NonNull AppCompatActivity activity) {
-    return new SimulatorSubMenu(activity.getApplicationContext())
+    SimulatorSubMenu simulatorSubMenu = new SimulatorSubMenu(activity.getApplicationContext());
+    simulatorSubMenu
         .addItem("Voice call", SimulatorVoiceCall.getActionProvider(activity))
         .addItem(
             "IMS video", SimulatorVideoCall.getActionProvider(activity.getApplicationContext()))
@@ -61,12 +65,23 @@
             () ->
                 activity.startActivity(
                     EnrichedCallSimulatorActivity.newIntent(activity.getApplicationContext())));
+    SpeakEasy speakEasy = SpeakEasyComponent.get(activity.getApplicationContext()).speakEasy();
+    if (speakEasy.isEnabled()) {
+      simulatorSubMenu.addItem(
+          "SpeakEasy call mock", () -> simulateSpeakEasyCallMock(activity.getApplicationContext()));
+    }
+
+    return simulatorSubMenu;
   }
 
   private static void simulateRttCallMock(@NonNull Context context) {
     context.startActivity(new Intent(context, RttChatActivity.class));
   }
 
+  private static void simulateSpeakEasyCallMock(@NonNull Context context) {
+    context.startActivity(new Intent(context, SpeakEasyActivity.class));
+  }
+
   private static void populateDatabase(@NonNull Context context) {
     DialerExecutorComponent.get(context)
         .dialerExecutorFactory()
diff --git a/java/com/android/incallui/speakeasy/AndroidManifest.xml b/java/com/android/incallui/speakeasy/AndroidManifest.xml
new file mode 100644
index 0000000..e56b2e7
--- /dev/null
+++ b/java/com/android/incallui/speakeasy/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<!--
+  ~ 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
+  -->
+<manifest
+    package="com.android.incallui.speakeasy"
+    xmlns:android="http://schemas.android.com/apk/res/android">
+  <application android:theme="@style/Theme.AppCompat">
+  <activity
+      android:name=".SpeakEasyActivity"
+      android:exported="false"
+      android:theme="@style/DialerThemeBase.NoActionBar"
+      android:windowSoftInputMode="adjustResize"/>
+  </application>
+</manifest>
diff --git a/java/com/android/incallui/speakeasy/SpeakEasy.java b/java/com/android/incallui/speakeasy/SpeakEasy.java
index 393072c..5621eed 100644
--- a/java/com/android/incallui/speakeasy/SpeakEasy.java
+++ b/java/com/android/incallui/speakeasy/SpeakEasy.java
@@ -16,9 +16,24 @@
 
 package com.android.incallui.speakeasy;
 
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+
 /** This interface provides a wrapper between callers and the Whisper client. */
 public interface SpeakEasy {
 
-  /** Signals to the user interface that the feature is abailable for use. */
+  /** Signals to the user interface that the feature is available for use. */
   boolean isEnabled();
+
+  /**
+   * Create a new instance of SpeakEasy fragment.
+   *
+   * @param callId call id of the call.
+   * @param nameOrNumber name or number of the caller to be displayed
+   * @param sessionStartTimeMillis start time of the session in terms of {@link
+   *     android.os.SystemClock#elapsedRealtime}.
+   * @return new SpeakEasy fragment. Null if the SpeakEasy feature is not available for use
+   */
+  @Nullable
+  Fragment getSpeakEasyFragment(String callId, String nameOrNumber, long sessionStartTimeMillis);
 }
diff --git a/java/com/android/incallui/speakeasy/SpeakEasyActivity.java b/java/com/android/incallui/speakeasy/SpeakEasyActivity.java
new file mode 100644
index 0000000..4663526
--- /dev/null
+++ b/java/com/android/incallui/speakeasy/SpeakEasyActivity.java
@@ -0,0 +1,47 @@
+/*
+ * 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.incallui.speakeasy;
+
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.view.View;
+
+/** Activity to for SpeakEasy component. */
+public class SpeakEasyActivity extends FragmentActivity {
+
+  private SpeakEasy speakEasy;
+
+  @Override
+  protected void onCreate(@Nullable Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    speakEasy = SpeakEasyComponent.get(this).speakEasy();
+    setContentView(R.layout.activity_speakeasy);
+    Fragment speakEasyFragment =
+        speakEasy.getSpeakEasyFragment("", "John Snow", SystemClock.elapsedRealtime());
+    if (speakEasyFragment != null) {
+      getSupportFragmentManager()
+          .beginTransaction()
+          .add(R.id.fragment_speakeasy, speakEasyFragment)
+          .commit();
+    }
+    getWindow().setStatusBarColor(getColor(R.color.speakeasy_status_bar_color));
+    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+  }
+}
diff --git a/java/com/android/incallui/speakeasy/SpeakEasyStub.java b/java/com/android/incallui/speakeasy/SpeakEasyStub.java
index 5e8a84a..8b6b562 100644
--- a/java/com/android/incallui/speakeasy/SpeakEasyStub.java
+++ b/java/com/android/incallui/speakeasy/SpeakEasyStub.java
@@ -16,6 +16,8 @@
 
 package com.android.incallui.speakeasy;
 
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
 import javax.inject.Inject;
 
 /** Default implementation of SpeakEasy. */
@@ -28,4 +30,10 @@
   public boolean isEnabled() {
     return false;
   }
+
+  @Override
+  public @Nullable Fragment getSpeakEasyFragment(
+      String callId, String nameOrNumber, long sessionStartTimeMillis) {
+    return null;
+  }
 }
diff --git a/java/com/android/incallui/speakeasy/res/layout/activity_speakeasy.xml b/java/com/android/incallui/speakeasy/res/layout/activity_speakeasy.xml
new file mode 100644
index 0000000..5271d62
--- /dev/null
+++ b/java/com/android/incallui/speakeasy/res/layout/activity_speakeasy.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ 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.
+  ~ 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
+  -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+  <FrameLayout
+      android:id="@+id/fragment_speakeasy"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"/>
+
+</LinearLayout>
diff --git a/java/com/android/incallui/speakeasy/res/values/colors.xml b/java/com/android/incallui/speakeasy/res/values/colors.xml
new file mode 100644
index 0000000..fc4790e
--- /dev/null
+++ b/java/com/android/incallui/speakeasy/res/values/colors.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2017 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
+  -->
+
+<resources>
+  <color name="speakeasy_status_bar_color">#E0E0E0</color>
+</resources>
diff --git a/packages.mk b/packages.mk
index 0edf0b5..e2ccf3e 100644
--- a/packages.mk
+++ b/packages.mk
@@ -79,6 +79,7 @@
 	com.android.incallui.incall.impl \
 	com.android.incallui.maps.impl \
 	com.android.incallui.rtt.impl \
+  com.android.incallui.speakeasy \
 	com.android.incallui.sessiondata \
 	com.android.incallui.spam \
 	com.android.incallui.speakerbuttonlogic \