[automerger skipped] Migrate packages/apps/Car to aapt2 am: b7dbefb800
am: b5dd100ad5  -s ours

Change-Id: I3e600b2417638dd22b23d366fd9356e89e72239d
diff --git a/Android.mk b/Android.mk
index 77c2d1d..5f790a2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -29,23 +29,27 @@
 
 LOCAL_USE_AAPT2 := true
 
+LOCAL_OVERRIDES_PACKAGES := LatinIME
+
+LOCAL_JAVA_LIBRARIES += android.car
+
 LOCAL_STATIC_JAVA_LIBRARIES := \
         android-common jsr305
-LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4
+
+LOCAL_STATIC_ANDROID_LIBRARIES += androidx.car_car
 
 # Include all the resources regardless of system supported locales
 LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
 
-LOCAL_SDK_VERSION := current
+#TODO(b/72620511) Apps should not use platform APIs directly
+#LOCAL_SDK_VERSION := current
+LOCAL_PRIVATE_PLATFORM_APIS := true
 
 # LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 LOCAL_PROGUARD_ENABLED := disabled
 
 LOCAL_DEX_PREOPT := false
 
-include packages/apps/Car/libs/car-stream-ui-lib/car-stream-ui-lib.mk
-include packages/services/Car/car-support-lib/car-support.mk
-
 include $(BUILD_PACKAGE)
 
 endif
diff --git a/res/values-w1024dp/dimens.xml b/res/values-w1024dp/dimens.xml
index ad1c365..3be1608 100644
--- a/res/values-w1024dp/dimens.xml
+++ b/res/values-w1024dp/dimens.xml
@@ -14,8 +14,9 @@
      limitations under the License.
 -->
 <resources>
-    <dimen name="keyboard_key_margin">112dp</dimen>
-    <dimen name="keyboard_key_size">96dp</dimen>
+    <dimen name="keyboard_key_margin">24dp</dimen>
+    <dimen name="keyboard_key_size">90dp</dimen>
     <dimen name="keyboard_half_key_size">48dp</dimen>
-    <dimen name="keyboard_key_horizontal_tiny_gap">4dp</dimen>
-</resources>
\ No newline at end of file
+    <dimen name="keyboard_key_horizontal_tiny_gap">2dp</dimen>
+    <dimen name="keyboard_key_spacebar_width">365dp</dimen>
+</resources>
diff --git a/res/values-w1280dp/dimens.xml b/res/values-w1280dp/dimens.xml
index abbb8ea..ab5b9b6 100644
--- a/res/values-w1280dp/dimens.xml
+++ b/res/values-w1280dp/dimens.xml
@@ -18,4 +18,5 @@
     <dimen name="keyboard_key_size">96dp</dimen>
     <dimen name="keyboard_half_key_size">48dp</dimen>
     <dimen name="keyboard_key_horizontal_tiny_gap">4dp</dimen>
-</resources>
\ No newline at end of file
+    <dimen name="keyboard_key_spacebar_width">400dp</dimen>
+</resources>
diff --git a/res/xml/method.xml b/res/xml/method.xml
index 5de859b..2f0fc02 100644
--- a/res/xml/method.xml
+++ b/res/xml/method.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <input-method xmlns:android="http://schemas.android.com/apk/res/android"
-    android:settingsActivity="com.android.inputmethod.latin.settings.SettingsActivity"
     android:isDefault="true"
     android:supportsSwitchingToNextInputMethod="false">
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
@@ -10,4 +9,4 @@
         android:languageTag="en-US"
         android:imeSubtypeMode="keyboard"
         android:isAsciiCapable="true" />
-</input-method>
\ No newline at end of file
+</input-method>
diff --git a/src/com/android/inputmethod/latin/CarLatinIME.java b/src/com/android/inputmethod/latin/CarLatinIME.java
index 861fd8d..fd41559 100644
--- a/src/com/android/inputmethod/latin/CarLatinIME.java
+++ b/src/com/android/inputmethod/latin/CarLatinIME.java
@@ -15,9 +15,10 @@
  */
 package com.android.inputmethod.latin;
 
