Update ActivityBlockingActivity UI am: 13037bca8f

Change-Id: Id7805d54e88d7445924e65a624561e81b3368fe3
diff --git a/service/res/drawable/action_button_background.xml b/service/res/drawable/action_button_background.xml
new file mode 100644
index 0000000..afed15e
--- /dev/null
+++ b/service/res/drawable/action_button_background.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ 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.
+  -->
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="@*android:color/car_card_ripple_background">
+    <item>
+        <shape android:shape="rectangle">
+            <solid android:color="@color/action_button_background_color" />
+            <corners android:radius="@dimen/action_button_corner_radius"/>
+        </shape>
+    </item>
+</ripple>
diff --git a/service/res/drawable/button_background.xml b/service/res/drawable/button_background.xml
deleted file mode 100644
index c714124..0000000
--- a/service/res/drawable/button_background.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
-    <solid android:color="@color/button_background"/>
-    <corners android:radius="@dimen/button_radius"/>
-</shape>
diff --git a/service/res/drawable/button_ripple_background.xml b/service/res/drawable/button_ripple_background.xml
deleted file mode 100644
index 418c508..0000000
--- a/service/res/drawable/button_ripple_background.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<ripple
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:color="@color/ripple_background">
-    <item android:drawable="@drawable/button_background" />
-</ripple>
diff --git a/service/res/drawable/car_ic_ux_restricted_48dp.xml b/service/res/drawable/car_ic_ux_restricted_48dp.xml
new file mode 100644
index 0000000..97fd3d5
--- /dev/null
+++ b/service/res/drawable/car_ic_ux_restricted_48dp.xml
@@ -0,0 +1,4 @@
+<vector android:height="48dp" android:viewportHeight="24"
+    android:viewportWidth="24" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FFFFFFFF" android:pathData="M18,8h-1L17,6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2L6,8c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,10c0,-1.1 -0.9,-2 -2,-2zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2L9,8L9,6zM18,20L6,20L6,10h12v10zM12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z"/>
+</vector>
diff --git a/service/res/layout/activity_blocking.xml b/service/res/layout/activity_blocking.xml
index 0c10016..f79406d 100644
--- a/service/res/layout/activity_blocking.xml
+++ b/service/res/layout/activity_blocking.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
+<?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.
@@ -13,69 +12,58 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="vertical"
     android:background="@color/activity_blocking_activity_background"
-    android:gravity="center">
-    <LinearLayout
-        android:layout_height="wrap_content"
-        android:layout_width="match_parent"
-        android:orientation="horizontal"
-        android:gravity="center">
-        <ImageView
-            android:id="@+id/blocked_app_icon"
-            android:layout_height="wrap_content"
-            android:layout_width="wrap_content" />
-        <TextView
-            android:id="@+id/blocked_app_name"
-            android:layout_height="wrap_content"
-            android:layout_width="wrap_content"
-            android:layout_marginStart="@dimen/common_margin"
-            android:textColor="@color/blocking_text"
-            android:textAppearance="@style/ActivityBlockingActivityText" />
-    </LinearLayout>
+    android:gravity="center"
+    android:orientation="vertical">
 
-    <TextView
-        android:id="@+id/blocking_text"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginTop="@dimen/common_margin"
-        android:gravity="center"
-        android:textAppearance="@style/ActivityBlockingActivityText" />
+  <ImageView
+      android:id="@+id/ux_restricted_icon"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginBottom="@dimen/common_margin"
+      android:src="@drawable/car_ic_ux_restricted_48dp" />
 
-    <!-- Show exit button if we need to (and are able to) restart the blocked task -->
-    <TextView
-        android:id="@+id/exit_button_message"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginTop="@dimen/common_margin"
-        android:textAppearance="@style/ActivityBlockingActivityText" />
+  <TextView
+      android:id="@+id/blocking_text"
+      android:layout_width="@dimen/blocking_text_width"
+      android:layout_height="wrap_content"
+      android:gravity="center"
+      android:text="@string/activity_blocked_text"
+      android:textAppearance="@style/ActivityBlockingActivityText" />
+
+  <LinearLayout
+      android:id="@+id/action_button_container"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginTop="48dp"
+      android:layout_gravity="center"
+      android:gravity="center_horizontal"
+      android:orientation="horizontal">
     <Button
         android:id="@+id/exit_button"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginTop="@dimen/common_margin"
