Gracefully handle exception when processing widget loads event while device is locked.

Bug: 277189566
Test: test starting launcher and editing widgets
Change-Id: Id15da3f3471374b02f1e2bf2e0a45dc801957241
diff --git a/src/com/android/launcher3/widget/WidgetManagerHelper.java b/src/com/android/launcher3/widget/WidgetManagerHelper.java
index 15fa844..737cdbd 100644
--- a/src/com/android/launcher3/widget/WidgetManagerHelper.java
+++ b/src/com/android/launcher3/widget/WidgetManagerHelper.java
@@ -78,8 +78,16 @@
             return allWidgetsSteam(mContext).collect(Collectors.toList());
         }
 
-        return mAppWidgetManager.getInstalledProvidersForPackage(
-                packageUser.mPackageName, packageUser.mUser);
+        try {
+            return mAppWidgetManager.getInstalledProvidersForPackage(
+                    packageUser.mPackageName, packageUser.mUser);
+        } catch (IllegalStateException e) {
+            // b/277189566: Launcher will load the widget when it gets the user-unlock event.
+            // If exception is thrown because of device is locked, it means a race condition occurs
+            // that the user got locked again while launcher is processing the event. In this case
+            // we should return empty list.
+            return Collections.emptyList();
+        }
     }
 
     /**