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.
Bug: 294110802
Test: builds
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2608381792389b60ba37c08afcea09dca3c6ff9c)
Merged-In: I26edfec35dca14abe90b08e3c74de0446eda95d2
Change-Id: I26edfec35dca14abe90b08e3c74de0446eda95d2
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt
index a347908..17d10d3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt
@@ -101,10 +101,10 @@
@SuppressLint("UseSwitchCompatOrMaterialCode")
override fun onFinishInflate() {
super.onFinishInflate()
- val taskbarSwitchOption = findViewById<LinearLayout>(R.id.taskbar_switch_option)
- val alwaysShowTaskbarSwitch = findViewById<Switch>(R.id.taskbar_pinning_switch)
+ val taskbarSwitchOption = requireViewById<LinearLayout>(R.id.taskbar_switch_option)
+ val alwaysShowTaskbarSwitch = requireViewById<Switch>(R.id.taskbar_pinning_switch)
val navigationModeChangeOption =
- findViewById<LinearLayout>(R.id.navigation_mode_switch_option)
+ requireViewById<LinearLayout>(R.id.navigation_mode_switch_option)
alwaysShowTaskbarSwitch.isChecked = alwaysShowTaskbarOn
taskbarSwitchOption.setOnClickListener {
alwaysShowTaskbarSwitch.isClickable = true
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
index e073264..f32e9bc 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
@@ -156,18 +156,19 @@
*/
fun setSecondTask(pendingIntent: PendingIntent) {
secondPendingIntent = pendingIntent
- secondUser = pendingIntent.creatorUserHandle!!
+ secondUser = pendingIntent.creatorUserHandle
}
- private fun getShortcutInfo(intent: Intent?, user: UserHandle?): ShortcutInfo? {
- if (intent?.getPackage() == null) {
+ private fun getShortcutInfo(intent: Intent?, user: UserHandle): ShortcutInfo? {
+ val intentPackage = intent?.getPackage()
+ if (intentPackage == null) {
return null
}
val shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID)
?: return null
try {
val context: Context = context.createPackageContextAsUser(
- intent.getPackage(), 0 /* flags */, user)
+ intentPackage, 0 /* flags */, user)
return ShortcutInfo.Builder(context, shortcutId).build()
} catch (e: PackageManager.NameNotFoundException) {
Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage())
@@ -250,7 +251,7 @@
* convert [secondIntent]
*/
private fun convertIntentsToFinalTypes() {
- initialShortcut = getShortcutInfo(initialIntent, initialUser)
+ initialShortcut = getShortcutInfo(initialIntent, checkNotNull(initialUser))
initialPendingIntent = getPendingIntent(initialIntent, initialUser)
initialIntent = null
@@ -264,7 +265,7 @@
return
}
- secondShortcut = getShortcutInfo(secondIntent, secondUser)
+ secondShortcut = getShortcutInfo(secondIntent, checkNotNull(secondUser))
secondPendingIntent = getPendingIntent(secondIntent, secondUser)
secondIntent = null
}
@@ -405,4 +406,4 @@
writer.println("$prefix\tinitialShortcut= $initialShortcut")
writer.println("$prefix\tsecondShortcut= $secondShortcut")
}
-}
\ No newline at end of file
+}