-        android:text="@string/exit_button"
-        style="@style/ButtonStyle"/>
+        style="@style/ButtonStyle" />
 
-    <!-- Widgets to display debug info. They should not show for non-user build. -->
     <Button
         android:id="@+id/toggle_debug_info"
-        android:visibility="gone"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginTop="@dimen/common_margin"
+        style="@style/ButtonStyle"
         android:text="@string/debug_button_text"
-        style="@style/ButtonStyle"/>
-
-    <TextView
-        android:id="@+id/debug_info"
         android:visibility="gone"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginTop="@dimen/common_margin"
-        android:textAppearance="@style/ActivityBlockingActivityText" />
+        android:layout_marginStart="@dimen/action_button_padding_horizontal"/>
+
+  </LinearLayout>
+
+  <TextView
+      android:id="@+id/debug_info"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:textAppearance="@style/ActivityBlockingActivityText"
+      android:visibility="gone" />
+
 </LinearLayout>
+
diff --git a/service/res/values/colors.xml b/service/res/values/colors.xml
index 6764116..109a4a4 100644
--- a/service/res/values/colors.xml
+++ b/service/res/values/colors.xml
@@ -18,18 +18,17 @@
 -->
 <resources>
     <!-- Semi-transparent background color of blocking activity. -->
-    <!-- In Call background scrim: grey 200 -->
-    <color name="activity_blocking_activity_background">#ffeeeeee</color>
+    <color name="activity_blocking_activity_background">#c7000000</color>
 
     <!-- Color of text in blocking activity. -->
-    <color name="blocking_text">#ff212121</color>
+    <color name="blocking_text">#ffffff</color>
 
     <!-- Background color of button. -->
-    <color name="button_background">#ff00796b</color>
+    <color name="action_button_background_color">@*android:color/car_grey_868</color>
 
     <!-- Color of button text. -->
-    <color name="button_text">#fffafafa</color>
+    <color name="button_text">#ffffffff</color>
 
     <!-- Ripple color of button background. -->
-    <color name="ripple_background">#3d000000</color>
+    <color name="ripple_background">@*android:color/car_card_ripple_background_dark</color>
 </resources>
diff --git a/service/res/values/dimens.xml b/service/res/values/dimens.xml
index 23653db..1cf1308 100644
--- a/service/res/values/dimens.xml
+++ b/service/res/values/dimens.xml
@@ -18,15 +18,17 @@
 -->
 <resources>
     <!-- Text size in ActivityBlockingActivity. -->
-    <dimen name="blocking_text_size">32sp</dimen>
-    <!-- Widget margin. It should be half the height of button. -->
-    <dimen name="common_margin">28dp</dimen>
-    <!-- Minimum height of button in ActivityBlockingActivity. -->
-    <dimen name="button_min_height">56dp</dimen>
-    <!-- Minimum width of button in ActivityBlockingActivity. -->
-    <dimen name="button_min_width">156dp</dimen>
-    <!-- Padding of button in ActivityBlockingActivity. -->
-    <dimen name="button_padding">16dp</dimen>
-    <!-- Radius of button in ActivityBlockingActivity. -->
-    <dimen name="button_radius">4dp</dimen>
+    <dimen name="blocking_text_size">@*android:dimen/car_body1_size</dimen>
+    <dimen name="blocking_text_width">706dp</dimen>
+
+    <dimen name="common_margin">32dp</dimen>
+
+    <!-- Dimensions for the Buttons in ActivityBlockingActivity -->
+    <dimen name="action_button_height">76dp</dimen>
+    <dimen name="action_button_top_margin">48dp</dimen>
+    <dimen name="action_button_corner_radius">38dp</dimen>
+    <dimen name="action_button_max_width">268dp</dimen>
+    <dimen name="action_button_min_width">@*android:dimen/car_button_min_width</dimen>
+    <dimen name="action_button_text_size">@*android:dimen/car_body3_size</dimen>
+    <dimen name="action_button_padding_horizontal">@*android:dimen/car_padding_4</dimen>
 </resources>
