Snap for 7495312 from 284482a0406cf0aa993609f7bc8a0a61d257f6b2 to sc-v2-release

Change-Id: I98bb60fc0f34128b42ff722056819539faacce0e
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index bf9059f..a48e2c0 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -103,16 +103,10 @@
              android:clearTaskOnLaunch="true"
              android:exported="false"/>
 
-        <!--
-        Activity for gesture nav onboarding.
-        It's protected by android.permission.REBOOT to ensure that only system apps can start it
-        (setup wizard already has this permission)
-        -->
         <activity android:name="com.android.quickstep.interaction.GestureSandboxActivity"
             android:autoRemoveFromRecents="true"
             android:excludeFromRecents="true"
             android:screenOrientation="portrait"
-            android:permission="android.permission.REBOOT"
             android:exported="true">
             <intent-filter>
                 <action android:name="com.android.quickstep.action.GESTURE_SANDBOX"/>
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 82eaecd..deeaaa6 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -42,6 +42,7 @@
 import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS;
 import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED;
 import static com.android.quickstep.GestureState.STATE_END_TARGET_SET;
+import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_CANCELED;
 import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED;
 import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
 import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
@@ -378,6 +379,17 @@
             activity.runOnceOnStart(this::onLauncherStart);
         }
 
+        // Set up a entire animation lifecycle callback to notify the current recents view when
+        // the animation is canceled
+        mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> {
+                ThumbnailData snapshot = mGestureState.getRecentsAnimationCanceledSnapshot();
+                if (snapshot != null) {
+                    RecentsModel.INSTANCE.get(mContext).onTaskSnapshotChanged(
+                            mRecentsView.getRunningTaskId(), snapshot);
+                    mRecentsView.onRecentsAnimationComplete();
+                }
+            });
+
         setupRecentsViewUi();
         linkRecentsViewScroll();
 
@@ -671,6 +683,9 @@
             mRecentsAnimationController.setUseLauncherSystemBarFlags(swipeUpThresholdPassed
                     ||  (quickswitchThresholdPassed && centermostTaskFlags != 0));
             mRecentsAnimationController.setSplitScreenMinimized(swipeUpThresholdPassed);
+            // Provide a hint to WM the direction that we will be settling in case the animation
+            // needs to be canceled
+            mRecentsAnimationController.setWillFinishToHome(swipeUpThresholdPassed);
 
             if (swipeUpThresholdPassed) {
                 mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0);
