Snap for 7498377 from bf60673bbbc08002688b14e1b856eec925895afd to sc-release

Change-Id: I64653ca12fafd0b036443bc48e5b21a9d5980d4b
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java
index e8510b7..a4e1af6 100644
--- a/src/com/android/launcher3/ExtendedEditText.java
+++ b/src/com/android/launcher3/ExtendedEditText.java
@@ -70,6 +70,9 @@
     public boolean onKeyPreIme(int keyCode, KeyEvent event) {
         // If this is a back key, propagate the key back to the listener
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
+            if (TextUtils.isEmpty(getText())) {
+                hideKeyboard();
+            }
             if (mBackKeyListener != null) {
                 return mBackKeyListener.onBackKey();
             }
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d107afd..1cfe7e0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2330,30 +2330,32 @@
 
         try {
             final LauncherAppWidgetProviderInfo appWidgetInfo;
-            String reason = "";
+            String removalReason = "";
 
             if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)) {
                 // If the provider is not ready, bind as a pending widget.
                 appWidgetInfo = null;
-                reason = "the provider not ready.";
+                removalReason = "the provider isn't ready.";
             } else if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
                 // The widget id is not valid. Try to find the widget based on the provider info.
                 appWidgetInfo = mAppWidgetManager.findProvider(item.providerName, item.user);
                 if (appWidgetInfo == null) {
                     if (WidgetsModel.GO_DISABLE_WIDGETS) {
-                        reason = "widgets are disabled on go device.";
+                        removalReason = "widgets are disabled on go device.";
                     } else {
-                        reason = "WidgetManagerHelper cannot find a provider from provider info.";
+                        removalReason =
+                                "WidgetManagerHelper cannot find a provider from provider info.";
                     }
                 }
             } else {
                 appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(item.appWidgetId);
                 if (appWidgetInfo == null) {
                     if (item.appWidgetId <= LauncherAppWidgetInfo.CUSTOM_WIDGET_ID) {
-                        reason = "CustomWidgetManager cannot find provider from that widget id .";
+                        removalReason =
+                                "CustomWidgetManager cannot find provider from that widget id.";
                     } else {
-                        reason = "AppWidgetManager cannot find provider for that widget id."
-                                + " It could be due to AppWidgetService is not available, or the"
+                        removalReason = "AppWidgetManager cannot find provider for that widget id."
+                                + " It could be because AppWidgetService is not available, or the"
                                 + " appWidgetId has not been bound to a the provider yet, or you"
                                 + " don't have access to that appWidgetId.";
                     }
@@ -2366,7 +2368,7 @@
                 if (appWidgetInfo == null) {
                     FileLog.d(TAG, "Removing restored widget: id=" + item.appWidgetId
                             + " belongs to component " + item.providerName + " user " + item.user
-                            + ", as the provider is null and " + reason);
+                            + ", as the provider is null and " + removalReason);
                     getModelWriter().deleteItemFromDatabase(item);
                     return null;
                 }
diff --git a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java
index 6de3e11..867c770 100644
--- a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java
+++ b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java
@@ -98,12 +98,17 @@
     private final IconCache mIconCache;
     private final UserCache mUserCache;
     private final CacheDb mDb;
+    private final float mPreviewBoxCornerRadius;
 
     public DatabaseWidgetPreviewLoader(Context context, IconCache iconCache) {
         mContext = context;
         mIconCache = iconCache;
         mUserCache = UserCache.INSTANCE.get(context);
         mDb = new CacheDb(context);
+        float previewCornerRadius = RoundedCornerEnforcement.computeEnforcedRadius(context);
+        mPreviewBoxCornerRadius = previewCornerRadius > 0
+                ? previewCornerRadius
+                : mContext.getResources().getDimension(R.dimen.widget_preview_corner_radius);
     }
 
     /**
@@ -521,7 +526,7 @@
 
         ShadowGenerator.Builder builder = new ShadowGenerator.Builder(Color.WHITE);
         builder.shadowBlur = res.getDimension(R.dimen.widget_preview_shadow_blur);
-        builder.radius = res.getDimension(R.dimen.widget_preview_corner_radius);
+        builder.radius = mPreviewBoxCornerRadius;
         builder.keyShadowDistance = res.getDimension(R.dimen.widget_preview_key_shadow_distance);
 
         builder.bounds.set(builder.shadowBlur, builder.shadowBlur,