diff --git a/service/res/values/strings.xml b/service/res/values/strings.xml
index 1589180..f11e2c5 100644
--- a/service/res/values/strings.xml
+++ b/service/res/values/strings.xml
@@ -115,11 +115,15 @@
         box and restart the car</string>
 
     <!-- Blocking activity: Message to show to user when a feature of current application is not allowed. [CHAR LIMIT=120] -->
-    <string name="activity_blocked_text">For your safety, this activity isn\u2019t available while driving.\nTo continue, wait until you\u2019re parked.</string>
+    <string name="activity_blocked_text">Not available while driving</string>
     <!-- Blocking activity: Message to accompany the exit_button that restarts the blocked app. [CHAR LIMIT=120] -->
     <string name="exit_button_message">To start over with safe app features, select <xliff:g id="exit_button" example="Back">%s</xliff:g>.</string>
     <!-- Blocking activity: Text for button that restarts the current blocked application. [CHAR LIMIT=15] -->
     <string name="exit_button">Back</string>
+    <!-- Blocking activity: Text for button that closes current blocked application. [CHAR LIMIT=20] -->
+    <string name="exit_button_close_application">Close app</string>
+    <!-- Blocking activity: Text for button that closes current blocked application. [CHAR LIMIT=15] -->
+    <string name="exit_button_go_back">Back</string>
     <!-- Blocking activity: Text for button that shows debug info in non-user build. -->
     <string name="debug_button_text" translatable="false">Debug Info</string>
 
diff --git a/service/res/values/styles.xml b/service/res/values/styles.xml
index 35b0b29..e9c8942 100644
--- a/service/res/values/styles.xml
+++ b/service/res/values/styles.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?><!-- 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.
@@ -16,23 +15,31 @@
 <resources>
     <!-- TextAppearances for ActivityBlockingActivity. -->
     <style name="ActivityBlockingActivityText">
-        <item name="android:fontFamily">sans-serif-medium</item>
+        <item name="android:fontFamily">roboto-regular</item>
         <item name="android:textColor">@color/blocking_text</item>
         <item name="android:textStyle">normal</item>
         <item name="android:textSize">@dimen/blocking_text_size</item>
     </style>
 
+    <!-- TextAppearances for Button Text in ActivityBlockingActivity. -->
+    <style name="ActionButtonText" parent="android:TextAppearance.DeviceDefault">
+        <item name="android:fontFamily">roboto-regular</item>
+        <item name="android:textColor">@color/blocking_text</item>
+        <item name="android:textSize">@*android:dimen/car_body3_size</item>
+    </style>
+
     <!-- Style for buttons in ActivityBlockingActivity. -->
     <style name="ButtonStyle">
-        <item name="android:background">@drawable/button_ripple_background</item>
-        <item name="android:fontFamily">sans-serif-medium</item>
-        <item name="android:minHeight">@dimen/button_min_height</item>
-        <item name="android:minWidth">@dimen/button_min_width</item>
-        <item name="android:paddingHorizontal">@dimen/button_padding</item>
-        <item name="android:textAllCaps">true</item>
-        <item name="android:textAlignment">center</item>
-        <item name="android:textAppearance">@style/ActivityBlockingActivityText</item>
-        <item name="android:textColor">@color/button_text</item>
+        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_height">@dimen/action_button_height</item>
+        <item name="android:minWidth">@dimen/action_button_min_width</item>
+        <item name="android:maxWidth">@dimen/action_button_max_width</item>
+        <item name="android:textAppearance">@style/ActionButtonText</item>
+        <item name="android:textColor">@color/blocking_text</item>
+        <item name="android:singleLine">true</item>
+        <item name="android:background">@drawable/action_button_background</item>
+        <item name="android:gravity">center</item>
+        <item name="android:paddingHorizontal">@dimen/action_button_padding_horizontal</item>
     </style>
 </resources>
 
diff --git a/service/src/com/android/car/pm/ActivityBlockingActivity.java b/service/src/com/android/car/pm/ActivityBlockingActivity.java
index 9756523..a9f0d6a 100644
--- a/service/src/com/android/car/pm/ActivityBlockingActivity.java
+++ b/service/src/com/android/car/pm/ActivityBlockingActivity.java
@@ -27,20 +27,15 @@
 import android.car.drivingstate.CarUxRestrictionsManager;
 import android.content.ComponentName;
 import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
 import android.os.Build;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
