Merge "Import translations. DO NOT MERGE ANYWHERE" into rvc-qpr-dev
diff --git a/car_product/build/car.mk b/car_product/build/car.mk
index efbbc9b..456f7fd 100644
--- a/car_product/build/car.mk
+++ b/car_product/build/car.mk
@@ -21,6 +21,7 @@
 
 PRODUCT_PACKAGES += \
     Bluetooth \
+    CarActivityResolver \
     CarDeveloperOptions \
     OneTimeInitializer \
     Provision \
diff --git a/car_product/overlay-visual/frameworks/base/core/res/res/drawable/activated_item_background.xml b/car_product/overlay-visual/frameworks/base/core/res/res/drawable/activated_item_background.xml
new file mode 100644
index 0000000..280934f
--- /dev/null
+++ b/car_product/overlay-visual/frameworks/base/core/res/res/drawable/activated_item_background.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true" android:state_pressed="true">
+        <shape android:shape="rectangle">
+            <solid android:color="#8A94CBFF"/>
+            <stroke android:width="4dp"
+                    android:color="#94CBFF"/>
+        </shape>
+    </item>
+    <item android:state_focused="true" android:state_activated="true">
+        <shape android:shape="rectangle">
+            <solid android:color="?android:attr/colorControlActivated"/>
+            <stroke android:width="8dp" android:color="#94CBFF"/>
+        </shape>
+    </item>
+    <item android:state_focused="true">
+        <shape android:shape="rectangle">
+            <solid android:color="#3D94CBFF"/>
+            <stroke android:width="8dp" android:color="#94CBFF"/>
+        </shape>
+    </item>
+    <item android:state_activated="true">
+        <shape android:shape="rectangle">
+            <solid android:color="?android:attr/colorControlActivated"/>
+        </shape>
+    </item>
+    <item>
+        <ripple android:color="?android:attr/colorControlHighlight">
+            <item android:id="@android:id/mask">
+                <color android:color="@android:color/white" />
+            </item>
+        </ripple>
+    </item>
+</selector>
diff --git a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolve_list_item.xml b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolve_list_item.xml
index 633dd2d..2fc9901 100644
--- a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolve_list_item.xml
+++ b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolve_list_item.xml
@@ -23,7 +23,7 @@
               android:minHeight="?android:attr/listPreferredItemHeightLarge"
               android:paddingTop="4dp"
               android:paddingBottom="4dp"
-              android:background="?android:attr/activatedBackgroundIndicator">
+              android:background="@drawable/activated_item_background">
     <ImageView android:id="@*android:id/icon"
                android:layout_width="75dp"
                android:layout_height="75dp"
diff --git a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list.xml b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list.xml
index eec830d..1bc599d 100644
--- a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list.xml
+++ b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list.xml
@@ -20,5 +20,8 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
+    <com.android.car.ui.FocusParkingView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
     <include layout="@*android:layout/car_resolver_list"/>
 </FrameLayout>
diff --git a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list_with_default.xml b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list_with_default.xml
index 682f749..5477f2c 100644
--- a/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list_with_default.xml
+++ b/car_product/overlay-visual/frameworks/base/core/res/res/layout/resolver_list_with_default.xml
@@ -20,5 +20,8 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
+    <com.android.car.ui.FocusParkingView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
     <include layout="@*android:layout/car_resolver_list_with_default"/>
 </FrameLayout>
diff --git a/car_product/overlay/frameworks/base/core/res/res/values/config.xml b/car_product/overlay/frameworks/base/core/res/res/values/config.xml
index 2b49a42..73a380b 100644
--- a/car_product/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/car_product/overlay/frameworks/base/core/res/res/values/config.xml
@@ -124,4 +124,8 @@
         <item>"no_modify_accounts"</item>
     </string-array>
 
+    <!-- Use a car-specific activity resolver that supports rotary. -->
+    <string name="config_customResolverActivity" translatable="false"
+        >com.android.car.activityresolver/.CarResolverActivity</string>
+
 </resources>
