Merge "bootanalyze: handle all valid fs_stat properly" into oc-dev
diff --git a/car_product/overlay/packages/services/Car/service/res/values/Config.xml b/car_product/overlay/packages/services/Car/service/res/values/Config.xml
index ec9e73a..0680f15 100644
--- a/car_product/overlay/packages/services/Car/service/res/values/Config.xml
+++ b/car_product/overlay/packages/services/Car/service/res/values/Config.xml
@@ -1,4 +1,4 @@
 <resources>
     <!-- default activity whitelist which are allowed while driving -->
-    <string name="defauiltActivityWhitelist">com.android.systemui,com.android.car.dialer,com.android.car.hvac,com.android.car.media,com.android.car.radio,com.android.support.car.lenspicker</string>
+    <string name="defauiltActivityWhitelist">com.android.systemui,com.android.car.dialer,com.android.car.hvac,com.android.car.media,com.android.car.radio,com.android.support.car.lenspicker,com.google.android.setupwizard</string>
 </resources>
diff --git a/service/src/com/android/car/SystemActivityMonitoringService.java b/service/src/com/android/car/SystemActivityMonitoringService.java
index 0ea89dc..2ff4e0e 100644
--- a/service/src/com/android/car/SystemActivityMonitoringService.java
+++ b/service/src/com/android/car/SystemActivityMonitoringService.java
@@ -319,6 +319,7 @@
         mContext.startActivity(launcherIntent);
 
         newActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
         mContext.startActivityAsUser(newActivityIntent,
                 new UserHandle(currentTask.stackInfo.userId));
         // now make stack with new activity focused.
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml b/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml
new file mode 100644
index 0000000..759a73e
--- /dev/null
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/car_assistant.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical" android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <ImageView
+        android:id="@+id/voice_button"
+        android:layout_gravity="center"
+        android:src="@drawable/ic_voice_assistant_mic"
+        style="@style/OverviewButton"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/tests/EmbeddedKitchenSinkApp/res/layout/kitchen_content.xml b/tests/EmbeddedKitchenSinkApp/res/layout/kitchen_content.xml
index 14c3ef7..6a3d9ca 100644
--- a/tests/EmbeddedKitchenSinkApp/res/layout/kitchen_content.xml
+++ b/tests/EmbeddedKitchenSinkApp/res/layout/kitchen_content.xml
@@ -7,9 +7,4 @@
     android:layout_height="match_parent"
     android:paddingStart="56dp"
     android:paddingTop="@dimen/lens_header_height">
-    <ImageView
-        android:id="@+id/voice_button"
-        android:layout_gravity="center"
-        android:src="@drawable/ic_voice_assistant_mic"
-        style="@style/OverviewButton"/>
 </FrameLayout>
\ No newline at end of file
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java
index e57a14f..884d982 100644
--- a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/KitchenSinkActivity.java
@@ -35,6 +35,7 @@
 import com.android.car.app.CarDrawerActivity;
 import com.android.car.app.CarDrawerAdapter;
 import com.android.car.app.DrawerItemViewHolder;
+import com.google.android.car.kitchensink.assistant.CarAssistantFragment;
 import com.google.android.car.kitchensink.audio.AudioTestFragment;
 import com.google.android.car.kitchensink.bluetooth.BluetoothHeadsetFragment;
 import com.google.android.car.kitchensink.bluetooth.MapMceTestFragment;
@@ -54,6 +55,7 @@
     private static final String TAG = "KitchenSinkActivity";
 
     private static final String MENU_AUDIO = "audio";
+    private static final String MENU_ASSISTANT = "assistant";
     private static final String MENU_HVAC = "hvac";
     private static final String MENU_QUIT = "quit";
     private static final String MENU_JOB = "job_scheduler";
@@ -87,7 +89,7 @@
     private OrientationTestFragment mOrientationFragment;
     private MapMceTestFragment mMapMceTestFragment;
     private BluetoothHeadsetFragment mBluetoothHeadsetFragement;
-    private ImageView mMic;
+    private CarAssistantFragment mAssistantFragment;
 
     private final CarSensorManager.OnSensorChangedListener mListener = (manager, event) -> {
         switch (event.sensorType) {
@@ -106,23 +108,6 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setMainContent(R.layout.kitchen_content);
-        mMic = (ImageView) findViewById(R.id.voice_button);
-        mMic.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
-                Intent intent = new Intent();
-                intent.setAction(
-                        KitchenSinkActivity.this.getString(R.string.assistant_activity_action));
-                if (intent.resolveActivity(getPackageManager()) != null) {
-                    startActivity(intent);
-                } else {
-                    Toast.makeText(KitchenSinkActivity.this,
-                            "Assistant app is not available.", Toast.LENGTH_SHORT).show();
-                }
-            }
-        });
-
         // Connection to Car Service does not work for non-automotive yet.
         if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
             mCarApi = Car.createCar(this, mCarConnectionCallback);
@@ -210,7 +195,7 @@
     private final class DrawerAdapter extends CarDrawerAdapter {
 
         private final String mAllMenus[] = {
-                MENU_AUDIO, MENU_RADIO, MENU_HVAC, MENU_JOB,
+                MENU_AUDIO, MENU_ASSISTANT, MENU_RADIO, MENU_HVAC, MENU_JOB,
                 MENU_CLUSTER, MENU_INPUT_TEST, MENU_SENSORS, MENU_VOLUME_TEST,
                 MENU_TOUCH_TEST, MENU_CUBES_TEST, MENU_CAR_SETTINGS, MENU_ORIENTATION,
                 MENU_BLUETOOTH_HEADSET, MENU_MAP_MESSAGING, MENU_QUIT
@@ -242,6 +227,12 @@
                     }
                     showFragment(mAudioTestFragment);
                     break;
+                case MENU_ASSISTANT:
+                    if (mAssistantFragment == null) {
+                        mAssistantFragment = new CarAssistantFragment();
+                    }
+                    showFragment(mAssistantFragment);
+                    break;
                 case MENU_RADIO:
                     if (mRadioTestFragment == null) {
                         mRadioTestFragment = new RadioTestFragment();
diff --git a/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java
new file mode 100644
index 0000000..147b017
--- /dev/null
+++ b/tests/EmbeddedKitchenSinkApp/src/com/google/android/car/kitchensink/assistant/CarAssistantFragment.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+package com.google.android.car.kitchensink.assistant;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.HapticFeedbackConstants;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import com.google.android.car.kitchensink.R;
+
+public class CarAssistantFragment extends Fragment {
+
+    private ImageView mMic;
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+                             @Nullable Bundle savedInstanceState) {
+        View v = inflater.inflate(R.layout.car_assistant, container, false);
+        mMic = (ImageView) v.findViewById(R.id.voice_button);
+        Context context = getContext();
+        mMic.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
+                Intent intent = new Intent();
+                intent.setAction(
+                        getContext().getString(R.string.assistant_activity_action));
+                if (intent.resolveActivity(context.getPackageManager()) != null) {
+                    startActivity(intent);
+                } else {
+                    Toast.makeText(context,
+                            "Assistant app is not available.", Toast.LENGTH_SHORT).show();
+                }
+            }
+        });
+        return v;
+    }
+}