+import android.view.ViewTreeObserver;
 import android.widget.Button;
-import android.widget.ImageView;
 import android.widget.TextView;
 
-import androidx.annotation.Nullable;
-
 import com.android.car.CarLog;
 import com.android.car.R;
 
@@ -54,26 +49,35 @@
     private Car mCar;
     private CarUxRestrictionsManager mUxRManager;
 
-    private TextView mBlockedAppName;
-    private ImageView mBlockedAppIcon;
-    private TextView mBlockingText;
-    private TextView mExitButtonMessage;
     private Button mExitButton;
+    private Button mToggleDebug;
 
     private int mBlockedTaskId;
 
+    private final View.OnClickListener mOnExitButtonClickedListener =
+            v -> {
+                if (isExitOptionCloseApplication()) {
+                    handleCloseApplication();
+                } else {
+                    handleRestartingTask();
+                }
+            };
+
+    private final ViewTreeObserver.OnGlobalLayoutListener mOnGlobalLayoutListener =
+            new ViewTreeObserver.OnGlobalLayoutListener() {
+                @Override
+                public void onGlobalLayout() {
+                    mToggleDebug.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+                    updateButtonWidths();
+                }
+            };
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_blocking);
 
-        mBlockingText = findViewById(R.id.blocking_text);
-        mBlockedAppName = findViewById(R.id.blocked_app_name);
-        mBlockedAppIcon = findViewById(R.id.blocked_app_icon);
         mExitButton = findViewById(R.id.exit_button);
-        mExitButtonMessage = findViewById(R.id.exit_button_message);
-
-        mBlockingText.setText(getString(R.string.activity_blocked_text));
 
         // Listen to the CarUxRestrictions so this blocking activity can be dismissed when the
         // restrictions are lifted.
@@ -110,26 +114,9 @@
             if (Log.isLoggable(CarLog.TAG_AM, Log.DEBUG)) {
                 Log.d(CarLog.TAG_AM, "Blocking activity " + blockedActivity);
             }
-            // Show application icon and name of blocked activity.
-            Drawable appIcon = findApplicationIcon(blockedActivity);
-            if (appIcon != null) {
-                mBlockedAppIcon.setImageDrawable(appIcon);
-            } else {
-                mBlockedAppIcon.setVisibility(View.GONE);
-            }
-            mBlockedAppName.setText(findHumanReadableLabel(blockedActivity));
         }
 
-        boolean isRootDO = getIntent().getBooleanExtra(
-                BLOCKING_INTENT_EXTRA_IS_ROOT_ACTIVITY_DO, false);
-
-        // Display a button to restart task if root task is DO.
-        boolean showButton = mBlockedTaskId != INVALID_TASK_ID && isRootDO;
-        mExitButton.setVisibility(showButton ? View.VISIBLE : View.GONE);
-        mExitButton.setOnClickListener(v -> handleRestartingTask());
-        mExitButtonMessage.setVisibility(showButton ? View.VISIBLE : View.GONE);
-        mExitButtonMessage.setText(
-                getString(R.string.exit_button_message, getString(R.string.exit_button)));
+        displayExitButton();
 
         // Show more debug info for non-user build.
         if (Build.IS_ENG || Build.IS_USERDEBUG) {
@@ -137,6 +124,26 @@
         }
     }
 