+import android.car.Car;
 import android.car.CarNotConnectedException;
-import android.car.hardware.CarSensorEvent;
-import android.car.hardware.CarSensorManager;
+import android.car.drivingstate.CarUxRestrictions;
+import android.car.drivingstate.CarUxRestrictionsManager;
 import android.content.ComponentName;
 import android.content.ServiceConnection;
 import android.content.res.Configuration;
@@ -27,8 +28,6 @@
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
-import android.car.Car;
-
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -47,10 +46,10 @@
 /**
  * IME for car use case. 2 features are added compared to the original IME.
  * <ul>
- *     <li> Monitor driving status, and put a lockout screen on top of the current keyboard if
- *          keyboard input is not allowed.
- *     <li> Add a close keyboard button so that user dismiss the keyboard when "back" button is not
- *          present in the system navigation bar.
+ * <li> Monitor driving status, and put a lockout screen on top of the current keyboard if
+ * keyboard input is not allowed.
+ * <li> Add a close keyboard button so that user dismiss the keyboard when "back" button is not
+ * present in the system navigation bar.
  * </ul>
  */
 public class CarLatinIME extends InputMethodService {
@@ -71,7 +70,7 @@
     private Keyboard mQweKeyboard;
     private Keyboard mSymbolKeyboard;
     private Car mCar;
-    private CarSensorManager mSensorManager;
+    private CarUxRestrictionsManager mUxRManager;
 
     private View mLockoutView;
     private KeyboardView mPopupKeyboardView;
@@ -87,9 +86,11 @@
 
     private static final class HideKeyboardHandler extends Handler {
         private final WeakReference<CarLatinIME> mIME;
+
         public HideKeyboardHandler(CarLatinIME ime) {
             mIME = new WeakReference<CarLatinIME>(ime);
         }
+
         @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
@@ -107,10 +108,13 @@
                 public void onServiceConnected(ComponentName name, IBinder service) {
                     Log.d(TAG, "Car Service connected");
                     try {
-                        mSensorManager = (CarSensorManager) mCar.getCarManager(Car.SENSOR_SERVICE);
-                        mSensorManager.registerListener(mCarSensorListener,
-                                CarSensorManager.SENSOR_TYPE_DRIVING_STATUS,
-                                CarSensorManager.SENSOR_RATE_FASTEST);
+                        mUxRManager = (CarUxRestrictionsManager) mCar.getCarManager(
+                                Car.CAR_UX_RESTRICTION_SERVICE);
+                        if (mUxRManager != null) {
+                            mUxRManager.registerListener(mCarUxRListener);
+                        } else {
+                            Log.e(TAG, "CarUxRestrictions service not available");
+                        }
                     } catch (CarNotConnectedException e) {
                         Log.e(TAG, "car not connected", e);
                     }
@@ -122,17 +126,16 @@
                 }
             };
 
-    private final CarSensorManager.OnSensorChangedListener mCarSensorListener =
-            new CarSensorManager.OnSensorChangedListener() {
+    private final CarUxRestrictionsManager.onUxRestrictionsChangedListener mCarUxRListener =
+            new CarUxRestrictionsManager.onUxRestrictionsChangedListener() {
                 @Override
-                public void onSensorChanged(CarSensorEvent event) {
-                    if (event.sensorType != CarSensorManager.SENSOR_TYPE_DRIVING_STATUS) {
+                public void onUxRestrictionsChanged(CarUxRestrictions restrictions) {
+                    if (restrictions == null) {
                         return;
                     }
-                    int drivingStatus = event.getDrivingStatusData(null).status;
-
                     boolean keyboardEnabled =
-                            (drivingStatus & CarSensorEvent.DRIVE_STATUS_NO_KEYBOARD_INPUT) == 0;
+                            (restrictions.getActiveRestrictions()
+                                    & CarUxRestrictions.UX_RESTRICTIONS_NO_KEYBOARD) == 0;
                     mHandler.sendMessage(mHandler.obtainMessage(
                             MSG_ENABLE_KEYBOARD, keyboardEnabled ? 1 : 0, 0, null));
                 }
@@ -184,7 +187,6 @@
     }
 
 
-
     @Override
     public void onStartInputView(EditorInfo editorInfo, boolean reastarting) {
         super.onStartInputView(editorInfo, reastarting);
@@ -260,7 +262,7 @@
                 @Override
                 public void onKey(int primaryCode, int[] keyCodes) {
                     if (Log.isLoggable(TAG, Log.DEBUG)) {
-                      Log.d(TAG, "onKey " + primaryCode);
+                        Log.d(TAG, "onKey " + primaryCode);
                     }
                     InputConnection inputConnection = getCurrentInputConnection();
                     switch (primaryCode) {
@@ -309,22 +311,31 @@
                             }
                             break;
                         case KEYCODE_ENTER:
-                            final int imeOptionsActionId = getImeOptionsActionIdFromEditorInfo(mEditorInfo);
+                            final int imeOptionsActionId = getImeOptionsActionIdFromEditorInfo(
+                                    mEditorInfo);
                             if (IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {
-                                // Either we have an actionLabel and we should performEditorAction with
+                                // Either we have an actionLabel and we should
+                                // performEditorAction with
                                 // actionId regardless of its value.
                                 inputConnection.performEditorAction(mEditorInfo.actionId);
                             } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {
-                                // We didn't have an actionLabel, but we had another action to execute.
-                                // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast,
-                                // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it
-                                // means there should be an action and the app didn't bother to set a specific
-                                // code for it - presumably it only handles one. It does not have to be treated
-                                // in any specific way: anything that is not IME_ACTION_NONE should be sent to
+                                // We didn't have an actionLabel, but we had another action to
+                                // execute.
+                                // EditorInfo.IME_ACTION_NONE explicitly means no action. In
+                                // contrast,
+                                // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an
+                                // action, so it
+                                // means there should be an action and the app didn't bother to
+                                // set a specific
+                                // code for it - presumably it only handles one. It does not have
+                                // to be treated
+                                // in any specific way: anything that is not IME_ACTION_NONE
+                                // should be sent to
                                 // performEditorAction.
                                 inputConnection.performEditorAction(imeOptionsActionId);
                             } else {
-                                // No action label, and the action from imeOptions is NONE: this is a regular
+                                // No action label, and the action from imeOptions is NONE: this
+                                // is a regular
                                 // enter key that should input a carriage return.
                                 String txt = Character.toString((char) primaryCode);
                                 if (mKeyboardView.isShifted()) {
@@ -345,7 +356,7 @@
                                 commitText = commitText.toUpperCase(mLocale);
                             }
                             if (Log.isLoggable(TAG, Log.DEBUG)) {
-                              Log.d(TAG, "commitText " + commitText);
+                                Log.d(TAG, "commitText " + commitText);
                             }
                             inputConnection.commitText(commitText, 1);
                             updateCapitalization();
diff --git a/src/com/android/inputmethod/latin/car/KeyboardView.java b/src/com/android/inputmethod/latin/car/KeyboardView.java
index f641768..b237bae 100644
--- a/src/com/android/inputmethod/latin/car/KeyboardView.java
+++ b/src/com/android/inputmethod/latin/car/KeyboardView.java
@@ -382,7 +382,7 @@
         mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
         mDisambiguateSwipe = true;
 
-        int color = getResources().getColor(com.android.car.stream.ui.R.color.car_700);
+        int color = getResources().getColor(R.color.car_dark_blue_grey_700);
         mPopupScrimColor = Color.argb(
                 SCRIM_ALPHA, Color.red(color), Color.green(color), Color.blue(color));
         mBackgroundColor = Color.TRANSPARENT;