diff --git a/packages/CarActivityResolver/Android.bp b/packages/CarActivityResolver/Android.bp
new file mode 100644
index 0000000..83228c3
--- /dev/null
+++ b/packages/CarActivityResolver/Android.bp
@@ -0,0 +1,35 @@
+// Copyright (C) 2021 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.
+android_app {
+    name: "CarActivityResolver",
+    srcs: ["src/**/*.java"],
+    platform_apis: true,
+    certificate: "platform",
+    privileged: true,
+    optimize: {
+        proguard_flags_files: ["proguard.flags"],
+        enabled: false,
+    },
+    resource_dirs: ["res"],
+    static_libs: [
+        "car-ui-lib",
+    ],
+    libs: ["android.car"],
+    required: ["allowed_privapp_com.android.car.activityresolver"],
+    product_variables: {
+        pdk: {
+            enabled: false,
+        },
+    },
+}
diff --git a/packages/CarActivityResolver/AndroidManifest.xml b/packages/CarActivityResolver/AndroidManifest.xml
new file mode 100644
index 0000000..78e1fb1
--- /dev/null
+++ b/packages/CarActivityResolver/AndroidManifest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  ~ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+          package="com.android.car.activityresolver">
+
+    <!-- Required to rank activities. -->
+    <uses-permission android:name="android.permission.BIND_RESOLVER_RANKER_SERVICE" />
+
+    <!-- Required for ActivityManager.getCurrentUser(). -->
+    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
+
+    <!-- Required for UserManager.getProfiles() and getUserInfo(). -->
+    <uses-permission android:name="android.permission.MANAGE_USERS" />
+
+    <!-- To delete last chosen activity when another activity is chosen. -->
+    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+
+    <!-- To change the preferred activity. -->
+    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
+
+    <application android:label="@string/app_name">
+
+        <activity
+            android:name=".CarResolverActivity"
+            android:exported="true"
+            android:launchMode="singleInstance"
+            android:noHistory="true">
+        </activity>
+
+    </application>
+</manifest>
diff --git a/packages/CarActivityResolver/res/values/strings.xml b/packages/CarActivityResolver/res/values/strings.xml
new file mode 100644
index 0000000..42c7d26
--- /dev/null
+++ b/packages/CarActivityResolver/res/values/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2021 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name" translatable="false">CarActivityResolver</string>
+</resources>
diff --git a/packages/CarActivityResolver/src/com/android/car/activityresolver/CarResolverActivity.java b/packages/CarActivityResolver/src/com/android/car/activityresolver/CarResolverActivity.java
new file mode 100644
index 0000000..d4807a3
--- /dev/null
+++ b/packages/CarActivityResolver/src/com/android/car/activityresolver/CarResolverActivity.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 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.car.activityresolver;
+
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.widget.ListView;
+
+import com.android.internal.R;
+import com.android.internal.app.ResolverActivity;
+import com.android.internal.app.ResolverViewPager;
+
+/**
+ * An automotive variant of the resolver activity which does not use the safe forwarding mode and
+ * which supports rotary.
+ */
+public final class CarResolverActivity extends ResolverActivity
+        implements ViewTreeObserver.OnGlobalLayoutListener {
+
+    private ResolverViewPager mProfilePager;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setSafeForwardingMode(false);
+
+        mProfilePager = findViewById(R.id.profile_pager);
+        mProfilePager.getViewTreeObserver().addOnGlobalLayoutListener(this);
+    }
+
+    @Override
+    protected void onDestroy() {
+        mProfilePager.getViewTreeObserver().removeOnGlobalLayoutListener(this);
+
+        super.onDestroy();
+    }
+
+    @Override
+    public void onGlobalLayout() {
+        ListView listView = findViewById(R.id.resolver_list);
+        if (listView != null) {
+            // Items must be focusable for rotary.
+            listView.setItemsCanFocus(true);
+
+            // Set click listeners for rotary.
+            for (int i = 0; i < listView.getChildCount(); i++) {
+                View element = listView.getChildAt(i);
+                element.setOnClickListener(view -> {
+                    int position = listView.getPositionForView(view);
+                    long id = listView.getItemIdAtPosition(position);
+                    listView.performItemClick(view, position, id);
+                });
+            }
+        }
+    }
+}
diff --git a/tests/DiagnosticTools/res/values-ta/strings.xml b/tests/DiagnosticTools/res/values-ta/strings.xml
index 09e74cc..abb9412 100644
--- a/tests/DiagnosticTools/res/values-ta/strings.xml
+++ b/tests/DiagnosticTools/res/values-ta/strings.xml
@@ -17,5 +17,5 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="display_freeze_frame_info" msgid="1425573367248263107">"ஃப்ரீஸ் ஃப்ரேம் தகவலைக் காட்டு"</string>
+    <string name="display_freeze_frame_info" msgid="1425573367248263107">"ஃப்ரீஸ் ஃபிரேம் தகவலைக் காட்டு"</string>
 </resources>