+    private void displayExitButton() {
+        String exitButtonText = getExitButtonText();
+
+        mExitButton.setText(exitButtonText);
+        mExitButton.setOnClickListener(mOnExitButtonClickedListener);
+    }
+
+    // If the root activity is DO, the user will have the option to go back to that activity,
+    // otherwise, the user will have the option to close the blocked application
+    private boolean isExitOptionCloseApplication() {
+        boolean isRootDO = getIntent().getBooleanExtra(
+                BLOCKING_INTENT_EXTRA_IS_ROOT_ACTIVITY_DO, false);
+        return mBlockedTaskId == INVALID_TASK_ID || !isRootDO;
+    }
+
+    private String getExitButtonText() {
+        return isExitOptionCloseApplication() ? getString(R.string.exit_button_close_application)
+                : getString(R.string.exit_button_go_back);
+    }
+
     private void displayDebugInfo() {
         String blockedActivity = getIntent().getStringExtra(
                 BLOCKING_INTENT_EXTRA_BLOCKED_ACTIVITY_NAME);
@@ -147,12 +154,29 @@
 
         // We still want to ensure driving safety for non-user build;
         // toggle visibility of debug info with this button.
-        Button toggleDebug = findViewById(R.id.toggle_debug_info);
-        toggleDebug.setVisibility(View.VISIBLE);
-        toggleDebug.setOnClickListener(v -> {
+        mToggleDebug = findViewById(R.id.toggle_debug_info);
+        mToggleDebug.setVisibility(View.VISIBLE);
+        mToggleDebug.setOnClickListener(v -> {
             boolean isDebugVisible = debugInfo.getVisibility() == View.VISIBLE;
             debugInfo.setVisibility(isDebugVisible ? View.GONE : View.VISIBLE);
         });
+
+        mToggleDebug.getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
+    }
+
+    // When the Debug button is visible, we set both of the visible buttons to have the width
+    // of whichever button is wider
+    private void updateButtonWidths() {
+        Button debugButton = findViewById(R.id.toggle_debug_info);
+
+        int exitButtonWidth = mExitButton.getWidth();
+        int debugButtonWidth = debugButton.getWidth();
+
+        if (exitButtonWidth > debugButtonWidth) {
+            debugButton.setWidth(exitButtonWidth);
+        } else {
+            mExitButton.setWidth(debugButtonWidth);
+        }
     }
 
     private String getDebugInfo(String blockedActivity, String rootActivity) {
@@ -195,6 +219,8 @@
     protected void onDestroy() {
         super.onDestroy();
         mUxRManager.unregisterListener();
+        mToggleDebug.getViewTreeObserver().removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
+        mCar.disconnect();
     }
 
     // If no distraction optimization is required in the new restrictions, then dismiss the
@@ -208,48 +234,16 @@
         }
     }
 
-    // Finds the icon of the application (package) the component belongs to.
-    @Nullable
-    private Drawable findApplicationIcon(String flattenComponentName) {
-        ComponentName componentName = ComponentName.unflattenFromString(flattenComponentName);
-        try {
-            return getPackageManager().getApplicationIcon(componentName.getPackageName());
-        } catch (PackageManager.NameNotFoundException e) {
-            if (Log.isLoggable(CarLog.TAG_AM, Log.INFO)) {
-                Log.i(CarLog.TAG_AM, "Could not find package for component name "
-                        + componentName.toString());
-            }
+    private void handleCloseApplication() {
+        if (isFinishing()) {
+            return;
         }
-        return null;
-    }
 
-    /**
-     * Returns a human-readable string for {@code flattenComponentName}.
-     *
-     * <p>It first attempts to return the application label for this activity. If that fails,
-     * it will return the last part in the activity name.
-     */
-    private String findHumanReadableLabel(String flattenComponentName) {
-        ComponentName componentName = ComponentName.unflattenFromString(flattenComponentName);
-        String label = null;
-        // Attempt to find application label.
-        try {
-            ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(
-                    componentName.getPackageName(), 0);
-            CharSequence appLabel = getPackageManager().getApplicationLabel(applicationInfo);
-            if (appLabel != null) {
-                label = appLabel.toString();
-            }
-        } catch (PackageManager.NameNotFoundException e) {
-            if (Log.isLoggable(CarLog.TAG_AM, Log.INFO)) {
-                Log.i(CarLog.TAG_AM, "Could not find package for component name "
-                        + componentName.toString());
-            }
-        }
-        if (TextUtils.isEmpty(label)) {
-            label = componentName.getClass().getSimpleName();
-        }
-        return label;
+        Intent startMain = new Intent(Intent.ACTION_MAIN);
+        startMain.addCategory(Intent.CATEGORY_HOME);
+        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        startActivity(startMain);
+        finish();
     }
 
     private void handleRestartingTask() {