@@ -1468,9 +1483,6 @@
             final boolean refreshView = !LIVE_TILE.get() /* refreshView */;
             boolean finishTransitionPosted = false;
             if (mRecentsAnimationController != null) {
-                if (LIVE_TILE.get()) {
-                    mRecentsAnimationController.getController().setWillFinishToHome(true);
-                }
                 // Update the screenshot of the task
                 if (mTaskSnapshot == null) {
                     UI_HELPER_EXECUTOR.execute(() -> {
diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java
index 6ad7f55..a302a07 100644
--- a/quickstep/src/com/android/quickstep/GestureState.java
+++ b/quickstep/src/com/android/quickstep/GestureState.java
@@ -142,6 +142,8 @@
     private RemoteAnimationTargetCompat mLastAppearedTaskTarget;
     private Set<Integer> mPreviouslyAppearedTaskIds = new HashSet<>();
     private int mLastStartedTaskId = -1;
+    private RecentsAnimationController mRecentsAnimationController;
+    private ThumbnailData mRecentsAnimationCanceledSnapshot;
 
     /** The time when the swipe up gesture is triggered. */
     private long mSwipeUpStartTimeMs;
@@ -351,13 +353,20 @@
     @Override
     public void onRecentsAnimationStart(RecentsAnimationController controller,
             RecentsAnimationTargets targets) {
+        mRecentsAnimationController = controller;
         mStateCallback.setState(STATE_RECENTS_ANIMATION_STARTED);
     }
 
     @Override
     public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
+        mRecentsAnimationCanceledSnapshot = thumbnailData;
         mStateCallback.setState(STATE_RECENTS_ANIMATION_CANCELED);
         mStateCallback.setState(STATE_RECENTS_ANIMATION_ENDED);
+        if (mRecentsAnimationCanceledSnapshot != null) {
+            // Clean up the screenshot to finalize the recents animation cancel
+            mRecentsAnimationController.cleanupScreenshot();
+            mRecentsAnimationCanceledSnapshot = null;
+        }
     }
 
     @Override
@@ -366,6 +375,14 @@
         mStateCallback.setState(STATE_RECENTS_ANIMATION_ENDED);
     }
 
+    /**
+     * Returns the canceled animation thumbnail data. This call only returns a value while
+     * STATE_RECENTS_ANIMATION_CANCELED state is being set.
+     */
+    ThumbnailData getRecentsAnimationCanceledSnapshot() {
+        return mRecentsAnimationCanceledSnapshot;
+    }
+
     void setSwipeUpStartTimeMs(long uptimeMs) {
         mSwipeUpStartTimeMs = uptimeMs;
     }
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
index 9e69ef9..f343485 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
@@ -159,6 +159,14 @@
     }
 
     /**
+     * @see IRecentsAnimationController#cleanupScreenshot()
+     */
+    @UiThread
+    public void cleanupScreenshot() {
+        UI_HELPER_EXECUTOR.execute(() -> mController.cleanupScreenshot());
+    }
+
+    /**
      * @see RecentsAnimationControllerCompat#detachNavigationBarFromApp
      */
     @UiThread
@@ -175,6 +183,14 @@
     }
 
     /**
+     * @see IRecentsAnimationController#setWillFinishToHome(boolean)
+     */
+    @UiThread
+    public void setWillFinishToHome(boolean willFinishToHome) {
+        UI_HELPER_EXECUTOR.execute(() -> mController.setWillFinishToHome(willFinishToHome));
+    }
+
+    /**
      * Sets the final surface transaction on a Task. This is used by Launcher to notify the system
      * that animating Activity to PiP has completed and the associated task surface should be
      * updated accordingly. This should be called before `finish`
diff --git a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
index cf523d0..bc49133 100644
--- a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
@@ -18,6 +18,7 @@
 import android.graphics.Color;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.util.DisplayMetrics;
 import android.view.Display;
 import android.view.View;
@@ -122,9 +123,9 @@
         mCurrentTutorialStep = mTutorialSteps[mCurrentStep];
         mFragment = TutorialFragment.newInstance(mCurrentTutorialStep);
         getSupportFragmentManager().beginTransaction()
-            .replace(R.id.gesture_tutorial_fragment_container, mFragment)
-            .runOnCommit(() -> mFragment.onAttachedToWindow())
-            .commit();
+                .replace(R.id.gesture_tutorial_fragment_container, mFragment)
+                .runOnCommit(() -> mFragment.onAttachedToWindow())
+                .commit();
         mCurrentStep++;
     }
 
@@ -141,21 +142,33 @@
 
     private TutorialType[] getTutorialSteps(Bundle extras) {
         TutorialType[] defaultSteps = new TutorialType[] {TutorialType.LEFT_EDGE_BACK_NAVIGATION};
+        mCurrentStep = 1;
+        mNumSteps = 1;
 
         if (extras == null || !extras.containsKey(KEY_TUTORIAL_STEPS)) {
             return defaultSteps;
         }
 
-        String[] tutorialStepNames = extras.getStringArray(KEY_TUTORIAL_STEPS);
+        Object savedSteps = extras.get(KEY_TUTORIAL_STEPS);
         int currentStep = extras.getInt(KEY_CURRENT_STEP, -1);
+        String[] savedStepsNames;
 
-        if (tutorialStepNames == null) {
+        if (savedSteps instanceof String) {
+            savedStepsNames = TextUtils.isEmpty((String) savedSteps)
+                    ? null : ((String) savedSteps).split(",");
+        } else if (savedSteps instanceof String[]) {
+            savedStepsNames = (String[]) savedSteps;
+        } else {
             return defaultSteps;
         }
 
-        TutorialType[] tutorialSteps = new TutorialType[tutorialStepNames.length];
-        for (int i = 0; i < tutorialStepNames.length; i++) {
-            tutorialSteps[i] = TutorialType.valueOf(tutorialStepNames[i]);
+        if (savedStepsNames == null) {
+            return defaultSteps;
+        }
+
+        TutorialType[] tutorialSteps = new TutorialType[savedStepsNames.length];
+        for (int i = 0; i < savedStepsNames.length; i++) {
+            tutorialSteps[i] = TutorialType.valueOf(savedStepsNames[i]);
         }
 
         mCurrentStep = Math.max(currentStep, 1);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 9c20789..3a445c3 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -404,8 +404,6 @@
 
     private final TaskOverlayFactory mTaskOverlayFactory;
 
-    private int mOrientation;
-
     protected boolean mDisallowScrollToClearAll;
     private boolean mOverlayEnabled;
     protected boolean mFreezeViewVisibility;
@@ -599,7 +597,6 @@
                 .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity);
         mModel = RecentsModel.INSTANCE.get(context);
         mIdp = InvariantDeviceProfile.INSTANCE.get(context);
-        mOrientation = getResources().getConfiguration().orientation;
 
         mClearAllButton = (ClearAllButton) LayoutInflater.from(context)
                 .inflate(R.layout.overview_clear_all_button, this, false);
@@ -2701,15 +2698,7 @@
     @Override
     protected void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
-        if (LIVE_TILE.get() && mEnableDrawingLiveTile && newConfig.orientation != mOrientation) {
-            switchToScreenshot(
-                    () -> finishRecentsAnimation(true /* toRecents */, false /* showPip */,
-                            this::updateRecentsRotation));
-            mEnableDrawingLiveTile = false;
-        } else {
-            updateRecentsRotation();
-        }
-        mOrientation = newConfig.orientation;
+        updateRecentsRotation();
     }
 
     /**
@@ -3477,16 +3466,26 @@
             if (onFinishComplete != null) {
                 onFinishComplete.run();
             }
-            // After we finish the recents animation, the current task id should be correctly
-            // reset so that when the task is launched from Overview later, it goes through the
-            // flow of starting a new task instead of finishing recents animation to app. A
-            // typical example of this is (1) user swipes up from app to Overview (2) user
-            // taps on QSB (3) user goes back to Overview and launch the most recent task.
-            setCurrentTask(-1);
-            mRecentsAnimationController = null;
+            onRecentsAnimationComplete();
         }, sendUserLeaveHint);
     }
 
+    /**
+     * Called when a running recents animation has finished or canceled.
+     */
+    public void onRecentsAnimationComplete() {
+        // At this point, the recents animation is not running and if the animation was canceled
+        // by a display rotation then reset this state to show the screenshot
+        setRunningTaskViewShowScreenshot(true);
+        // After we finish the recents animation, the current task id should be correctly
+        // reset so that when the task is launched from Overview later, it goes through the
+        // flow of starting a new task instead of finishing recents animation to app. A
+        // typical example of this is (1) user swipes up from app to Overview (2) user
+        // taps on QSB (3) user goes back to Overview and launch the most recent task.
+        setCurrentTask(-1);
+        mRecentsAnimationController = null;
+    }
+
     public void setDisallowScrollToClearAll(boolean disallowScrollToClearAll) {
         if (mDisallowScrollToClearAll != disallowScrollToClearAll) {
             mDisallowScrollToClearAll = disallowScrollToClearAll;
diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml
index d1e1253..6e81180 100644
--- a/res/values-af/strings.xml
+++ b/res/values-af/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"Kennisgewings"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"Raak en hou om \'n kortpad te skuif."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"Dubbeltik en hou om \'n kortpad te skuif of gebruik gepasmaakte handelinge."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"Geen plek op hierdie tuisskerm nie"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"Geen plek meer in die Gunstelinge-laai nie"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"Programmelys"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"Lys persoonlike programme"</string>
diff --git a/res/values-az/strings.xml b/res/values-az/strings.xml
index 3670b01..1bbc006 100644
--- a/res/values-az/strings.xml
+++ b/res/values-az/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"Bildirişlər"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"Qısayolu daşımaq üçün toxunub saxlayın."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"Qısayolu daşımaq üçün iki dəfə toxunub saxlayın və ya fərdi əməliyyatlardan istifadə edin."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"Bu Əsas ekranda yer qalmayıb"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"Favoritlər-də yer yoxdur"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"Tətbiq siyahısı"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"Şəxsi tətbiqlərin siyahısı"</string>
diff --git a/res/values-bn/strings.xml b/res/values-bn/strings.xml
index 62b5c5d..aa32151 100644
--- a/res/values-bn/strings.xml
+++ b/res/values-bn/strings.xml
@@ -46,10 +46,8 @@
     <string name="widget_button_text" msgid="2880537293434387943">"উইজেট"</string>
     <string name="widgets_full_sheet_search_bar_hint" msgid="8484659090860596457">"সার্চ করুন"</string>
     <string name="widgets_full_sheet_cancel_button_description" msgid="5766167035728653605">"সার্চ বক্স থেকে টেক্সট মুছুন"</string>
-    <!-- no translation found for no_widgets_available (4337693382501046170) -->
-    <skip />
-    <!-- no translation found for no_search_results (3787956167293097509) -->
-    <skip />
+    <string name="no_widgets_available" msgid="4337693382501046170">"উইজেট এবং শর্টকার্ট উপলভ্য নেই"</string>
+    <string name="no_search_results" msgid="3787956167293097509">"কোনও উইজেট বা শর্টকার্ট খুঁজে পাওয়া যায়নি"</string>
     <string name="widgets_full_sheet_personal_tab" msgid="2743540105607120182">"ব্যক্তিগত"</string>
     <string name="widgets_full_sheet_work_tab" msgid="3767150027110633765">"অফিস"</string>
     <string name="widget_category_conversations" msgid="8894438636213590446">"কথোপকথন"</string>
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index a842935..f1860d4 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -103,7 +103,7 @@
     <string name="folder_name_format_exact" msgid="8626242716117004803">"Carpeta: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> elements"</string>
     <string name="folder_name_format_overflow" msgid="4270108890534995199">"Carpeta: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> o més elements"</string>
     <string name="wallpaper_button_text" msgid="8404103075899945851">"Fons de pantalla"</string>
-    <string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Fons de pantalla i estil"</string>
+    <string name="styles_wallpaper_button_text" msgid="8216961355289236794">"Estil i fons de pantalla"</string>
     <string name="settings_button_text" msgid="8873672322605444408">"Config. pantalla d\'inici"</string>
     <string name="msg_disabled_by_admin" msgid="6898038085516271325">"Desactivada per l\'administrador"</string>
     <string name="allow_rotation_title" msgid="7728578836261442095">"Permet la rotació de la pantalla d\'inici"</string>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index dfa6337..aebf5e0 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -46,10 +46,8 @@
     <string name="widget_button_text" msgid="2880537293434387943">"Widgets"</string>
     <string name="widgets_full_sheet_search_bar_hint" msgid="8484659090860596457">"Suche"</string>
     <string name="widgets_full_sheet_cancel_button_description" msgid="5766167035728653605">"Text aus dem Suchfeld löschen"</string>
-    <!-- no translation found for no_widgets_available (4337693382501046170) -->
-    <skip />
-    <!-- no translation found for no_search_results (3787956167293097509) -->
-    <skip />
+    <string name="no_widgets_available" msgid="4337693382501046170">"Widgets und Shortcuts nicht verfügbar"</string>
+    <string name="no_search_results" msgid="3787956167293097509">"Keine Widgets oder Shortcuts gefunden"</string>
     <string name="widgets_full_sheet_personal_tab" msgid="2743540105607120182">"Privat"</string>
     <string name="widgets_full_sheet_work_tab" msgid="3767150027110633765">"Geschäftlich"</string>
     <string name="widget_category_conversations" msgid="8894438636213590446">"Unterhaltungen"</string>
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index f8b3997..78ecc70 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"Jakinarazpenak"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"Eduki sakatuta lasterbide bat mugitzeko."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"Sakatu birritan eta eduki sakatuta lasterbide bat mugitzeko edo ekintza pertsonalizatuak erabiltzeko."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"Ez dago tokirik hasierako pantailan"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"Ez dago toki gehiago Gogokoak erretiluan"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"Aplikazioen zerrenda"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"Aplikazio pertsonalen zerrenda"</string>
diff --git a/res/values-ka/strings.xml b/res/values-ka/strings.xml
index 579ff60..fd67306 100644
--- a/res/values-ka/strings.xml
+++ b/res/values-ka/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"შეტყობინებები"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"შეხებით აირჩიეთ და გეჭიროთ მალსახმობის გადასაადგილებლად."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"ორმაგი შეხებით აირჩიეთ და გეჭიროთ მალსახმობის გადასაადგილებლად ან მორგებული მოქმედებების გამოსაყენებლად."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"ამ მთავარ ეკრანზე ადგილი არ არის"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"რჩეულების თაროზე ადგილი არ არის"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"აპების სია"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"პერსონალური აპების სია"</string>
diff --git a/res/values-kk/strings.xml b/res/values-kk/strings.xml
index 5783873..64771de 100644
--- a/res/values-kk/strings.xml
+++ b/res/values-kk/strings.xml
@@ -76,7 +76,7 @@
     <string name="install_drop_target_label" msgid="2539096853673231757">"Орнату"</string>
     <string name="dismiss_prediction_label" msgid="3357562989568808658">"Қолданбаны ұсынбау"</string>
     <string name="pin_prediction" msgid="4196423321649756498">"Болжанған қолданбаны бекіту"</string>
-    <string name="permlab_install_shortcut" msgid="5632423390354674437">"төте пернелерді орнату"</string>
+    <string name="permlab_install_shortcut" msgid="5632423390354674437">"таңбаша орнату"</string>
     <string name="permdesc_install_shortcut" msgid="923466509822011139">"Қолданбаға пайдаланушының қатысуынсыз төте пернелерді қосу мүмкіндігін береді."</string>
     <string name="permlab_read_settings" msgid="1941457408239617576">"Негізгі экрандағы параметрлер мен төте пернелерді оқу"</string>
     <string name="permdesc_read_settings" msgid="5833423719057558387">"Қолданбаға Негізгі экрандағы параметрлер мен төте пернелерді оқу мүмкіндігін береді."</string>
diff --git a/res/values-ky/strings.xml b/res/values-ky/strings.xml
index 605ebe1..2ead1ea 100644
--- a/res/values-ky/strings.xml
+++ b/res/values-ky/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"Билдирмелер"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"Ыкчам баскычты жылдыруу үчүн коё бербей басып туруңуз."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"Ыкчам баскычты жылдыруу үчүн эки жолу таптап, кармап туруңуз же ыңгайлаштырылган аракеттерди колдонуңуз."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"Башкы экранда бош орун жок"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"Тандамалдар тайпасында орун калган жок"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"Колдонмолор тизмеси"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"Жеке колдономолордун тизмеси"</string>
diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml
index e7269ca..e4634dd 100644
--- a/res/values-mr/strings.xml
+++ b/res/values-mr/strings.xml
@@ -64,8 +64,7 @@
     <string name="notifications_header" msgid="1404149926117359025">"सूचना"</string>
     <string name="long_press_shortcut_to_add" msgid="5405328730817637737">"शॉर्टकट हलवण्यासाठी स्पर्श करा आणि धरून ठेवा."</string>
     <string name="long_accessible_way_to_add_shortcut" msgid="2199537273817090740">"शॉर्टकट हलवण्यासाठी किंवा कस्टम कृती वापरण्यासाठी दोनदा टॅप करा आणि धरून ठेवा."</string>
-    <!-- no translation found for out_of_space (6692471482459245734) -->
-    <skip />
+    <string name="out_of_space" msgid="6692471482459245734">"या होम स्क्रीनवर कोणतीही रूम नाही"</string>
     <string name="hotseat_out_of_space" msgid="7448809638125333693">"आवडीच्या ट्रे मध्ये आणखी जागा नाही"</string>
     <string name="all_apps_button_label" msgid="8130441508702294465">"अ‍ॅप्स सूची"</string>
     <string name="all_apps_button_personal_label" msgid="1315764287305224468">"वैयक्तिक अ‍ॅप्स सूची"</string>
diff --git a/res/values-pa/strings.xml b/res/values-pa/strings.xml
index ed0879f..ff9ed62 100644
--- a/res/values-pa/strings.xml
+++ b/res/values-pa/strings.xml
@@ -46,10 +46,8 @@
     <string name="widget_button_text" msgid="2880537293434387943">"ਵਿਜੇਟ"</string>
     <string name="widgets_full_sheet_search_bar_hint" msgid="8484659090860596457">"ਖੋਜੋ"</string>
     <string name="widgets_full_sheet_cancel_button_description" msgid="5766167035728653605">"ਖੋਜ ਬਾਕਸ ਤੋਂ ਸਪੱਸ਼ਟ ਲਿਖਤ"</string>
-    <!-- no translation found for no_widgets_available (4337693382501046170) -->
-    <skip />
-    <!-- no translation found for no_search_results (3787956167293097509) -->
-    <skip />
+    <string name="no_widgets_available" msgid="4337693382501046170">"ਵਿਜੇਟ ਜਾਂ ਸ਼ਾਰਟਕੱਟ ਉਪਲਬਧ ਨਹੀਂ ਹਨ"</string>
+    <string name="no_search_results" msgid="3787956167293097509">"ਕੋਈ ਵੀ ਵਿਜੇਟ ਜਾਂ ਸ਼ਾਰਟਕੱਟ ਨਹੀਂ ਮਿਲਿਆ"</string>
     <string name="widgets_full_sheet_personal_tab" msgid="2743540105607120182">"ਨਿੱਜੀ"</string>
     <string name="widgets_full_sheet_work_tab" msgid="3767150027110633765">"ਕਾਰਜ-ਸਥਾਨ"</string>
     <string name="widget_category_conversations" msgid="8894438636213590446">"ਗੱਲਾਂਬਾਤਾਂ"</string>
diff --git a/res/values-sq/strings.xml b/res/values-sq/strings.xml
index e39e3e7..833745f 100644
--- a/res/values-sq/strings.xml
+++ b/res/values-sq/strings.xml
@@ -46,10 +46,8 @@
     <string name="widget_button_text" msgid="2880537293434387943">"Miniaplikacionet"</string>
     <string name="widgets_full_sheet_search_bar_hint" msgid="8484659090860596457">"Kërko"</string>
     <string name="widgets_full_sheet_cancel_button_description" msgid="5766167035728653605">"Pastro tekstin nga kutia e kërkimit"</string>
-    <!-- no translation found for no_widgets_available (4337693382501046170) -->
-    <skip />
-    <!-- no translation found for no_search_results (3787956167293097509) -->
-    <skip />
+    <string name="no_widgets_available" msgid="4337693382501046170">"Miniaplikacionet dhe shkurtoret nuk ofrohen"</string>
+    <string name="no_search_results" msgid="3787956167293097509">"Nuk u gjet asnjë miniaplikacion ose shkurtore"</string>
     <string name="widgets_full_sheet_personal_tab" msgid="2743540105607120182">"Personale"</string>
     <string name="widgets_full_sheet_work_tab" msgid="3767150027110633765">"Puna"</string>
     <string name="widget_category_conversations" msgid="8894438636213590446">"Bisedat"</string>
diff --git a/res/values-ur/strings.xml b/res/values-ur/strings.xml
index 7fe31a6..3353539 100644
--- a/res/values-ur/strings.xml
+++ b/res/values-ur/strings.xml
@@ -46,10 +46,8 @@
     <string name="widget_button_text" msgid="2880537293434387943">"ویجیٹس"</string>
     <string name="widgets_full_sheet_search_bar_hint" msgid="8484659090860596457">"تلاش کریں"</string>
     <string name="widgets_full_sheet_cancel_button_description" msgid="5766167035728653605">"تلاش کے خانے سے ٹیکسٹ صاف کریں"</string>
-    <!-- no translation found for no_widgets_available (4337693382501046170) -->
-    <skip />
-    <!-- no translation found for no_search_results (3787956167293097509) -->
-    <skip />
+    <string name="no_widgets_available" msgid="4337693382501046170">"ویجیٹس اور شارٹ کٹس دستیاب نہیں ہیں"</string>
+    <string name="no_search_results" msgid="3787956167293097509">"کوئی ویجیٹ یا شارٹ کٹ نہیں ملا"</string>
     <string name="widgets_full_sheet_personal_tab" msgid="2743540105607120182">"ذاتی"</string>
     <string name="widgets_full_sheet_work_tab" msgid="3767150027110633765">"دفتری ویجیٹس"</string>
     <string name="widget_category_conversations" msgid="8894438636213590446">"گفتگوئیں"</string>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 231875c..750de92 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -142,6 +142,7 @@
 import com.android.launcher3.model.ItemInstallQueue;
 import com.android.launcher3.model.ModelUtils;
 import com.android.launcher3.model.ModelWriter;
+import com.android.launcher3.model.WidgetsModel;
 import com.android.launcher3.model.data.AppInfo;
 import com.android.launcher3.model.data.FolderInfo;
 import com.android.launcher3.model.data.ItemInfo;
@@ -2348,24 +2349,43 @@
 
         try {
             final LauncherAppWidgetProviderInfo appWidgetInfo;
+            String reason = "";
 
             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.";
             } 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.";
+                    } else {
+                        reason = "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 .";
+                    } else {
+                        reason = "AppWidgetManager cannot find provider for that widget id."
+                                + " It could be due to 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.";
+                    }
+                }
             }
 
             // If the provider is ready, but the width is not yet restored, try to restore it.
             if (!item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
                     && (item.restoreStatus != LauncherAppWidgetInfo.RESTORE_COMPLETED)) {
                 if (appWidgetInfo == null) {
-                    Log.d(TAG, "Removing restored widget: id=" + item.appWidgetId
-                            + " belongs to component " + item.providerName
-                            + ", as the provider is 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);
                     getModelWriter().deleteItemFromDatabase(item);
                     return null;
                 }