Snap for 11587190 from 70213c4c4aac3a92a8a00002a199dab05edec320 to mainline-healthfitness-release Change-Id: I4526813235d9f6cd58b8291306afc7093c928669
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/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt index 9b50c5d..c45c667 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt
@@ -97,8 +97,8 @@ override fun onFinishInflate() { super.onFinishInflate() - content = findViewById(R.id.content) - arrow = findViewById(R.id.arrow) + content = requireViewById(R.id.content) + arrow = requireViewById(R.id.arrow) arrow.background = RoundedArrowDrawable( arrowWidth,
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt index e99fa50..de4175d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
@@ -93,7 +93,7 @@ tooltipStep = TOOLTIP_STEP_FEATURES inflateTooltip(R.layout.taskbar_edu_swipe) tooltip?.run { - findViewById<LottieAnimationView>(R.id.swipe_animation).supportLightTheme() + requireViewById<LottieAnimationView>(R.id.swipe_animation).supportLightTheme() show() } } @@ -112,10 +112,10 @@ tooltipStep = TOOLTIP_STEP_NONE inflateTooltip(R.layout.taskbar_edu_features) tooltip?.run { - val splitscreenAnim = findViewById<LottieAnimationView>(R.id.splitscreen_animation) - val suggestionsAnim = findViewById<LottieAnimationView>(R.id.suggestions_animation) - val settingsAnim = findViewById<LottieAnimationView>(R.id.settings_animation) - val settingsEdu = findViewById<View>(R.id.settings_edu) + val splitscreenAnim = requireViewById<LottieAnimationView>(R.id.splitscreen_animation) + val suggestionsAnim = requireViewById<LottieAnimationView>(R.id.suggestions_animation) + val settingsAnim = requireViewById<LottieAnimationView>(R.id.settings_animation) + val settingsEdu = requireViewById<View>(R.id.settings_edu) splitscreenAnim.supportLightTheme() suggestionsAnim.supportLightTheme() settingsAnim.supportLightTheme() @@ -186,7 +186,7 @@ private fun createAccessibilityDelegate() = object : View.AccessibilityDelegate() { override fun performAccessibilityAction( - host: View?, + host: View, action: Int, args: Bundle? ): Boolean { @@ -197,22 +197,22 @@ return super.performAccessibilityAction(host, action, args) } - override fun onPopulateAccessibilityEvent(host: View?, event: AccessibilityEvent?) { + override fun onPopulateAccessibilityEvent(host: View, event: AccessibilityEvent) { super.onPopulateAccessibilityEvent(host, event) - if (event?.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - event.text?.add(host?.context?.getText(R.string.taskbar_edu_a11y_title)) + if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { + event.text.add(host.context?.getText(R.string.taskbar_edu_a11y_title)) } } override fun onInitializeAccessibilityNodeInfo( - host: View?, - info: AccessibilityNodeInfo? + host: View, + info: AccessibilityNodeInfo ) { super.onInitializeAccessibilityNodeInfo(host, info) - info?.addAction( + info.addAction( AccessibilityNodeInfo.AccessibilityAction( R.id.close, - host?.context?.getText(R.string.taskbar_edu_close) + host.context?.getText(R.string.taskbar_edu_close) ) ) }
diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt index 5eb240e..5a5ff8e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
@@ -192,13 +192,13 @@ removeOnAttachStateChangeListener(pendingAttachedToWindowListener) pendingAttachedToWindowListener = object : View.OnAttachStateChangeListener { - override fun onViewAttachedToWindow(v: View?) { + override fun onViewAttachedToWindow(v: View) { onAttachedToWindow() removeOnAttachStateChangeListener(this) pendingAttachedToWindowListener = null } - override fun onViewDetachedFromWindow(v: View?) {} + override fun onViewDetachedFromWindow(v: View) {} } addOnAttachStateChangeListener(pendingAttachedToWindowListener) }
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt index 27a4988..e704e51 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
@@ -40,7 +40,7 @@ protected val endContextualContainer: ViewGroup, protected val startContextualContainer: ViewGroup ) : NavButtonLayoutter { - protected val homeButton: ImageView = navButtonContainer.findViewById(R.id.home) - protected val recentsButton: ImageView = navButtonContainer.findViewById(R.id.recent_apps) - protected val backButton: ImageView = navButtonContainer.findViewById(R.id.back) + protected val homeButton: ImageView = navButtonContainer.requireViewById(R.id.home) + protected val recentsButton: ImageView = navButtonContainer.requireViewById(R.id.recent_apps) + protected val backButton: ImageView = navButtonContainer.requireViewById(R.id.back) }
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index 0668da9..000778d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
@@ -58,11 +58,12 @@ isThreeButtonNav: Boolean, phoneMode: Boolean ): NavButtonLayoutter { - val navButtonContainer = navButtonsView.findViewById<LinearLayout>(ID_END_NAV_BUTTONS) + val navButtonContainer = + navButtonsView.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS) val endContextualContainer = - navButtonsView.findViewById<ViewGroup>(ID_END_CONTEXTUAL_BUTTONS) + navButtonsView.requireViewById<ViewGroup>(ID_END_CONTEXTUAL_BUTTONS) val startContextualContainer = - navButtonsView.findViewById<ViewGroup>(ID_START_CONTEXTUAL_BUTTONS) + navButtonsView.requireViewById<ViewGroup>(ID_START_CONTEXTUAL_BUTTONS) val isPhoneNavMode = phoneMode && isThreeButtonNav return when { isPhoneNavMode -> {
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt index e073264..18b8de0 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt +++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt
@@ -156,18 +156,20 @@ */ fun setSecondTask(pendingIntent: PendingIntent) { secondPendingIntent = pendingIntent - secondUser = pendingIntent.creatorUserHandle!! + secondUser = pendingIntent.creatorUserHandle } 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()) @@ -250,7 +252,7 @@ * convert [secondIntent] */ private fun convertIntentsToFinalTypes() { - initialShortcut = getShortcutInfo(initialIntent, initialUser) + initialShortcut = getShortcutInfo(initialIntent, checkNotNull(initialUser)) initialPendingIntent = getPendingIntent(initialIntent, initialUser) initialIntent = null @@ -264,7 +266,7 @@ return } - secondShortcut = getShortcutInfo(secondIntent, secondUser) + secondShortcut = getShortcutInfo(secondIntent, checkNotNull(secondUser)) secondPendingIntent = getPendingIntent(secondIntent, secondUser) secondIntent = null } @@ -405,4 +407,4 @@ writer.println("$prefix\tinitialShortcut= $initialShortcut") writer.println("$prefix\tsecondShortcut= $secondShortcut") } -} \ No newline at end of file +}
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 8ee0fbb..b373911 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt
@@ -121,7 +121,7 @@ override fun onFinishInflate() { super.onFinishInflate() - optionLayout = findViewById(R.id.menu_option_layout) + optionLayout = requireViewById(R.id.menu_option_layout) } private fun populateAndShowForTask( @@ -193,8 +193,8 @@ mActivityContext.layoutInflater.inflate(R.layout.task_view_menu_option, this, false) as LinearLayout menuOption.setIconAndLabelFor( - menuOptionView.findViewById(R.id.icon), - menuOptionView.findViewById(R.id.text) + menuOptionView.requireViewById(R.id.icon), + menuOptionView.requireViewById(R.id.text) ) val lp = menuOptionView.layoutParams as LayoutParams lp.width = menuWidth
diff --git a/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt index 65542cf..0b3c0e8 100644 --- a/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt +++ b/quickstep/tests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt
@@ -144,12 +144,12 @@ Consumer<Task> { assertEquals( "ComponentName package mismatched", - it.key.baseIntent.component.packageName, + it.key.baseIntent.component?.packageName, matchingPackage ) assertEquals( "ComponentName class mismatched", - it.key.baseIntent.component.className, + it.key.baseIntent.component?.className, matchingClass ) assertEquals(it, groupTask1.task1) @@ -236,12 +236,12 @@ Consumer<Task> { assertEquals( "ComponentName package mismatched", - it.key.baseIntent.component.packageName, + it.key.baseIntent.component?.packageName, matchingPackage ) assertEquals( "ComponentName class mismatched", - it.key.baseIntent.component.className, + it.key.baseIntent.component?.className, matchingClass ) assertEquals("userId mismatched", it.key.userId, nonPrimaryUserHandle.identifier) @@ -288,12 +288,12 @@ Consumer<Task> { assertEquals( "ComponentName package mismatched", - it.key.baseIntent.component.packageName, + it.key.baseIntent.component?.packageName, matchingPackage ) assertEquals( "ComponentName class mismatched", - it.key.baseIntent.component.className, + it.key.baseIntent.component?.className, matchingClass ) assertEquals(it, groupTask2.task2)
diff --git a/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt b/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt index 3b480ca..06b7e68 100644 --- a/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt +++ b/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt
@@ -190,7 +190,7 @@ intentIndex = c.getColumnIndex(INTENT) val cellXIndex = c.getColumnIndex(CELLX) val cellYIndex = c.getColumnIndex(CELLY) - val locMap = HashMap<String, Point>() + val locMap = HashMap<String?, Point>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = Point(c.getInt(cellXIndex), c.getInt(cellYIndex)) @@ -436,13 +436,13 @@ c.close() } - private fun parseLocMap(context: Context, c: Cursor): Map<String, Triple<Int, Int, Int>> { + private fun parseLocMap(context: Context, c: Cursor): Map<String?, Triple<Int, Int, Int>> { // Check workspace items val intentIndex = c.getColumnIndex(INTENT) val screenIndex = c.getColumnIndex(SCREEN) val cellXIndex = c.getColumnIndex(CELLX) val cellYIndex = c.getColumnIndex(CELLY) - val locMap = mutableMapOf<String, Triple<Int, Int, Int>>() + val locMap = mutableMapOf<String?, Triple<Int, Int, Int>>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = Triple(c.getInt(screenIndex), c.getInt(cellXIndex), c.getInt(cellYIndex)) @@ -636,7 +636,7 @@ val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap<String, Int>() + val locMap = HashMap<String?, Int>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex) @@ -698,7 +698,7 @@ val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap<String, Int>() + val locMap = HashMap<String?, Int>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex) @@ -758,7 +758,7 @@ val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap<String, Int>() + val locMap = HashMap<String?, Int>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex)