Fix kotlin nullable errors in Launcher3

Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.

This relands I26edfec35dca14abe90b08e3c74de0446eda95d2 with a fix in
SplitSelectDataHolder.kt to call createPackageContext when user is null
instead of asserting that it is not null.

Bug: 294110802
Test: builds
Test: WMShellFlickerServiceTests
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:4cc251e6c1bd5e06ef24a92e08aae043cf3f2587)
Merged-In: I4525d0fa83a1db9cc5cff90f340fc3f863537c01
Change-Id: I4525d0fa83a1db9cc5cff90f340fc3f863537c01

(cherry picked from commit 70ca32bca24d388f219ee2bf600737801fe10184)
Change-Id: I71ad1016e7bb2c28d7b47c7cdbd9c3a57a79d6bd
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
index e073264..d9513f5 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
@@ -160,14 +160,16 @@
     }
 
     private fun getShortcutInfo(intent: Intent?, user: UserHandle?): ShortcutInfo? {
-        if (intent?.getPackage() == null) {
-            return null
-        }
+        val intentPackage = intent?.getPackage() ?: return null
         val shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID)
                 ?: return null
         try {
-            val context: Context = context.createPackageContextAsUser(
-                    intent.getPackage(), 0 /* flags */, user)
+            val context: Context =
+                if (user != null) {
+                    context.createPackageContextAsUser(intentPackage, 0 /* flags */, user)
+                } else {
+                    context.createPackageContext(intentPackage, 0 /* *flags */)
+                }
             return ShortcutInfo.Builder(context, shortcutId).build()
         } catch (e: PackageManager.NameNotFoundException) {
             Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage())
@@ -405,4 +407,4 @@
         writer.println("$prefix\tinitialShortcut= $initialShortcut")
         writer.println("$prefix\tsecondShortcut= $secondShortcut")
     }
-}
\ No newline at end of file
+}