Fixes @Nullable issues in System UI and WMShell. Test: followed these steps: 1. Patched in https://r.android.com/2688146 2. m sysuig 3. Fix compilation issues 4. Repeat 2 and 3 until done Fix: 294098415 Change-Id: I74cc61fd87819be7302590d788c3c230bff57544
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt index e95e8e5..1b41f79 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/ManageEducationView.kt
@@ -41,9 +41,9 @@ private val ANIMATE_DURATION: Long = 200 private val positioner: BubblePositioner = positioner - private val manageView by lazy { findViewById<ViewGroup>(R.id.manage_education_view) } - private val manageButton by lazy { findViewById<Button>(R.id.manage_button) } - private val gotItButton by lazy { findViewById<Button>(R.id.got_it) } + private val manageView by lazy { requireViewById<ViewGroup>(R.id.manage_education_view) } + private val manageButton by lazy { requireViewById<Button>(R.id.manage_button) } + private val gotItButton by lazy { requireViewById<Button>(R.id.got_it) } private var isHiding = false private var realManageButtonRect = Rect() @@ -122,7 +122,7 @@ manageButton .setOnClickListener { hide() - expandedView.findViewById<View>(R.id.manage_button).performClick() + expandedView.requireViewById<View>(R.id.manage_button).performClick() } gotItButton.setOnClickListener { hide() } setOnClickListener { hide() }
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt index d0598cd..5e3a077 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt
@@ -48,9 +48,9 @@ private val positioner: BubblePositioner = positioner private val controller: BubbleController = controller - private val view by lazy { findViewById<View>(R.id.stack_education_layout) } - private val titleTextView by lazy { findViewById<TextView>(R.id.stack_education_title) } - private val descTextView by lazy { findViewById<TextView>(R.id.stack_education_description) } + private val view by lazy { requireViewById<View>(R.id.stack_education_layout) } + private val titleTextView by lazy { requireViewById<TextView>(R.id.stack_education_title) } + private val descTextView by lazy { requireViewById<TextView>(R.id.stack_education_description) } var isHiding = false private set
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index b15fd91..9f3357b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -296,7 +296,7 @@ task.taskId ) val wct = WindowContainerTransaction() - wct.setBounds(task.token, null) + wct.setBounds(task.token, Rect()) if (Transitions.ENABLE_SHELL_TRANSITIONS) { enterDesktopTaskTransitionHandler.startCancelMoveToDesktopMode(wct, @@ -533,6 +533,7 @@ ) // Check if we should skip handling this transition var reason = "" + val triggerTask = request.triggerTask val shouldHandleRequest = when { // Only handle open or to front transitions @@ -541,19 +542,19 @@ false } // Only handle when it is a task transition - request.triggerTask == null -> { + triggerTask == null -> { reason = "triggerTask is null" false } // Only handle standard type tasks - request.triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> { - reason = "activityType not handled (${request.triggerTask.activityType})" + triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> { + reason = "activityType not handled (${triggerTask.activityType})" false } // Only handle fullscreen or freeform tasks - request.triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN && - request.triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> { - reason = "windowingMode not handled (${request.triggerTask.windowingMode})" + triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN && + triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> { + reason = "windowingMode not handled (${triggerTask.windowingMode})" false } // Otherwise process it @@ -569,17 +570,17 @@ return null } - val task: RunningTaskInfo = request.triggerTask - - val result = when { - // If display has tasks stashed, handle as stashed launch - desktopModeTaskRepository.isStashed(task.displayId) -> handleStashedTaskLaunch(task) - // Check if fullscreen task should be updated - task.windowingMode == WINDOWING_MODE_FULLSCREEN -> handleFullscreenTaskLaunch(task) - // Check if freeform task should be updated - task.windowingMode == WINDOWING_MODE_FREEFORM -> handleFreeformTaskLaunch(task) - else -> { - null + val result = triggerTask?.let { task -> + when { + // If display has tasks stashed, handle as stashed launch + desktopModeTaskRepository.isStashed(task.displayId) -> handleStashedTaskLaunch(task) + // Check if fullscreen task should be updated + task.windowingMode == WINDOWING_MODE_FULLSCREEN -> handleFullscreenTaskLaunch(task) + // Check if freeform task should be updated + task.windowingMode == WINDOWING_MODE_FREEFORM -> handleFreeformTaskLaunch(task) + else -> { + null + } } } KtProtoLog.v( @@ -686,7 +687,7 @@ WINDOWING_MODE_FULLSCREEN } wct.setWindowingMode(taskInfo.token, targetWindowingMode) - wct.setBounds(taskInfo.token, null) + wct.setBounds(taskInfo.token, Rect()) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(taskInfo.token, getFullscreenDensityDpi()) }
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt index b9cb5c7..9debb25 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/ToggleResizeDesktopTaskTransitionHandler.kt
@@ -69,7 +69,7 @@ ): Boolean { val change = findRelevantChange(info) val leash = change.leash - val taskId = change.taskInfo.taskId + val taskId = checkNotNull(change.taskInfo).taskId val startBounds = change.startAbsBounds val endBounds = change.endAbsBounds val windowDecor =
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt index 672e57a..a9eb882 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt
@@ -23,14 +23,14 @@ appIcon: Drawable ) : DesktopModeWindowDecorationViewHolder(rootView) { - private val captionView: View = rootView.findViewById(R.id.desktop_mode_caption) - private val captionHandle: View = rootView.findViewById(R.id.caption_handle) - private val openMenuButton: View = rootView.findViewById(R.id.open_menu_button) - private val closeWindowButton: ImageButton = rootView.findViewById(R.id.close_window) - private val expandMenuButton: ImageButton = rootView.findViewById(R.id.expand_menu_button) - private val maximizeWindowButton: ImageButton = rootView.findViewById(R.id.maximize_window) - private val appNameTextView: TextView = rootView.findViewById(R.id.application_name) - private val appIconImageView: ImageView = rootView.findViewById(R.id.application_icon) + private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption) + private val captionHandle: View = rootView.requireViewById(R.id.caption_handle) + private val openMenuButton: View = rootView.requireViewById(R.id.open_menu_button) + private val closeWindowButton: ImageButton = rootView.requireViewById(R.id.close_window) + private val expandMenuButton: ImageButton = rootView.requireViewById(R.id.expand_menu_button) + private val maximizeWindowButton: ImageButton = rootView.requireViewById(R.id.maximize_window) + private val appNameTextView: TextView = rootView.requireViewById(R.id.application_name) + private val appIconImageView: ImageView = rootView.requireViewById(R.id.application_icon) init { captionView.setOnTouchListener(onCaptionTouchListener) @@ -47,7 +47,9 @@ override fun bindData(taskInfo: RunningTaskInfo) { val captionDrawable = captionView.background as GradientDrawable - captionDrawable.setColor(taskInfo.taskDescription.statusBarColor) + taskInfo.taskDescription?.statusBarColor?.let { + captionDrawable.setColor(it) + } closeWindowButton.imageTintList = ColorStateList.valueOf( getCaptionCloseButtonColor(taskInfo))
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt index 47a12a0..9374ac9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt
@@ -17,8 +17,8 @@ onCaptionButtonClickListener: View.OnClickListener ) : DesktopModeWindowDecorationViewHolder(rootView) { - private val captionView: View = rootView.findViewById(R.id.desktop_mode_caption) - private val captionHandle: ImageButton = rootView.findViewById(R.id.caption_handle) + private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption) + private val captionHandle: ImageButton = rootView.requireViewById(R.id.caption_handle) init { captionView.setOnTouchListener(onCaptionTouchListener) @@ -27,9 +27,10 @@ } override fun bindData(taskInfo: RunningTaskInfo) { - val captionColor = taskInfo.taskDescription.statusBarColor - val captionDrawable = captionView.background as GradientDrawable - captionDrawable.setColor(captionColor) + taskInfo.taskDescription?.statusBarColor?.let { captionColor -> + val captionDrawable = captionView.background as GradientDrawable + captionDrawable.setColor(captionColor) + } captionHandle.imageTintList = ColorStateList.valueOf(getCaptionHandleBarColor(taskInfo)) }
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt index d293cf7..49e8d15 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeWindowDecorationViewHolder.kt
@@ -25,11 +25,14 @@ * with the caption background color. */ protected fun shouldUseLightCaptionColors(taskInfo: RunningTaskInfo): Boolean { - return if (Color.alpha(taskInfo.taskDescription.statusBarColor) != 0 && - taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) { - Color.valueOf(taskInfo.taskDescription.statusBarColor).luminance() < 0.5 - } else { - taskInfo.taskDescription.statusBarAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0 - } + return taskInfo.taskDescription + ?.let { taskDescription -> + if (Color.alpha(taskDescription.statusBarColor) != 0 && + taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) { + Color.valueOf(taskDescription.statusBarColor).luminance() < 0.5 + } else { + taskDescription.statusBarAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0 + } + } ?: false } }
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt index a03acc3..73f6db6 100644 --- a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt +++ b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt
@@ -325,7 +325,7 @@ return batteryLevel } - override fun onBoundsChange(bounds: Rect?) { + override fun onBoundsChange(bounds: Rect) { super.onBoundsChange(bounds) updateSize() }
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt index 37b1ee5..187d073 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt
@@ -249,7 +249,7 @@ // intent is to launch a dialog from another dialog. val animatedParent = openedDialogs.firstOrNull { - it.dialog.window.decorView.viewRootImpl == controller.viewRoot + it.dialog.window?.decorView?.viewRootImpl == controller.viewRoot } val controller = animatedParent?.dialogContentWithBackground?.let { @@ -336,7 +336,7 @@ ): ActivityLaunchAnimator.Controller? { val animatedDialog = openedDialogs.firstOrNull { - it.dialog.window.decorView.viewRootImpl == view.viewRootImpl + it.dialog.window?.decorView?.viewRootImpl == view.viewRootImpl } ?: return null return createActivityLaunchController(animatedDialog, cujType) @@ -417,7 +417,7 @@ animatedDialog.prepareForStackDismiss() // Remove the dim. - dialog.window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + dialog.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) } override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) { @@ -783,7 +783,7 @@ } // Show the background dim. - dialog.window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) startAnimation( isLaunching = true, @@ -863,7 +863,7 @@ isLaunching = false, onLaunchAnimationStart = { // Remove the dim background as soon as we start the animation. - dialog.window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + dialog.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) }, onLaunchAnimationEnd = { val dialogContentWithBackground = this.dialogContentWithBackground!!
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewLaunchAnimatorController.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewLaunchAnimatorController.kt index 1a03ede..6c4b695 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewLaunchAnimatorController.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewLaunchAnimatorController.kt
@@ -206,8 +206,9 @@ return } - backgroundView = FrameLayout(launchContainer.context) - launchContainerOverlay.add(backgroundView) + backgroundView = FrameLayout(launchContainer.context).also { + launchContainerOverlay.add(it) + } // We wrap the ghosted view background and use it to draw the expandable background. Its // alpha will be set to 0 as soon as we start drawing the expanding background. @@ -319,7 +320,7 @@ backgroundDrawable?.wrapped?.alpha = startBackgroundAlpha GhostView.removeGhost(ghostedView) - launchContainerOverlay.remove(backgroundView) + backgroundView?.let { launchContainerOverlay.remove(it) } if (ghostedView is LaunchableView) { // Restore the ghosted view visibility.
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/LaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/LaunchAnimator.kt index 142fd21..d6eba2e 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/LaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/LaunchAnimator.kt
@@ -283,7 +283,7 @@ animator.addListener( object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?, isReverse: Boolean) { + override fun onAnimationStart(animation: Animator, isReverse: Boolean) { if (DEBUG) { Log.d(TAG, "Animation started") } @@ -295,7 +295,7 @@ launchContainerOverlay.add(windowBackgroundLayer) } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { if (DEBUG) { Log.d(TAG, "Animation ended") }
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt index b555fa5..8dc7495 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/TextAnimator.kt
@@ -42,7 +42,9 @@ return baseTypeface } - val axes = FontVariationAxis.fromFontVariationSettings(fVar).toMutableList() + val axes = FontVariationAxis.fromFontVariationSettings(fVar) + ?.toMutableList() + ?: mutableListOf() axes.removeIf { !baseTypeface.isSupportedAxes(it.getOpenTypeTagValue()) } if (axes.isEmpty()) { return baseTypeface @@ -120,8 +122,8 @@ } addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) = textInterpolator.rebase() - override fun onAnimationCancel(animation: Animator?) = textInterpolator.rebase() + override fun onAnimationEnd(animation: Animator) = textInterpolator.rebase() + override fun onAnimationCancel(animation: Animator) = textInterpolator.rebase() } ) } @@ -302,11 +304,11 @@ if (onAnimationEnd != null) { val listener = object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { onAnimationEnd.run() animator.removeListener(this) } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { animator.removeListener(this) } }
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt index 38b99cc..bd3706e 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt
@@ -1046,7 +1046,7 @@ } } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { cancelled = true } }
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt b/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt index f83fa33..affb76b 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt
@@ -57,7 +57,7 @@ private fun readIntFromBundle(extras: Bundle, key: String): Int? = try { - extras.getString(key).toInt() + extras.getString(key)?.toInt() } catch (e: Exception) { null }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt index c142933..5edd283 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerKt.kt
@@ -27,6 +27,6 @@ */ fun ActivityManager.isInForeground(packageName: String): Boolean { val tasks: List<ActivityManager.RunningTaskInfo> = getRunningTasks(1) - return tasks.isNotEmpty() && packageName == tasks[0].topActivity.packageName + return tasks.isNotEmpty() && packageName == tasks[0].topActivity?.packageName } }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/smartspace/SmartspaceState.kt b/packages/SystemUI/shared/src/com/android/systemui/shared/system/smartspace/SmartspaceState.kt index d7e61d6..ebc57d2 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/smartspace/SmartspaceState.kt +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/smartspace/SmartspaceState.kt
@@ -31,15 +31,15 @@ var visibleOnScreen = false constructor(parcel: Parcel) : this() { - this.boundsOnScreen = parcel.readParcelable(Rect::javaClass.javaClass.classLoader) + this.boundsOnScreen = parcel.readParcelable(Rect::javaClass.javaClass.classLoader) ?: Rect() this.selectedPage = parcel.readInt() this.visibleOnScreen = parcel.readBoolean() } - override fun writeToParcel(dest: Parcel?, flags: Int) { - dest?.writeParcelable(boundsOnScreen, 0) - dest?.writeInt(selectedPage) - dest?.writeBoolean(visibleOnScreen) + override fun writeToParcel(dest: Parcel, flags: Int) { + dest.writeParcelable(boundsOnScreen, 0) + dest.writeInt(selectedPage) + dest.writeBoolean(visibleOnScreen) } override fun describeContents(): Int {
diff --git a/packages/SystemUI/shared/src/com/android/systemui/unfold/util/NaturalRotationUnfoldProgressProvider.kt b/packages/SystemUI/shared/src/com/android/systemui/unfold/util/NaturalRotationUnfoldProgressProvider.kt index aca9907..dac130d 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/unfold/util/NaturalRotationUnfoldProgressProvider.kt +++ b/packages/SystemUI/shared/src/com/android/systemui/unfold/util/NaturalRotationUnfoldProgressProvider.kt
@@ -39,7 +39,7 @@ fun init() { rotationChangeProvider.addCallback(rotationListener) - rotationListener.onRotationChanged(context.display.rotation) + context.display?.rotation?.let { rotationListener.onRotationChanged(it) } } private val rotationListener = RotationListener { rotation ->
diff --git a/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt b/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt index 78a5c98..495367b 100644 --- a/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt +++ b/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt
@@ -105,7 +105,7 @@ hideAnimator.addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { super@BouncerKeyguardMessageArea.setMessage(msg, animate) } } @@ -118,7 +118,7 @@ showAnimator.addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { textAboutToShow = null } }
diff --git a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt index 4a6e53d..4f4eec6 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt
@@ -144,7 +144,7 @@ smallClockOnAttachStateChangeListener = object : OnAttachStateChangeListener { var pastVisibility: Int? = null - override fun onViewAttachedToWindow(view: View?) { + override fun onViewAttachedToWindow(view: View) { value.events.onTimeFormatChanged(DateFormat.is24HourFormat(context)) if (view != null) { smallClockFrame = view.parent as FrameLayout @@ -168,7 +168,7 @@ } } - override fun onViewDetachedFromWindow(p0: View?) { + override fun onViewDetachedFromWindow(p0: View) { smallClockFrame?.viewTreeObserver ?.removeOnGlobalLayoutListener(onGlobalLayoutListener) } @@ -178,10 +178,10 @@ largeClockOnAttachStateChangeListener = object : OnAttachStateChangeListener { - override fun onViewAttachedToWindow(p0: View?) { + override fun onViewAttachedToWindow(p0: View) { value.events.onTimeFormatChanged(DateFormat.is24HourFormat(context)) } - override fun onViewDetachedFromWindow(p0: View?) { + override fun onViewDetachedFromWindow(p0: View) { } } value.largeClock.view
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 946ddba..ea9fe5f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt
@@ -230,7 +230,7 @@ lightRevealScrim.revealAmount = animator.animatedValue as Float } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { // Reset light reveal scrim to the default, so the CentralSurfaces // can handle any subsequent light reveal changes // (ie: from dozing changes)
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleView.kt index 5ede16d..4c2dc41 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleView.kt
@@ -147,12 +147,12 @@ retractDwellAnimator = AnimatorSet().apply { playTogether(retractDwellRippleAnimator, retractAlphaAnimator) addListener(object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { dwellPulseOutAnimator?.cancel() drawDwell = true } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { drawDwell = false resetDwellAlpha() } @@ -182,13 +182,13 @@ invalidate() } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { retractDwellAnimator?.cancel() dwellPulseOutAnimator?.cancel() drawDwell = true } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { drawDwell = false resetDwellAlpha() } @@ -239,14 +239,14 @@ expandDwellRippleAnimator ) addListener(object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { retractDwellAnimator?.cancel() fadeDwellAnimator?.cancel() visibility = VISIBLE drawDwell = true } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { drawDwell = false } }) @@ -273,12 +273,12 @@ unlockedRippleAnimator = rippleAnimator.apply { addListener(object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { drawRipple = true visibility = VISIBLE } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { onAnimationEnd?.run() drawRipple = false visibility = GONE @@ -327,7 +327,7 @@ } } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { // To reduce overdraw, we mask the effect to a circle whose radius is big enough to cover // the active effect area. Values here should be kept in sync with the // animation implementation in the ripple shader. (Twice bigger)
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FaceAuthAccessibilityDelegate.kt b/packages/SystemUI/src/com/android/systemui/biometrics/FaceAuthAccessibilityDelegate.kt index b9fa240..a24a47b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/FaceAuthAccessibilityDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/FaceAuthAccessibilityDelegate.kt
@@ -40,7 +40,7 @@ private val keyguardUpdateMonitor: KeyguardUpdateMonitor, private val faceAuthInteractor: KeyguardFaceAuthInteractor, ) : View.AccessibilityDelegate() { - override fun onInitializeAccessibilityNodeInfo(host: View?, info: AccessibilityNodeInfo) { + override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(host, info) if (keyguardUpdateMonitor.shouldListenForFace()) { val clickActionToRetryFace = @@ -52,7 +52,7 @@ } } - override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean { + override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean { return if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK.id) { keyguardUpdateMonitor.requestFaceAuth(FaceAuthApiRequestReason.ACCESSIBILITY_ACTION) faceAuthInteractor.onAccessibilityAction()
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt index 7f696fd..eb6864d 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt
@@ -119,7 +119,7 @@ private var overlayView: View? = null set(value) { field?.let { oldView -> - val lottie = oldView.findViewById(R.id.sidefps_animation) as LottieAnimationView + val lottie = oldView.requireViewById(R.id.sidefps_animation) as LottieAnimationView lottie.pauseAnimation() windowManager.removeView(oldView) orientationListener.disable() @@ -274,7 +274,7 @@ } overlayOffsets = offsets - val lottie = view.findViewById(R.id.sidefps_animation) as LottieAnimationView + val lottie = view.requireViewById(R.id.sidefps_animation) as LottieAnimationView view.rotation = display.asSideFpsAnimationRotation( offsets.isYAligned(),
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt index 8352d0a..5dafa61 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt
@@ -38,7 +38,8 @@ override fun getDrawable(): UdfpsDrawable = fingerprintDrawable fun updateAccessibilityViewLocation(sensorBounds: Rect) { - val fingerprintAccessibilityView: View = findViewById(R.id.udfps_enroll_accessibility_view) + val fingerprintAccessibilityView: View = + requireViewById(R.id.udfps_enroll_accessibility_view) val params: ViewGroup.LayoutParams = fingerprintAccessibilityView.layoutParams params.width = sensorBounds.width() params.height = sensorBounds.height()
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardAccessibilityDelegate.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardAccessibilityDelegate.kt index fb7b56e..8497879 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardAccessibilityDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardAccessibilityDelegate.kt
@@ -33,7 +33,7 @@ @Main private val resources: Resources, private val keyguardViewManager: StatusBarKeyguardViewManager, ) : View.AccessibilityDelegate() { - override fun onInitializeAccessibilityNodeInfo(host: View?, info: AccessibilityNodeInfo) { + override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(host, info) val clickAction = AccessibilityNodeInfo.AccessibilityAction( @@ -43,7 +43,7 @@ info.addAction(clickAction) } - override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean { + override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean { // when an a11y service is enabled, double tapping on the fingerprint sensor should // show the primary bouncer return if (action == AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK.id) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt index db30a55..e3fd3ce1 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerLegacy.kt
@@ -306,8 +306,9 @@ activityLaunchAnimator.addListener(activityLaunchAnimatorListener) view.mUseExpandedOverlay = useExpandedOverlay view.startIconAsyncInflate { - (view.findViewById(R.id.udfps_animation_view_internal) as View).accessibilityDelegate = - udfpsKeyguardAccessibilityDelegate + val animationViewInternal: View = + view.requireViewById(R.id.udfps_animation_view_internal) + animationViewInternal.accessibilityDelegate = udfpsKeyguardAccessibilityDelegate } }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/CredentialInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/CredentialInteractor.kt index 1f1a1b5..2a02667 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/CredentialInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/CredentialInteractor.kt
@@ -89,7 +89,7 @@ ) val hat = gkResponse.gatekeeperHAT lockPatternUtils.removeGatekeeperPasswordHandle(pwHandle) - emit(CredentialStatus.Success.Verified(hat)) + emit(CredentialStatus.Success.Verified(checkNotNull(hat))) } else if (response.timeout > 0) { // if requests are being throttled, update the error message every // second until the temporary lock has expired @@ -226,8 +226,7 @@ is BiometricPromptRequest.Credential.Password -> DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_PASSWORD_LAST_ATTEMPT } - return devicePolicyManager.resources.getString(id) { - // use fallback a string if not found + val getFallbackString = { val defaultId = when (request) { is BiometricPromptRequest.Credential.Pin -> @@ -239,6 +238,8 @@ } getString(defaultId) } + + return devicePolicyManager.resources?.getString(id, getFallbackString) ?: getFallbackString() } private fun Context.getLastAttemptBeforeWipeUserMessage( @@ -266,8 +267,8 @@ DevicePolicyResources.Strings.SystemUi.BIOMETRIC_DIALOG_WORK_LOCK_FAILED_ATTEMPTS else -> DevicePolicyResources.UNDEFINED } - return devicePolicyManager.resources.getString(id) { - // use fallback a string if not found + + val getFallbackString = { val defaultId = when (userType) { UserType.PRIMARY -> @@ -279,4 +280,6 @@ } getString(defaultId) } + + return devicePolicyManager.resources?.getString(id, getFallbackString) ?: getFallbackString() }
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/CredentialPasswordView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/CredentialPasswordView.kt index a3f34ce..b940ec8 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/CredentialPasswordView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/CredentialPasswordView.kt
@@ -122,7 +122,7 @@ titleView.ellipsize = TextUtils.TruncateAt.MARQUEE titleView.marqueeRepeatLimit = -1 // select to enable marquee unless a screen reader is enabled - titleView.isSelected = accessibilityManager.shouldMarquee() + titleView.isSelected = accessibilityManager?.shouldMarquee() ?: false } else { titleView.isSingleLine = false titleView.ellipsize = null
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt index 7b78761..a520836 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt
@@ -89,9 +89,9 @@ val textColorHint = view.resources.getColor(R.color.biometric_dialog_gray, view.context.theme) - val titleView = view.findViewById<TextView>(R.id.title) - val subtitleView = view.findViewById<TextView>(R.id.subtitle) - val descriptionView = view.findViewById<TextView>(R.id.description) + val titleView = view.requireViewById<TextView>(R.id.title) + val subtitleView = view.requireViewById<TextView>(R.id.subtitle) + val descriptionView = view.requireViewById<TextView>(R.id.description) // set selected to enable marquee unless a screen reader is enabled titleView.isSelected = @@ -100,18 +100,18 @@ !accessibilityManager.isEnabled || !accessibilityManager.isTouchExplorationEnabled descriptionView.movementMethod = ScrollingMovementMethod() - val iconViewOverlay = view.findViewById<LottieAnimationView>(R.id.biometric_icon_overlay) - val iconView = view.findViewById<LottieAnimationView>(R.id.biometric_icon) - val indicatorMessageView = view.findViewById<TextView>(R.id.indicator) + val iconViewOverlay = view.requireViewById<LottieAnimationView>(R.id.biometric_icon_overlay) + val iconView = view.requireViewById<LottieAnimationView>(R.id.biometric_icon) + val indicatorMessageView = view.requireViewById<TextView>(R.id.indicator) // Negative-side (left) buttons - val negativeButton = view.findViewById<Button>(R.id.button_negative) - val cancelButton = view.findViewById<Button>(R.id.button_cancel) - val credentialFallbackButton = view.findViewById<Button>(R.id.button_use_credential) + val negativeButton = view.requireViewById<Button>(R.id.button_negative) + val cancelButton = view.requireViewById<Button>(R.id.button_cancel) + val credentialFallbackButton = view.requireViewById<Button>(R.id.button_use_credential) // Positive-side (right) buttons - val confirmationButton = view.findViewById<Button>(R.id.button_confirm) - val retryButton = view.findViewById<Button>(R.id.button_try_again) + val confirmationButton = view.requireViewById<Button>(R.id.button_confirm) + val retryButton = view.requireViewById<Button>(R.id.button_try_again) // TODO(b/251476085): temporary workaround for the unsafe callbacks & legacy controllers val adapter =
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt index 1a286cf..370b36b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt
@@ -72,7 +72,7 @@ } } - val iconHolderView = view.findViewById<View>(R.id.biometric_icon_frame) + val iconHolderView = view.requireViewById<View>(R.id.biometric_icon_frame) val iconPadding = view.resources.getDimension(R.dimen.biometric_dialog_icon_padding) val fullSizeYOffset = view.resources.getDimension(R.dimen.biometric_dialog_medium_to_large_translation_offset) @@ -205,7 +205,7 @@ } private fun View.isLandscape(): Boolean { - val r = context.display.rotation + val r = context.display?.rotation return r == Surface.ROTATION_90 || r == Surface.ROTATION_270 }
diff --git a/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt b/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt index 5ca36ab..ddb09749 100644 --- a/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/charging/WiredChargingRippleController.kt
@@ -156,9 +156,9 @@ } windowLayoutParams.packageName = context.opPackageName rippleView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener { - override fun onViewDetachedFromWindow(view: View?) {} + override fun onViewDetachedFromWindow(view: View) {} - override fun onViewAttachedToWindow(view: View?) { + override fun onViewAttachedToWindow(view: View) { layoutRipple() rippleView.startRipple(Runnable { windowManager.removeView(rippleView) @@ -176,7 +176,7 @@ val height = bounds.height() val maxDiameter = Integer.max(width, height) * 2f rippleView.setMaxSize(maxDiameter, maxDiameter) - when (context.display.rotation) { + when (context.display?.rotation) { Surface.ROTATION_0 -> { rippleView.setCenter( width * normalizedPortPosX, height * normalizedPortPosY)
diff --git a/packages/SystemUI/src/com/android/systemui/classifier/FalsingA11yDelegate.kt b/packages/SystemUI/src/com/android/systemui/classifier/FalsingA11yDelegate.kt index 63d57cc..a9f3b77 100644 --- a/packages/SystemUI/src/com/android/systemui/classifier/FalsingA11yDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/classifier/FalsingA11yDelegate.kt
@@ -29,7 +29,7 @@ */ class FalsingA11yDelegate @Inject constructor(private val falsingCollector: FalsingCollector) : View.AccessibilityDelegate() { - override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean { + override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean { if (action == ACTION_CLICK) { falsingCollector.onA11yAction() }
diff --git a/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt b/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt index 3e6ac86..c0d1951 100644 --- a/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt
@@ -100,7 +100,7 @@ .stateIn(scope, SharingStarted.WhileSubscribed(), getResolutionScale()) override fun getResolutionScale(): Float { - context.display.getDisplayInfo(displayInfo.value) + context.display?.getDisplayInfo(displayInfo.value) val maxDisplayMode = displayUtils.getMaximumResolutionDisplayMode(displayInfo.value.supportedModes) maxDisplayMode?.let {
diff --git a/packages/SystemUI/src/com/android/systemui/contrast/ContrastDialog.kt b/packages/SystemUI/src/com/android/systemui/contrast/ContrastDialog.kt index f17d0f3..0b327a1 100644 --- a/packages/SystemUI/src/com/android/systemui/contrast/ContrastDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/contrast/ContrastDialog.kt
@@ -66,9 +66,9 @@ contrastButtons = mapOf( - CONTRAST_LEVEL_STANDARD to findViewById(R.id.contrast_button_standard), - CONTRAST_LEVEL_MEDIUM to findViewById(R.id.contrast_button_medium), - CONTRAST_LEVEL_HIGH to findViewById(R.id.contrast_button_high) + CONTRAST_LEVEL_STANDARD to requireViewById(R.id.contrast_button_standard), + CONTRAST_LEVEL_MEDIUM to requireViewById(R.id.contrast_button_medium), + CONTRAST_LEVEL_HIGH to requireViewById(R.id.contrast_button_high) ) contrastButtons.forEach { (contrastLevel, contrastButton) ->
diff --git a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt index e8c97bf..4a534e9c 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/controller/ControlsControllerImpl.kt
@@ -190,7 +190,7 @@ PREFS_CONTROLS_SEEDING_COMPLETED, mutableSetOf<String>()) val servicePackageSet = serviceInfoSet.map { it.packageName } prefs.edit().putStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, - completedSeedingPackageSet.intersect(servicePackageSet)).apply() + completedSeedingPackageSet?.intersect(servicePackageSet) ?: emptySet()).apply() var changed = false favoriteComponentSet.subtract(serviceInfoSet).forEach {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt index 23721c9..8bae667 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt
@@ -193,7 +193,7 @@ ControlsAnimations.enterAnimation(pageIndicator).apply { addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { // Position the tooltip if necessary after animations are complete // so we can get the position on screen. The tooltip is not // rooted in the layout root.
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt index ff55b76d..a13f717 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ChallengeDialogs.kt
@@ -106,10 +106,8 @@ } ) - getWindow().apply { - setType(WINDOW_TYPE) - setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) - } + window?.setType(WINDOW_TYPE) + window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) setOnShowListener(DialogInterface.OnShowListener { _ -> val editText = requireViewById<EditText>(R.id.controls_pin_input) editText.setHint(instructions) @@ -153,9 +151,7 @@ ) } return builder.create().apply { - getWindow().apply { - setType(WINDOW_TYPE) - } + window?.setType(WINDOW_TYPE) } }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt index c04bc87..abe3423 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlViewHolder.kt
@@ -384,7 +384,7 @@ ) } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { stateAnimator = null } }) @@ -438,7 +438,7 @@ duration = 200L interpolator = Interpolators.LINEAR addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { statusRowUpdater.invoke() } }) @@ -450,7 +450,7 @@ statusAnimator = AnimatorSet().apply { playSequentially(fadeOut, fadeIn) addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { status.alpha = STATUS_ALPHA_ENABLED statusAnimator = null }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt index be50a14..98f17f4 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt
@@ -132,8 +132,8 @@ init { // To pass touches to the task inside TaskView. - window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) - window.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY) + window?.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL) + window?.addPrivateFlags(WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY) setContentView(R.layout.controls_detail_dialog) @@ -182,7 +182,7 @@ } // consume all insets to achieve slide under effect - window.getDecorView().setOnApplyWindowInsetsListener { + checkNotNull(window).decorView.setOnApplyWindowInsetsListener { v: View, insets: WindowInsets -> val l = v.getPaddingLeft() val r = v.getPaddingRight() @@ -202,7 +202,7 @@ } fun getTaskViewBounds(): Rect { - val wm = context.getSystemService(WindowManager::class.java) + val wm = checkNotNull(context.getSystemService(WindowManager::class.java)) val windowMetrics = wm.getCurrentWindowMetrics() val rect = windowMetrics.bounds val metricInsets = windowMetrics.windowInsets
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/RenderInfo.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/RenderInfo.kt index ad2b785..dbbda9a 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/RenderInfo.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/RenderInfo.kt
@@ -67,7 +67,8 @@ iconMap.put(resourceId, icon) } } - return RenderInfo(icon!!.constantState.newDrawable(context.resources), fg, bg) + return RenderInfo( + checkNotNull(icon?.constantState).newDrawable(context.resources), fg, bg) } fun registerComponentIcon(componentName: ComponentName, icon: Drawable) {
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt index 84cda5a..3c2bfa0 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/StatusBehavior.kt
@@ -94,10 +94,8 @@ ) } cvh.visibleDialog = builder.create().apply { - getWindow().apply { - setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY) - show() - } + window?.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY) + show() } } }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt index 1461135..b2c95a6 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ToggleRangeBehavior.kt
@@ -244,7 +244,7 @@ cvh.clipLayer.level = it.animatedValue as Int } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { rangeAnimator = null } }) @@ -335,7 +335,7 @@ } override fun onScroll( - e1: MotionEvent, + e1: MotionEvent?, e2: MotionEvent, xDiff: Float, yDiff: Float
diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayMetricsRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayMetricsRepository.kt index bcfeeb9e..cef45dc 100644 --- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayMetricsRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayMetricsRepository.kt
@@ -51,7 +51,7 @@ val callback = object : ConfigurationController.ConfigurationListener { override fun onConfigChanged(newConfig: Configuration?) { - context.display.getMetrics(displayMetricsHolder) + context.display?.getMetrics(displayMetricsHolder) trySend(displayMetricsHolder) } }
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt index 7078341..b5b56b2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/backlight/ui/view/KeyboardBacklightDialog.kt
@@ -161,7 +161,7 @@ } private fun updateIconTile() { - val iconTile = rootView.findViewById(BACKLIGHT_ICON_ID) as ImageView + val iconTile = rootView.requireViewById(BACKLIGHT_ICON_ID) as ImageView val backgroundDrawable = iconTile.background as ShapeDrawable if (currentLevel == 0) { iconTile.setColorFilter(dimmedIconColor)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt index c019d21..5d7a3d4 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt
@@ -59,7 +59,7 @@ conflatedCallbackFlow { val callback = object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback { - override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) { + override fun onWalletCardsRetrieved(response: GetWalletCardsResponse) { val hasCards = response?.walletCards?.isNotEmpty() == true trySendWithFailureLogging( state( @@ -71,7 +71,7 @@ ) } - override fun onWalletCardRetrievalError(error: GetWalletCardsError?) { + override fun onWalletCardRetrievalError(error: GetWalletCardsError) { Log.e(TAG, "Wallet card retrieval error, message: \"${error?.message}\"") trySendWithFailureLogging( KeyguardQuickAffordanceConfig.LockScreenState.Hidden, @@ -133,13 +133,13 @@ return suspendCancellableCoroutine { continuation -> val callback = object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback { - override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) { + override fun onWalletCardsRetrieved(response: GetWalletCardsResponse) { continuation.resumeWith( Result.success(response?.walletCards ?: emptyList()) ) } - override fun onWalletCardRetrievalError(error: GetWalletCardsError?) { + override fun onWalletCardRetrievalError(error: GetWalletCardsError) { continuation.resumeWith(Result.success(emptyList())) } }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt index 30f8f3e..ff5094e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt
@@ -581,7 +581,7 @@ // We always want to invoke face detect in the main thread. faceAuthLogger.faceDetectionStarted() faceManager?.detectFace( - detectCancellationSignal, + checkNotNull(detectCancellationSignal), detectionCallback, FaceAuthenticateOptions.Builder().setUserId(currentUserId).build() )
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/LightRevealScrimRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/LightRevealScrimRepository.kt index 6a2511f..1c0b73f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/LightRevealScrimRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/LightRevealScrimRepository.kt
@@ -163,12 +163,13 @@ private fun constructCircleRevealFromPoint(point: Point): LightRevealEffect { return with(point) { + val display = checkNotNull(context.display) CircleReveal( x, y, startRadius = 0, endRadius = - max(max(x, context.display.width - x), max(y, context.display.height - y)), + max(max(x, display.width - x), max(y, display.height - y)), ) } }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt index a0a2abe..13a60b7 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt
@@ -471,7 +471,7 @@ return true } - override fun onLongClickUseDefaultHapticFeedback(view: View?) = false + override fun onLongClickUseDefaultHapticFeedback(view: View) = false } @Deprecated("Deprecated as part of b/278057014")
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt index 63a6791..83b5463 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt
@@ -304,7 +304,7 @@ return true } - override fun onLongClickUseDefaultHapticFeedback(view: View?) = false + override fun onLongClickUseDefaultHapticFeedback(view: View) = false }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt index 162c109..82610e6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSettingsViewBinder.kt
@@ -43,7 +43,7 @@ vibratorHelper: VibratorHelper, activityStarter: ActivityStarter ): DisposableHandle { - val view = parentView.findViewById<LaunchableLinearLayout>(R.id.keyguard_settings_button) + val view = parentView.requireViewById<LaunchableLinearLayout>(R.id.keyguard_settings_button) val disposableHandle = view.repeatWhenAttached {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt index b568a9a..3bb01f2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/UdfpsKeyguardInternalViewBinder.kt
@@ -42,13 +42,13 @@ view.accessibilityDelegate = viewModel.accessibilityDelegate // bind child views - UdfpsAodFingerprintViewBinder.bind(view.findViewById(R.id.udfps_aod_fp), aodViewModel) + UdfpsAodFingerprintViewBinder.bind(view.requireViewById(R.id.udfps_aod_fp), aodViewModel) UdfpsFingerprintViewBinder.bind( - view.findViewById(R.id.udfps_lockscreen_fp), + view.requireViewById(R.id.udfps_lockscreen_fp), fingerprintViewModel ) UdfpsBackgroundViewBinder.bind( - view.findViewById(R.id.udfps_keyguard_fp_bg), + view.requireViewById(R.id.udfps_keyguard_fp_bg), backgroundViewModel ) }
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt index 58bc552..580db35 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
@@ -117,7 +117,7 @@ private var host: SurfaceControlViewHost val surfacePackage: SurfaceControlViewHost.SurfacePackage - get() = host.surfacePackage + get() = checkNotNull(host.surfacePackage) private lateinit var largeClockHostView: FrameLayout private lateinit var smallClockHostView: FrameLayout
diff --git a/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt b/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt index e064839..5f7991e 100644 --- a/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt +++ b/packages/SystemUI/src/com/android/systemui/lifecycle/RepeatWhenAttached.kt
@@ -70,7 +70,7 @@ var lifecycleOwner: ViewLifecycleOwner? = null val onAttachListener = object : View.OnAttachStateChangeListener { - override fun onViewAttachedToWindow(v: View?) { + override fun onViewAttachedToWindow(v: View) { Assert.isMainThread() lifecycleOwner?.onDestroy() lifecycleOwner = @@ -81,7 +81,7 @@ ) } - override fun onViewDetachedFromWindow(v: View?) { + override fun onViewDetachedFromWindow(v: View) { lifecycleOwner?.onDestroy() lifecycleOwner = null }
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/models/player/SeekBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/media/controls/models/player/SeekBarViewModel.kt index 35f5a8c..a91917a 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/models/player/SeekBarViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/models/player/SeekBarViewModel.kt
@@ -514,7 +514,7 @@ * Returns true when the down event of the scroll hits within the target box of the thumb. */ override fun onScroll( - eventStart: MotionEvent, + eventStart: MotionEvent?, event: MotionEvent, distanceX: Float, distanceY: Float @@ -528,7 +528,7 @@ * Gestures that include a fling are considered a false gesture on the seek bar. */ override fun onFling( - eventStart: MotionEvent, + eventStart: MotionEvent?, event: MotionEvent, velocityX: Float, velocityY: Float
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataFilter.kt b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataFilter.kt index 207df6b..a1291a4 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataFilter.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataFilter.kt
@@ -149,11 +149,7 @@ // Check if smartspace has explicitly specified whether to re-activate resumable media. // The default behavior is to trigger if the smartspace data is active. val shouldTriggerResume = - if (data.cardAction?.extras?.containsKey(EXTRA_KEY_TRIGGER_RESUME) == true) { - data.cardAction.extras.getBoolean(EXTRA_KEY_TRIGGER_RESUME, true) - } else { - true - } + data.cardAction?.extras?.getBoolean(EXTRA_KEY_TRIGGER_RESUME, true) ?: true val shouldReactivate = shouldTriggerResume && !hasActiveMedia() && hasAnyMedia() && data.isActive @@ -269,9 +265,7 @@ "Cannot create dismiss action click action: extras missing dismiss_intent." ) } else if ( - dismissIntent.getComponent() != null && - dismissIntent.getComponent().getClassName() == - EXPORTED_SMARTSPACE_TRAMPOLINE_ACTIVITY_NAME + dismissIntent.component?.className == EXPORTED_SMARTSPACE_TRAMPOLINE_ACTIVITY_NAME ) { // Dismiss the card Smartspace data through Smartspace trampoline activity. context.startActivity(dismissIntent)
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataManager.kt index 576eb9e..282a65a 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaDataManager.kt
@@ -22,6 +22,7 @@ import android.app.Notification.EXTRA_SUBSTITUTE_APP_NAME import android.app.PendingIntent import android.app.StatusBarManager +import android.app.smartspace.SmartspaceAction import android.app.smartspace.SmartspaceConfig import android.app.smartspace.SmartspaceManager import android.app.smartspace.SmartspaceSession @@ -1623,20 +1624,18 @@ * SmartspaceTarget's data is invalid. */ private fun toSmartspaceMediaData(target: SmartspaceTarget): SmartspaceMediaData { - var dismissIntent: Intent? = null - if (target.baseAction != null && target.baseAction.extras != null) { - dismissIntent = - target.baseAction.extras.getParcelable(EXTRAS_SMARTSPACE_DISMISS_INTENT_KEY) - as Intent? - } + val baseAction: SmartspaceAction? = target.baseAction + val dismissIntent = + baseAction?.extras?.getParcelable(EXTRAS_SMARTSPACE_DISMISS_INTENT_KEY) as Intent? val isActive = when { !mediaFlags.isPersistentSsCardEnabled() -> true - target.baseAction == null -> true - else -> - target.baseAction.extras.getString(EXTRA_KEY_TRIGGER_SOURCE) != - EXTRA_VALUE_TRIGGER_PERIODIC + baseAction == null -> true + else -> { + val triggerSource = baseAction.extras?.getString(EXTRA_KEY_TRIGGER_SOURCE) + triggerSource != EXTRA_VALUE_TRIGGER_PERIODIC + } } packageName(target)?.let {
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaSessionBasedFilter.kt b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaSessionBasedFilter.kt index d6f941d..6a8ffb7 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaSessionBasedFilter.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/pipeline/MediaSessionBasedFilter.kt
@@ -65,7 +65,7 @@ private val sessionListener = object : MediaSessionManager.OnActiveSessionsChangedListener { - override fun onActiveSessionsChanged(controllers: List<MediaController>) { + override fun onActiveSessionsChanged(controllers: List<MediaController>?) { handleControllersChanged(controllers) } } @@ -190,16 +190,18 @@ } } - private fun handleControllersChanged(controllers: List<MediaController>) { + private fun handleControllersChanged(controllers: List<MediaController>?) { packageControllers.clear() - controllers.forEach { controller -> + controllers?.forEach { controller -> packageControllers.get(controller.packageName)?.let { tokens -> tokens.add(controller) } ?: run { val tokens = mutableListOf(controller) packageControllers.put(controller.packageName, tokens) } } - tokensWithNotifications.retainAll(controllers.map { TokenId(it.sessionToken) }) + controllers?.map { TokenId(it.sessionToken) }?.let { + tokensWithNotifications.retainAll(it) + } } /**
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/IlluminationDrawable.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/IlluminationDrawable.kt index b46ebb2..b9cc772 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/IlluminationDrawable.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/IlluminationDrawable.kt
@@ -195,7 +195,7 @@ } addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { backgroundAnimation = null } }
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/LightSourceDrawable.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/LightSourceDrawable.kt index 937a618..646d1d0 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/LightSourceDrawable.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/LightSourceDrawable.kt
@@ -98,11 +98,11 @@ addListener( object : AnimatorListenerAdapter() { var cancelled = false - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { cancelled = true } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { if (cancelled) { return } @@ -226,7 +226,7 @@ ) addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { rippleData.progress = 0f rippleAnimation = null invalidateSelf() @@ -270,11 +270,8 @@ return bounds } - override fun onStateChange(stateSet: IntArray?): Boolean { + override fun onStateChange(stateSet: IntArray): Boolean { val changed = super.onStateChange(stateSet) - if (stateSet == null) { - return changed - } val wasPressed = pressed var enabled = false
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselScrollHandler.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselScrollHandler.kt index 1ace316..ce50a11 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselScrollHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselScrollHandler.kt
@@ -127,19 +127,19 @@ object : GestureDetector.SimpleOnGestureListener() { override fun onFling( eStart: MotionEvent?, - eCurrent: MotionEvent?, + eCurrent: MotionEvent, vX: Float, vY: Float ) = onFling(vX, vY) override fun onScroll( down: MotionEvent?, - lastMotion: MotionEvent?, + lastMotion: MotionEvent, distanceX: Float, distanceY: Float - ) = onScroll(down!!, lastMotion!!, distanceX) + ) = onScroll(down!!, lastMotion, distanceX) - override fun onDown(e: MotionEvent?): Boolean { + override fun onDown(e: MotionEvent): Boolean { if (falsingProtectionNeeded) { falsingCollector.onNotificationStartDismissing() }
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt index fe8ebaf..c1c757e 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
@@ -180,20 +180,20 @@ object : AnimatorListenerAdapter() { private var cancelled: Boolean = false - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { cancelled = true animationPending = false rootView?.removeCallbacks(startAnimation) } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { isCrossFadeAnimatorRunning = false if (!cancelled) { applyTargetStateIfNotAnimating() } } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { cancelled = false animationPending = false } @@ -606,7 +606,7 @@ val viewHost = UniqueObjectHostView(context) viewHost.addOnAttachStateChangeListener( object : View.OnAttachStateChangeListener { - override fun onViewAttachedToWindow(p0: View?) { + override fun onViewAttachedToWindow(p0: View) { if (rootOverlay == null) { rootView = viewHost.viewRootImpl.view rootOverlay = (rootView!!.overlay as ViewGroupOverlay) @@ -614,7 +614,7 @@ viewHost.removeOnAttachStateChangeListener(this) } - override fun onViewDetachedFromWindow(p0: View?) {} + override fun onViewDetachedFromWindow(p0: View) {} } ) return viewHost
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHost.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHost.kt index be570b4..631a0b8 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHost.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHost.kt
@@ -144,12 +144,12 @@ setListeningToMediaData(true) hostView.addOnAttachStateChangeListener( object : OnAttachStateChangeListener { - override fun onViewAttachedToWindow(v: View?) { + override fun onViewAttachedToWindow(v: View) { setListeningToMediaData(true) updateViewVisibility() } - override fun onViewDetachedFromWindow(v: View?) { + override fun onViewDetachedFromWindow(v: View) { setListeningToMediaData(false) } }
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/SquigglyProgress.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/SquigglyProgress.kt index 583c626..16dfc21 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/SquigglyProgress.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/SquigglyProgress.kt
@@ -117,7 +117,7 @@ } addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { heightAnimator = null } }
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt index bbd3d33..da8e106 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttChipControllerReceiver.kt
@@ -201,13 +201,13 @@ } override fun updateView(newInfo: ChipReceiverInfo, currentView: ViewGroup) { - val packageName = newInfo.routeInfo.clientPackageName + val packageName: String? = newInfo.routeInfo.clientPackageName var iconInfo = MediaTttUtils.getIconInfoFromPackageName( context, packageName, isReceiver = true, ) { - logger.logPackageNotFound(packageName) + packageName?.let { logger.logPackageNotFound(it) } } if (newInfo.appNameOverride != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt index 5013802..fbf7e25 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt
@@ -68,9 +68,9 @@ ) rippleView.addOnAttachStateChangeListener( object : View.OnAttachStateChangeListener { - override fun onViewDetachedFromWindow(view: View?) {} + override fun onViewDetachedFromWindow(view: View) {} - override fun onViewAttachedToWindow(view: View?) { + override fun onViewAttachedToWindow(view: View) { if (view == null) { return }
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt index 0b0535d..35018f1 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt
@@ -54,7 +54,7 @@ // Reset all listeners to animator. animator.removeAllListeners() animator.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { onAnimationEnd?.run() isStarted = false } @@ -86,7 +86,7 @@ invalidate() } animator.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animation?.let { visibility = GONE } onAnimationEnd?.run() isStarted = false
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinator.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinator.kt index f75f8b9..87d0098 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinator.kt
@@ -162,7 +162,7 @@ logger: MediaTttSenderLogger, instanceId: InstanceId, ): ChipbarInfo { - val packageName = routeInfo.clientPackageName + val packageName = checkNotNull(routeInfo.clientPackageName) val otherDeviceName = if (routeInfo.name.isBlank()) { context.getString(R.string.media_ttt_default_device_type)
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionRecentsViewController.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionRecentsViewController.kt index c816446..64de9bd 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionRecentsViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/appselector/view/MediaProjectionRecentsViewController.kt
@@ -88,7 +88,7 @@ .inflate(R.layout.media_projection_recent_tasks, parent, /* attachToRoot= */ false) as ViewGroup - val container = recentsRoot.findViewById<View>(R.id.media_projection_recent_tasks_container) + val container = recentsRoot.requireViewById<View>(R.id.media_projection_recent_tasks_container) container.setTaskHeightSize() val progress = recentsRoot.requireViewById<View>(R.id.media_projection_recent_tasks_loader)
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/MediaProjectionManagerRepository.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/MediaProjectionManagerRepository.kt index 38d4e69..6480a47 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/MediaProjectionManagerRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/taskswitcher/data/repository/MediaProjectionManagerRepository.kt
@@ -81,8 +81,8 @@ return MediaProjectionState.EntireScreen } val matchingTask = - tasksRepository.findRunningTaskFromWindowContainerToken(session.tokenToRecord) - ?: return MediaProjectionState.EntireScreen + tasksRepository.findRunningTaskFromWindowContainerToken( + checkNotNull(session.tokenToRecord)) ?: return MediaProjectionState.EntireScreen return MediaProjectionState.SingleTask(matchingTask) }
diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskRoleManagerExt.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskRoleManagerExt.kt index 4d30634..63d4634 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskRoleManagerExt.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskRoleManagerExt.kt
@@ -77,8 +77,13 @@ .build() } - private fun PackageManager.getApplicationLabel(packageName: String?): String? = - runCatching { getApplicationInfo(packageName, /* flags= */ 0)!! } + private fun PackageManager.getApplicationLabel(packageName: String?): String? { + if (packageName == null) { + return null + } + + return runCatching { getApplicationInfo(packageName, /* flags= */ 0)!! } .getOrNull() ?.let { info -> getApplicationLabel(info).toString() } + } }
diff --git a/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt b/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt index 5f338c3..46c8d35 100644 --- a/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt
@@ -132,13 +132,13 @@ LayoutInflater.from(context) .inflate(R.layout.people_space_activity_no_conversations, /* root= */ view) - noConversationsView.findViewById<View>(R.id.got_it_button).setOnClickListener { + noConversationsView.requireViewById<View>(R.id.got_it_button).setOnClickListener { onGotItClicked() } // The Tile preview has colorBackground as its background. Change it so it's different than // the activity's background. - val item = noConversationsView.findViewById<LinearLayout>(android.R.id.background) + val item = noConversationsView.requireViewById<LinearLayout>(android.R.id.background) val shape = item.background as GradientDrawable val ta = context.theme.obtainStyledAttributes(
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogV2.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogV2.kt index f4aa27d..c202f14 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogV2.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialogV2.kt
@@ -192,7 +192,7 @@ return null } val closeAppButton = - window.layoutInflater.inflate( + checkNotNull(window).layoutInflater.inflate( R.layout.privacy_dialog_card_button, expandedLayout, false @@ -248,7 +248,7 @@ private fun configureManageButton(element: PrivacyElement, expandedLayout: ViewGroup): View { val manageButton = - window.layoutInflater.inflate( + checkNotNull(window).layoutInflater.inflate( R.layout.privacy_dialog_card_button, expandedLayout, false
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt index b340043..23894a3 100644 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
@@ -50,22 +50,20 @@ public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - window.apply { - addPrivateFlags(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS) - setGravity(Gravity.CENTER) - } + window?.addPrivateFlags(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS) + window?.setGravity(Gravity.CENTER) setContentView(R.layout.screen_share_dialog) - dialogTitle = findViewById(R.id.screen_share_dialog_title) - warning = findViewById(R.id.text_warning) - startButton = findViewById(android.R.id.button1) - cancelButton = findViewById(android.R.id.button2) + dialogTitle = requireViewById(R.id.screen_share_dialog_title) + warning = requireViewById(R.id.text_warning) + startButton = requireViewById(android.R.id.button1) + cancelButton = requireViewById(android.R.id.button2) updateIcon() initScreenShareOptions() createOptionsView(getOptionsViewLayoutId()) } private fun updateIcon() { - val icon = findViewById<ImageView>(R.id.screen_share_dialog_icon) + val icon = requireViewById<ImageView>(R.id.screen_share_dialog_icon) if (dialogIconTint != null) { icon.setColorFilter(context.getColor(dialogIconTint)) } @@ -92,7 +90,7 @@ options ) adapter.setDropDownViewResource(R.layout.screen_share_dialog_spinner_item_text) - screenShareModeSpinner = findViewById(R.id.screen_share_mode_spinner) + screenShareModeSpinner = requireViewById(R.id.screen_share_mode_spinner) screenShareModeSpinner.adapter = adapter screenShareModeSpinner.onItemSelectedListener = this }
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt index 604d449..e8683fb 100644 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt
@@ -100,11 +100,11 @@ @LayoutRes override fun getOptionsViewLayoutId(): Int = R.layout.screen_record_options private fun initRecordOptionsView() { - audioSwitch = findViewById(R.id.screenrecord_audio_switch) - tapsSwitch = findViewById(R.id.screenrecord_taps_switch) - tapsView = findViewById(R.id.show_taps) + audioSwitch = requireViewById(R.id.screenrecord_audio_switch) + tapsSwitch = requireViewById(R.id.screenrecord_taps_switch) + tapsView = requireViewById(R.id.show_taps) updateTapsViewVisibility() - options = findViewById(R.id.screen_recording_options) + options = requireViewById(R.id.screen_recording_options) val a: ArrayAdapter<*> = ScreenRecordingAdapter(context, android.R.layout.simple_spinner_dropdown_item, MODES) a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt index c6cb9c4..bea12de 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt
@@ -130,12 +130,12 @@ private lateinit var carrierIconSlots: List<String> private lateinit var mShadeCarrierGroupController: ShadeCarrierGroupController - private val batteryIcon: BatteryMeterView = header.findViewById(R.id.batteryRemainingIcon) - private val clock: Clock = header.findViewById(R.id.clock) - private val date: TextView = header.findViewById(R.id.date) - private val iconContainer: StatusIconContainer = header.findViewById(R.id.statusIcons) - private val mShadeCarrierGroup: ShadeCarrierGroup = header.findViewById(R.id.carrier_group) - private val systemIcons: View = header.findViewById(R.id.shade_header_system_icons) + private val batteryIcon: BatteryMeterView = header.requireViewById(R.id.batteryRemainingIcon) + private val clock: Clock = header.requireViewById(R.id.clock) + private val date: TextView = header.requireViewById(R.id.date) + private val iconContainer: StatusIconContainer = header.requireViewById(R.id.statusIcons) + private val mShadeCarrierGroup: ShadeCarrierGroup = header.requireViewById(R.id.carrier_group) + private val systemIcons: View = header.requireViewById(R.id.shade_header_system_icons) private var roundedCorners = 0 private var cutout: DisplayCutout? = null @@ -582,7 +582,7 @@ inner class CustomizerAnimationListener( private val enteringCustomizing: Boolean, ) : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { super.onAnimationEnd(animation) header.animate().setListener(null) if (enteringCustomizing) { @@ -590,7 +590,7 @@ } } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { super.onAnimationStart(animation) if (!enteringCustomizing) { customizing = false
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt index 6e76784..05b1ac6 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewProviderModule.kt
@@ -106,7 +106,7 @@ featureFlags: FeatureFlags, ): NotificationShadeWindowView { if (featureFlags.isEnabled(Flags.SCENE_CONTAINER)) { - return root.findViewById(R.id.legacy_window_root) + return root.requireViewById(R.id.legacy_window_root) } return root as NotificationShadeWindowView? ?: throw IllegalStateException("root view not a NotificationShadeWindowView") @@ -118,7 +118,7 @@ fun providesNotificationStackScrollLayout( notificationShadeWindowView: NotificationShadeWindowView, ): NotificationStackScrollLayout { - return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller) + return notificationShadeWindowView.requireViewById(R.id.notification_stack_scroller) } @Provides @@ -153,7 +153,7 @@ fun providesNotificationPanelView( notificationShadeWindowView: NotificationShadeWindowView, ): NotificationPanelView { - return notificationShadeWindowView.findViewById(R.id.notification_panel) + return notificationShadeWindowView.requireViewById(R.id.notification_panel) } /** @@ -175,7 +175,7 @@ fun providesLightRevealScrim( notificationShadeWindowView: NotificationShadeWindowView, ): LightRevealScrim { - return notificationShadeWindowView.findViewById(R.id.light_reveal_scrim) + return notificationShadeWindowView.requireViewById(R.id.light_reveal_scrim) } @Provides @@ -183,7 +183,7 @@ fun providesKeyguardRootView( notificationShadeWindowView: NotificationShadeWindowView, ): KeyguardRootView { - return notificationShadeWindowView.findViewById(R.id.keyguard_root_view) + return notificationShadeWindowView.requireViewById(R.id.keyguard_root_view) } @Provides @@ -191,7 +191,7 @@ fun providesSharedNotificationContainer( notificationShadeWindowView: NotificationShadeWindowView, ): SharedNotificationContainer { - return notificationShadeWindowView.findViewById(R.id.shared_notification_container) + return notificationShadeWindowView.requireViewById(R.id.shared_notification_container) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -200,7 +200,7 @@ fun providesAuthRippleView( notificationShadeWindowView: NotificationShadeWindowView, ): AuthRippleView? { - return notificationShadeWindowView.findViewById(R.id.auth_ripple) + return notificationShadeWindowView.requireViewById(R.id.auth_ripple) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -212,9 +212,9 @@ featureFlags: FeatureFlags ): LockIconView { if (featureFlags.isEnabled(Flags.MIGRATE_LOCK_ICON)) { - return keyguardRootView.findViewById(R.id.lock_icon_view) + return keyguardRootView.requireViewById(R.id.lock_icon_view) } else { - return notificationPanelView.findViewById(R.id.lock_icon_view) + return notificationPanelView.requireViewById(R.id.lock_icon_view) } } @@ -224,7 +224,7 @@ fun providesTapAgainView( notificationPanelView: NotificationPanelView, ): TapAgainView { - return notificationPanelView.findViewById(R.id.shade_falsing_tap_again) + return notificationPanelView.requireViewById(R.id.shade_falsing_tap_again) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -233,7 +233,7 @@ fun providesNotificationsQuickSettingsContainer( notificationShadeWindowView: NotificationShadeWindowView, ): NotificationsQuickSettingsContainer { - return notificationShadeWindowView.findViewById(R.id.notification_container_parent) + return notificationShadeWindowView.requireViewById(R.id.notification_container_parent) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -243,7 +243,7 @@ fun providesShadeHeaderView( notificationShadeWindowView: NotificationShadeWindowView, ): MotionLayout { - val stub = notificationShadeWindowView.findViewById<ViewStub>(R.id.qs_header_stub) + val stub = notificationShadeWindowView.requireViewById<ViewStub>(R.id.qs_header_stub) val layoutId = R.layout.combined_qs_header stub.layoutResource = layoutId return stub.inflate() as MotionLayout @@ -260,7 +260,7 @@ @SysUISingleton @Named(SHADE_HEADER) fun providesBatteryMeterView(@Named(SHADE_HEADER) view: MotionLayout): BatteryMeterView { - return view.findViewById(R.id.batteryRemainingIcon) + return view.requireViewById(R.id.batteryRemainingIcon) } @Provides @@ -295,7 +295,7 @@ fun providesOngoingPrivacyChip( @Named(SHADE_HEADER) header: MotionLayout, ): OngoingPrivacyChip { - return header.findViewById(R.id.privacy_chip) + return header.requireViewById(R.id.privacy_chip) } @Provides @@ -304,7 +304,7 @@ fun providesStatusIconContainer( @Named(SHADE_HEADER) header: MotionLayout, ): StatusIconContainer { - return header.findViewById(R.id.statusIcons) + return header.requireViewById(R.id.statusIcons) } } }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BatteryStatusChip.kt b/packages/SystemUI/src/com/android/systemui/statusbar/BatteryStatusChip.kt index 37140ec..5209767 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BatteryStatusChip.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BatteryStatusChip.kt
@@ -37,8 +37,8 @@ init { inflate(context, R.layout.battery_status_chip, this) - roundedContainer = findViewById(R.id.rounded_container) - batteryMeterView = findViewById(R.id.battery_meter_view) + roundedContainer = requireViewById(R.id.rounded_container) + batteryMeterView = requireViewById(R.id.battery_meter_view) updateResources() }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt index 823bb35..b2b6e14 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LightRevealScrim.kt
@@ -419,15 +419,14 @@ revealGradientCenter.y = top + (revealGradientHeight / 2f) } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { if ( - canvas == null || - revealGradientWidth <= 0 || - revealGradientHeight <= 0 || - revealAmount == 0f + revealGradientWidth <= 0 || + revealGradientHeight <= 0 || + revealAmount == 0f ) { if (revealAmount < 1f) { - canvas?.drawColor(revealGradientEndColor) + canvas.drawColor(revealGradientEndColor) } return }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 4710574..672796a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt
@@ -474,7 +474,7 @@ } if (endlistener != null) { dragDownAnimator.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { endlistener.invoke() } })
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt index 750272d..17b4e3b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/MediaArtworkProcessor.kt
@@ -66,7 +66,7 @@ inBitmap = oldIn.copy(Bitmap.Config.ARGB_8888, false /* isMutable */) oldIn.recycle() } - val outBitmap = Bitmap.createBitmap(inBitmap.width, inBitmap.height, + val outBitmap = Bitmap.createBitmap(inBitmap?.width ?: 0, inBitmap?.height ?: 0, Bitmap.Config.ARGB_8888) input = Allocation.createFromBitmap(renderScript, inBitmap,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt index 0e20df6..6ad1395 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeDepthController.kt
@@ -272,7 +272,7 @@ blurUtils.blurRadiusOfRatio(animation.animatedValue as Float) } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { keyguardAnimator = null wakeAndUnlockBlurRadius = 0f }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt index eddb683..d1e0a71 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
@@ -234,7 +234,7 @@ } // Set the dot's view gravity to hug the status bar - (corner.findViewById<View>(R.id.privacy_dot) + (corner.requireViewById<View>(R.id.privacy_dot) .layoutParams as FrameLayout.LayoutParams) .gravity = rotatedCorner.innerGravity() } @@ -255,7 +255,7 @@ // in every rotation. The only thing we need to check is rtl val rtl = state.layoutRtl val size = Point() - tl.context.display.getRealSize(size) + tl.context.display?.getRealSize(size) val currentRotation = RotationUtils.getExactRotation(tl.context) val displayWidth: Int
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt index 903d485..c5de165 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
@@ -179,15 +179,20 @@ } if (weatherTarget != null) { val clickIntent = weatherTarget.headerAction?.intent - val weatherData = WeatherData.fromBundle(weatherTarget.baseAction.extras, { v -> - if (!falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { - activityStarter.startActivity( - clickIntent, - true, /* dismissShade */ - null, - false) + val weatherData = weatherTarget.baseAction?.extras?.let { extras -> + WeatherData.fromBundle( + extras, + ) { _ -> + if (!falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { + activityStarter.startActivity( + clickIntent, + true, /* dismissShade */ + null, + false) + } } - }) + } + if (weatherData != null) { keyguardUpdateMonitor.sendWeatherData(weatherData) }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ViewGroupFadeHelper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ViewGroupFadeHelper.kt index 16f1a45..1b43922 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ViewGroupFadeHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ViewGroupFadeHelper.kt
@@ -74,7 +74,7 @@ root.setTag(R.id.view_group_fade_helper_previous_value_tag, newAlpha) } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { endRunnable?.run() } })
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt index 38a1579..9c4aa07 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorListView.kt
@@ -60,7 +60,7 @@ override fun onFinishInflate() { super.onFinishInflate() - appControlRow = findViewById(R.id.app_control) + appControlRow = requireViewById(R.id.app_control) } /** @@ -143,9 +143,9 @@ lateinit var switch: Switch override fun onFinishInflate() { - iconView = findViewById(R.id.icon) - channelName = findViewById(R.id.app_name) - switch = findViewById(R.id.toggle) + iconView = requireViewById(R.id.icon) + channelName = requireViewById(R.id.app_name) + switch = requireViewById(R.id.toggle) setOnClickListener { switch.toggle() } } @@ -174,9 +174,9 @@ override fun onFinishInflate() { super.onFinishInflate() - channelName = findViewById(R.id.channel_name) - channelDescription = findViewById(R.id.channel_description) - switch = findViewById(R.id.toggle) + channelName = requireViewById(R.id.channel_name) + channelDescription = requireViewById(R.id.channel_description) + switch = requireViewById(R.id.toggle) switch.setOnCheckedChangeListener { _, b -> channel?.let { controller.proposeEditForChannel(it, if (b) it.importance else IMPORTANCE_NONE)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt index 2ccbc9f..baeae79 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt
@@ -914,8 +914,8 @@ val packages: Array<String> = context.resources.getStringArray(R.array.system_ui_packages) for (pkg in packages) { - if (intent.component == null) break - if (pkg == intent.component.packageName) { + val componentName = intent.component ?: break + if (pkg == componentName.packageName) { return UserHandle(UserHandle.myUserId()) } }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt index 34bbd13..cdd410e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt
@@ -32,6 +32,7 @@ import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.FalsingManager import com.android.systemui.statusbar.VibratorHelper +import com.android.systemui.util.animation.requiresRemeasuring /** * Renders the bottom area of the lock-screen. Concerned primarily with the quick affordance UI @@ -98,7 +99,7 @@ ambientIndicationArea?.let { nonNullAmbientIndicationArea -> // remove old ambient indication from its parent val originalAmbientIndicationView = - oldBottomArea.findViewById<View>(R.id.ambient_indication_container) + oldBottomArea.requireViewById<View>(R.id.ambient_indication_container) (originalAmbientIndicationView.parent as ViewGroup).removeView( originalAmbientIndicationView )
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt index 2affb817..931aedd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt
@@ -75,13 +75,13 @@ } override fun onViewAttached() { - statusContainer = mView.findViewById(R.id.system_icons) + statusContainer = mView.requireViewById(R.id.system_icons) statusContainer.setOnHoverListener( statusOverlayHoverListenerFactory.createDarkAwareListener(statusContainer)) if (moveFromCenterAnimationController == null) return - val statusBarLeftSide: View = mView.findViewById(R.id.status_bar_start_side_except_heads_up) - val systemIconArea: ViewGroup = mView.findViewById(R.id.status_bar_end_side_content) + val statusBarLeftSide: View = mView.requireViewById(R.id.status_bar_start_side_except_heads_up) + val systemIconArea: ViewGroup = mView.requireViewById(R.id.status_bar_end_side_content) val viewsToAnimate = arrayOf( statusBarLeftSide,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt index c850d4f..ad18170 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarContentInsetsProvider.kt
@@ -117,11 +117,11 @@ * status bar area is contiguous. */ fun currentRotationHasCornerCutout(): Boolean { - val cutout = context.display.cutout ?: return false + val cutout = checkNotNull(context.display).cutout ?: return false val topBounds = cutout.boundingRectTop val point = Point() - context.display.getRealSize(point) + checkNotNull(context.display).getRealSize(point) return topBounds.left <= 0 || topBounds.right >= point.x } @@ -161,7 +161,7 @@ */ fun getStatusBarContentInsetsForRotation(@Rotation rotation: Int): Pair<Int, Int> = traceSection(tag = "StatusBarContentInsetsProvider.getStatusBarContentInsetsForRotation") { - val displayCutout = context.display.cutout + val displayCutout = checkNotNull(context.display).cutout val key = getCacheKey(rotation, displayCutout) val screenBounds = context.resources.configuration.windowConfiguration.maxBounds @@ -198,7 +198,7 @@ fun getStatusBarContentAreaForRotation( @Rotation rotation: Int ): Rect { - val displayCutout = context.display.cutout + val displayCutout = checkNotNull(context.display).cutout val key = getCacheKey(rotation, displayCutout) return insetsCache[key] ?: getAndSetCalculatedAreaForRotation( rotation, displayCutout, getResourcesForRotation(rotation, context), key)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index e8da951..1bceb29d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt
@@ -105,18 +105,18 @@ } } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { if (lightRevealScrim.revealEffect !is CircleReveal) { lightRevealScrim.revealAmount = 1f } } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { lightRevealAnimationPlaying = false interactionJankMonitor.end(CUJ_SCREEN_OFF) } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { interactionJankMonitor.begin( notifShadeWindowControllerLazy.get().windowRootView, CUJ_SCREEN_OFF) } @@ -345,7 +345,7 @@ // portrait. If we're in another orientation, disable the screen off animation so we don't // animate in the keyguard AOD UI sideways or upside down. if (!keyguardStateController.isKeyguardScreenRotationAllowed && - context.display.rotation != Surface.ROTATION_0) { + context.display?.rotation != Surface.ROTATION_0) { return false }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/userswitcher/StatusBarUserSwitcherContainer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/userswitcher/StatusBarUserSwitcherContainer.kt index 270c592..1259477 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/userswitcher/StatusBarUserSwitcherContainer.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/userswitcher/StatusBarUserSwitcherContainer.kt
@@ -34,7 +34,7 @@ override fun onFinishInflate() { super.onFinishInflate() - text = findViewById(R.id.current_user_name) - avatar = findViewById(R.id.current_user_avatar) + text = requireViewById(R.id.current_user_name) + avatar = requireViewById(R.id.current_user_avatar) } } \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt index 4950482..ffb743f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeviceControlsControllerImpl.kt
@@ -128,7 +128,8 @@ val prefs = userContextProvider.userContext.getSharedPreferences( PREFS_CONTROLS_FILE, Context.MODE_PRIVATE) - val seededPackages = prefs.getStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, emptySet()) + val seededPackages = + prefs.getStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, emptySet()) ?: emptySet() val controlsController = controlsComponent.getControlsController().get() val componentsToSeed = mutableListOf<ComponentName>() @@ -174,7 +175,8 @@ } private fun addPackageToSeededSet(prefs: SharedPreferences, pkg: String) { - val seededPackages = prefs.getStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, emptySet()) + val seededPackages = + prefs.getStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, emptySet()) ?: emptySet() val updatedPkgs = seededPackages.toMutableSet() updatedPkgs.add(pkg) prefs.edit().putStringSet(PREFS_CONTROLS_SEEDING_COMPLETED, updatedPkgs).apply()
diff --git a/packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt b/packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt index 27aaa68..eb7d339 100644 --- a/packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt +++ b/packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt
@@ -353,8 +353,8 @@ // before CoreStartables run, and will not be removed. // In many cases, it reports the battery level of the stylus. registerBatteryListener(deviceId) - } else if (device.bluetoothAddress != null) { - onStylusBluetoothConnected(deviceId, device.bluetoothAddress) + } else { + device.bluetoothAddress?.let { onStylusBluetoothConnected(deviceId, it) } } } }
diff --git a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherFullscreenDialog.kt b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherFullscreenDialog.kt index 72786ef..5ad96303 100644 --- a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherFullscreenDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherFullscreenDialog.kt
@@ -60,7 +60,7 @@ override fun getWidth(): Int { val displayMetrics = context.resources.displayMetrics.apply { - context.display.getRealMetrics(this) + checkNotNull(context.display).getRealMetrics(this) } return displayMetrics.widthPixels }
diff --git a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherPopupMenu.kt b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherPopupMenu.kt index 088cd93..ee84580 100644 --- a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherPopupMenu.kt +++ b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherPopupMenu.kt
@@ -52,22 +52,22 @@ override fun show() { // need to call show() first in order to construct the listView super.show() - val listView = getListView() + listView?.apply { + isVerticalScrollBarEnabled = false + isHorizontalScrollBarEnabled = false - listView.setVerticalScrollBarEnabled(false) - listView.setHorizontalScrollBarEnabled(false) + // Creates a transparent spacer between items + val shape = ShapeDrawable() + shape.alpha = 0 + divider = shape + dividerHeight = res.getDimensionPixelSize( + R.dimen.bouncer_user_switcher_popup_divider_height) - // Creates a transparent spacer between items - val shape = ShapeDrawable() - shape.setAlpha(0) - listView.setDivider(shape) - listView.setDividerHeight(res.getDimensionPixelSize( - R.dimen.bouncer_user_switcher_popup_divider_height)) - - val height = res.getDimensionPixelSize(R.dimen.bouncer_user_switcher_popup_header_height) - listView.addHeaderView(createSpacer(height), null, false) - listView.addFooterView(createSpacer(height), null, false) - setWidth(findMaxWidth(listView)) + val height = res.getDimensionPixelSize(R.dimen.bouncer_user_switcher_popup_header_height) + addHeaderView(createSpacer(height), null, false) + addFooterView(createSpacer(height), null, false) + setWidth(findMaxWidth(this)) + } super.show() }
diff --git a/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt b/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt index e74232d..7f16e47 100644 --- a/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/user/legacyhelper/ui/LegacyUserUiHelper.kt
@@ -67,7 +67,7 @@ val resourceId: Int? = getGuestUserRecordNameResourceId(record) return when { resourceId != null -> context.getString(resourceId) - record.info != null -> record.info.name + record.info != null -> checkNotNull(record.info.name) else -> context.getString( getUserSwitcherActionTextResourceId(
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/TransitionLayout.kt b/packages/SystemUI/src/com/android/systemui/util/animation/TransitionLayout.kt index 56c5d3b..7866d76 100644 --- a/packages/SystemUI/src/com/android/systemui/util/animation/TransitionLayout.kt +++ b/packages/SystemUI/src/com/android/systemui/util/animation/TransitionLayout.kt
@@ -223,11 +223,11 @@ } } - override fun dispatchDraw(canvas: Canvas?) { - canvas?.save() - canvas?.clipRect(boundsRect) + override fun dispatchDraw(canvas: Canvas) { + canvas.save() + canvas.clipRect(boundsRect) super.dispatchDraw(canvas) - canvas?.restore() + canvas.restore() } private fun updateBounds() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt index 2b08c66..994db46 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SideFpsControllerTest.kt
@@ -164,7 +164,7 @@ context.addMockSystemService(WindowManager::class.java, windowManager) whenEver(layoutInflater.inflate(R.layout.sidefps_view, null, false)).thenReturn(sideFpsView) - whenEver(sideFpsView.findViewById<LottieAnimationView>(eq(R.id.sidefps_animation))) + whenEver(sideFpsView.requireViewById<LottieAnimationView>(eq(R.id.sidefps_animation))) .thenReturn(mock(LottieAnimationView::class.java)) with(mock(ViewPropertyAnimator::class.java)) { whenEver(sideFpsView.animate()).thenReturn(this)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt index 2501f85..8f8b840 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt
@@ -138,19 +138,19 @@ @Before fun setup() { - whenever<Clock>(view.findViewById(R.id.clock)).thenReturn(clock) + whenever<Clock>(view.requireViewById(R.id.clock)).thenReturn(clock) whenever(clock.context).thenReturn(mockedContext) - whenever<TextView>(view.findViewById(R.id.date)).thenReturn(date) + whenever<TextView>(view.requireViewById(R.id.date)).thenReturn(date) whenever(date.context).thenReturn(mockedContext) - whenever<ShadeCarrierGroup>(view.findViewById(R.id.carrier_group)).thenReturn(carrierGroup) + whenever<ShadeCarrierGroup>(view.requireViewById(R.id.carrier_group)).thenReturn(carrierGroup) - whenever<BatteryMeterView>(view.findViewById(R.id.batteryRemainingIcon)) + whenever<BatteryMeterView>(view.requireViewById(R.id.batteryRemainingIcon)) .thenReturn(batteryMeterView) - whenever<StatusIconContainer>(view.findViewById(R.id.statusIcons)).thenReturn(statusIcons) - whenever<View>(view.findViewById(R.id.shade_header_system_icons)).thenReturn(systemIcons) + whenever<StatusIconContainer>(view.requireViewById(R.id.statusIcons)).thenReturn(statusIcons) + whenever<View>(view.requireViewById(R.id.shade_header_system_icons)).thenReturn(systemIcons) viewContext = Mockito.spy(context) whenever(view.context).thenReturn(viewContext)