diff options
118 files changed, 394 insertions, 379 deletions
diff --git a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt b/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt index 9482591c65b5..aadbc2319a62 100644 --- a/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt +++ b/apct-tests/perftests/core/src/android/input/MotionPredictorBenchmark.kt @@ -130,7 +130,7 @@ class MotionPredictorBenchmark { eventTime, ACTION_MOVE, /*x=*/eventPosition, /*y=*/eventPosition) predictor.record(moveEvent) val predictionTime = eventTime + eventInterval - val predicted = predictor.predict(predictionTime.toNanos()) + val predicted = checkNotNull(predictor.predict(predictionTime.toNanos())) assertTrue(predicted.eventTime <= (predictionTime + offset).toMillis()) } } diff --git a/core/java/android/credentials/ui/BaseDialogResult.java b/core/java/android/credentials/ui/BaseDialogResult.java index f0442de74e9e..e8cf5abd5239 100644 --- a/core/java/android/credentials/ui/BaseDialogResult.java +++ b/core/java/android/credentials/ui/BaseDialogResult.java @@ -85,15 +85,15 @@ public class BaseDialogResult implements Parcelable { */ public static final int RESULT_CODE_DATA_PARSING_FAILURE = 3; - @NonNull + @Nullable private final IBinder mRequestToken; - public BaseDialogResult(@NonNull IBinder requestToken) { + public BaseDialogResult(@Nullable IBinder requestToken) { mRequestToken = requestToken; } /** Returns the unique identifier for the request that launched the operation. */ - @NonNull + @Nullable public IBinder getRequestToken() { return mRequestToken; } @@ -101,7 +101,6 @@ public class BaseDialogResult implements Parcelable { protected BaseDialogResult(@NonNull Parcel in) { IBinder requestToken = in.readStrongBinder(); mRequestToken = requestToken; - AnnotationValidations.validate(NonNull.class, null, mRequestToken); } @Override diff --git a/core/java/android/credentials/ui/UserSelectionDialogResult.java b/core/java/android/credentials/ui/UserSelectionDialogResult.java index 44b3b36844c2..3089bf674b95 100644 --- a/core/java/android/credentials/ui/UserSelectionDialogResult.java +++ b/core/java/android/credentials/ui/UserSelectionDialogResult.java @@ -60,7 +60,7 @@ public final class UserSelectionDialogResult extends BaseDialogResult implements @Nullable private ProviderPendingIntentResponse mProviderPendingIntentResponse; public UserSelectionDialogResult( - @NonNull IBinder requestToken, @NonNull String providerId, + @Nullable IBinder requestToken, @NonNull String providerId, @NonNull String entryKey, @NonNull String entrySubkey) { super(requestToken); mProviderId = providerId; @@ -69,7 +69,7 @@ public final class UserSelectionDialogResult extends BaseDialogResult implements } public UserSelectionDialogResult( - @NonNull IBinder requestToken, @NonNull String providerId, + @Nullable IBinder requestToken, @NonNull String providerId, @NonNull String entryKey, @NonNull String entrySubkey, @Nullable ProviderPendingIntentResponse providerPendingIntentResponse) { super(requestToken); diff --git a/core/res/res/values-da/strings.xml b/core/res/res/values-da/strings.xml index d5a442e5c535..891ec0a78dac 100644 --- a/core/res/res/values-da/strings.xml +++ b/core/res/res/values-da/strings.xml @@ -327,7 +327,7 @@ <string name="permgrouplab_phone" msgid="570318944091926620">"Telefon"</string> <string name="permgroupdesc_phone" msgid="270048070781478204">"foretage og administrere telefonopkald"</string> <string name="permgrouplab_sensors" msgid="9134046949784064495">"Kropssensorer"</string> - <string name="permgroupdesc_sensors" msgid="2610631290633747752">"få adgang til sensordata om dine livstegn"</string> + <string name="permgroupdesc_sensors" msgid="2610631290633747752">"få adgang til sensordata om dine vitale værdier"</string> <string name="permgrouplab_notifications" msgid="5472972361980668884">"Notifikationer"</string> <string name="permgroupdesc_notifications" msgid="4608679556801506580">"vise notifikationer"</string> <string name="capability_title_canRetrieveWindowContent" msgid="7554282892101587296">"Hente indholdet i vinduet"</string> diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml index 580e99bdb33e..234f1b3f0648 100644 --- a/core/res/res/values-ja/strings.xml +++ b/core/res/res/values-ja/strings.xml @@ -2136,7 +2136,7 @@ <string name="accessibility_system_action_headset_hook_label" msgid="8524691721287425468">"ヘッドセット: フック"</string> <string name="accessibility_system_action_on_screen_a11y_shortcut_label" msgid="8488701469459210309">"画面上のユーザー補助機能のショートカット"</string> <string name="accessibility_system_action_on_screen_a11y_shortcut_chooser_label" msgid="1057878690209817886">"画面上のユーザー補助機能のショートカットの選択メニュー"</string> - <string name="accessibility_system_action_hardware_a11y_shortcut_label" msgid="5764644187715255107">"ユーザー補助機能のショートカット"</string> + <string name="accessibility_system_action_hardware_a11y_shortcut_label" msgid="5764644187715255107">"ユーザー補助のショートカット"</string> <string name="accessibility_system_action_dismiss_notification_shade" msgid="8931637495533770352">"通知シェードを閉じる"</string> <string name="accessibility_system_action_dpad_up_label" msgid="1029042950229333782">"D-pad: 上"</string> <string name="accessibility_system_action_dpad_down_label" msgid="3441918448624921461">"D-pad: 下"</string> diff --git a/core/res/res/values-kn/strings.xml b/core/res/res/values-kn/strings.xml index 6a11dc1d7314..fd04f79e289e 100644 --- a/core/res/res/values-kn/strings.xml +++ b/core/res/res/values-kn/strings.xml @@ -1834,7 +1834,7 @@ <string name="write_fail_reason_cannot_write" msgid="432118118378451508">"ವಿಷಯವನ್ನು ಬರೆಯುವಲ್ಲಿ ದೋಷ ಎದುರಾಗಿದೆ"</string> <string name="reason_unknown" msgid="5599739807581133337">"ಅಪರಿಚಿತ"</string> <string name="reason_service_unavailable" msgid="5288405248063804713">"ಮುದ್ರಣ ಸೇವೆ ಸಕ್ರಿಯಗೊಂಡಿಲ್ಲ"</string> - <string name="print_service_installed_title" msgid="6134880817336942482">"<xliff:g id="NAME">%s</xliff:g> ಸೇವೆಯನ್ನು ಸ್ಥಾಪಿಸಲಾಗಿದೆ"</string> + <string name="print_service_installed_title" msgid="6134880817336942482">"<xliff:g id="NAME">%s</xliff:g> ಸೇವೆಯನ್ನು ಇನ್ಸ್ಟಾಲ್ ಮಾಡಲಾಗಿದೆ"</string> <string name="print_service_installed_message" msgid="7005672469916968131">"ಸಕ್ರಿಯಗೊಳಿಸಲು ಟ್ಯಾಪ್ ಮಾಡಿ"</string> <string name="restr_pin_enter_admin_pin" msgid="1199419462726962697">"ನಿರ್ವಾಹಕ ಪಿನ್ ನಮೂದಿಸಿ"</string> <string name="restr_pin_enter_pin" msgid="373139384161304555">"ಪಿನ್ ನಮೂದಿಸಿ"</string> diff --git a/core/res/res/values-pt-rPT/strings.xml b/core/res/res/values-pt-rPT/strings.xml index c5a9b49b3dfd..c6fed6de316d 100644 --- a/core/res/res/values-pt-rPT/strings.xml +++ b/core/res/res/values-pt-rPT/strings.xml @@ -1393,7 +1393,7 @@ <string name="share_remote_bugreport_action" msgid="7630880678785123682">"PARTILHAR"</string> <string name="decline_remote_bugreport_action" msgid="4040894777519784346">"RECUSAR"</string> <string name="select_input_method" msgid="3971267998568587025">"Escolher o método de entrada"</string> - <string name="show_ime" msgid="6406112007347443383">"Manter no ecrã enquanto o teclado físico estiver ativo"</string> + <string name="show_ime" msgid="6406112007347443383">"Mantê-lo no ecrã enquanto o teclado físico estiver ativo"</string> <string name="hardware" msgid="1800597768237606953">"Mostrar o teclado virtual"</string> <string name="select_keyboard_layout_notification_title" msgid="5823199895322205589">"Configure o dispositivo <xliff:g id="DEVICE_NAME">%s</xliff:g>"</string> <string name="select_multiple_keyboards_layout_notification_title" msgid="6999491025126641938">"Configure teclados físicos"</string> diff --git a/core/res/res/values-sk/strings.xml b/core/res/res/values-sk/strings.xml index 63145dc92b52..515dc7d25735 100644 --- a/core/res/res/values-sk/strings.xml +++ b/core/res/res/values-sk/strings.xml @@ -1144,7 +1144,7 @@ <string name="elapsed_time_short_format_h_mm_ss" msgid="2302144714803345056">"<xliff:g id="HOURS">%1$d</xliff:g>:<xliff:g id="MINUTES">%2$02d</xliff:g>:<xliff:g id="SECONDS">%3$02d</xliff:g>"</string> <string name="selectAll" msgid="1532369154488982046">"Vybrať všetko"</string> <string name="cut" msgid="2561199725874745819">"Vystrihnúť"</string> - <string name="copy" msgid="5472512047143665218">"Kopírovať"</string> + <string name="copy" msgid="5472512047143665218">"Skopírovať"</string> <string name="failed_to_copy_to_clipboard" msgid="725919885138539875">"Nepodarilo sa skopírovať do schránky"</string> <string name="paste" msgid="461843306215520225">"Prilepiť"</string> <string name="paste_as_plain_text" msgid="7664800665823182587">"Prilepiť ako obyčajný text"</string> diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml index 6beee3d5980a..c8a5c92539f2 100644 --- a/core/res/res/values-zh-rCN/strings.xml +++ b/core/res/res/values-zh-rCN/strings.xml @@ -1392,7 +1392,7 @@ <string name="share_remote_bugreport_action" msgid="7630880678785123682">"分享"</string> <string name="decline_remote_bugreport_action" msgid="4040894777519784346">"拒绝"</string> <string name="select_input_method" msgid="3971267998568587025">"选择输入法"</string> - <string name="show_ime" msgid="6406112007347443383">"开启后,连接到实体键盘时,它会一直显示在屏幕上"</string> + <string name="show_ime" msgid="6406112007347443383">"连接到实体键盘时,在屏幕上显示一个虚拟键盘"</string> <string name="hardware" msgid="1800597768237606953">"显示虚拟键盘"</string> <string name="select_keyboard_layout_notification_title" msgid="5823199895322205589">"配置“<xliff:g id="DEVICE_NAME">%s</xliff:g>”"</string> <string name="select_multiple_keyboards_layout_notification_title" msgid="6999491025126641938">"配置物理键盘"</string> diff --git a/core/res/res/values-zh-rTW/strings.xml b/core/res/res/values-zh-rTW/strings.xml index bc1a1f27b5a0..f3fa19ea3034 100644 --- a/core/res/res/values-zh-rTW/strings.xml +++ b/core/res/res/values-zh-rTW/strings.xml @@ -1561,7 +1561,7 @@ <string name="keyboardview_keycode_done" msgid="2524518019001653851">"完成"</string> <string name="keyboardview_keycode_mode_change" msgid="2743735349997999020">"模式變更"</string> <string name="keyboardview_keycode_shift" msgid="3026509237043975573">"Shift 鍵"</string> - <string name="keyboardview_keycode_enter" msgid="168054869339091055">"Enter 鍵"</string> + <string name="keyboardview_keycode_enter" msgid="168054869339091055">"Enter"</string> <string name="activitychooserview_choose_application" msgid="3500574466367891463">"選擇應用程式"</string> <string name="activitychooserview_choose_application_error" msgid="6937782107559241734">"無法啟動 <xliff:g id="APPLICATION_NAME">%s</xliff:g>"</string> <string name="shareactionprovider_share_with" msgid="2753089758467748982">"分享對象:"</string> diff --git a/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt b/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt index 9acb99a8c1c2..b794352e5e27 100644 --- a/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt +++ b/core/tests/PackageInstallerSessions/src/android/content/pm/PackageSessionTests.kt @@ -445,7 +445,9 @@ class PackageSessionTests { Manifest.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION) } handlerThread = HandlerThread("PackageSessionTests") - handlerThread?.start() - handler = Handler(handlerThread?.looper) + handlerThread?.let { + it.start() + handler = Handler(it.looper) + } } } 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 e95e8e5cdaea..1b41f793311d 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 @@ class ManageEducationView constructor(context: Context, positioner: BubblePositi 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 @@ class ManageEducationView constructor(context: Context, positioner: BubblePositi 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 d0598cd28582..5e3a077a3716 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 @@ class StackEducationView constructor( 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 91bb155d9d01..8d1433595223 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 @@ -398,17 +398,18 @@ class DesktopTasksController( request: TransitionRequestInfo ): WindowContainerTransaction? { // Check if we should skip handling this transition + val triggerTask = request.triggerTask val shouldHandleRequest = when { // Only handle open or to front transitions request.type != TRANSIT_OPEN && request.type != TRANSIT_TO_FRONT -> false // Only handle when it is a task transition - request.triggerTask == null -> false + triggerTask == null -> false // Only handle standard type tasks - request.triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> false + triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> false // Only handle fullscreen or freeform tasks - request.triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN && - request.triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> false + triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN && + triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> false // Otherwise process it else -> true } @@ -417,27 +418,30 @@ class DesktopTasksController( return null } - val task: RunningTaskInfo = request.triggerTask - val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId) + if (triggerTask == null) { + return null + } + + val activeTasks = desktopModeTaskRepository.getActiveTasks(triggerTask.displayId) // Check if we should switch a fullscreen task to freeform - if (task.windowingMode == WINDOWING_MODE_FULLSCREEN) { + if (triggerTask.windowingMode == WINDOWING_MODE_FULLSCREEN) { // If there are any visible desktop tasks, switch the task to freeform if (activeTasks.any { desktopModeTaskRepository.isVisibleTask(it) }) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: switch fullscreen task to freeform on transition" + " taskId=%d", - task.taskId + triggerTask.taskId ) return WindowContainerTransaction().also { wct -> - addMoveToDesktopChanges(wct, task.token) + addMoveToDesktopChanges(wct, triggerTask.token) } } } // CHeck if we should switch a freeform task to fullscreen - if (task.windowingMode == WINDOWING_MODE_FREEFORM) { + if (triggerTask.windowingMode == WINDOWING_MODE_FREEFORM) { // If no visible desktop tasks, switch this task to freeform as the transition came // outside of this controller if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) { @@ -445,10 +449,10 @@ class DesktopTasksController( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: switch freeform task to fullscreen oon transition" + " taskId=%d", - task.taskId + triggerTask.taskId ) return WindowContainerTransaction().also { wct -> - addMoveToFullscreenChanges(wct, task.token) + addMoveToFullscreenChanges(wct, triggerTask.token) } } } @@ -471,7 +475,7 @@ class DesktopTasksController( token: WindowContainerToken ) { wct.setWindowingMode(token, WINDOWING_MODE_FULLSCREEN) - wct.setBounds(token, null) + wct.setBounds(token, Rect()) if (isDesktopDensityOverrideSet()) { wct.setDensityDpi(token, getFullscreenDensityDpi()) } 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 b67acd5c15bb..1aacb4dd739c 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,13 +23,13 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder( 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 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 appNameTextView: TextView = rootView.requireViewById(R.id.application_name) + private val appIconImageView: ImageView = rootView.requireViewById(R.id.application_icon) init { captionView.setOnTouchListener(onCaptionTouchListener) @@ -45,7 +45,9 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder( 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 47a12a0cb71c..9374ac95e83d 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 @@ internal class DesktopModeFocusedWindowDecorationViewHolder( 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 @@ internal class DesktopModeFocusedWindowDecorationViewHolder( } 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 514ea52cb8ae..b4ecbf5f3e32 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 @@ -23,6 +23,9 @@ internal abstract class DesktopModeWindowDecorationViewHolder(rootView: View) { * with the caption background color. */ protected fun shouldUseLightCaptionColors(taskInfo: RunningTaskInfo): Boolean { - return Color.valueOf(taskInfo.taskDescription.statusBarColor).luminance() < 0.5 + return taskInfo.taskDescription + ?.let { taskDescription -> + Color.valueOf(taskDescription.statusBarColor).luminance() < 0.5 + } ?: false } } diff --git a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt index b86eec04d542..8361877744cf 100644 --- a/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt +++ b/packages/CredentialManager/src/com/android/credentialmanager/DataConverter.kt @@ -68,11 +68,12 @@ fun getAppLabel( ): String? { return try { val pkgInfo = pm.getPackageInfo(appPackageName, PackageManager.PackageInfoFlags.of(0)) - pkgInfo.applicationInfo.loadSafeLabel( + val applicationInfo = checkNotNull(pkgInfo.applicationInfo) + applicationInfo.loadSafeLabel( pm, 0f, TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM ).toString() - } catch (e: PackageManager.NameNotFoundException) { + } catch (e: Exception) { Log.e(Constants.LOG_TAG, "Caller app not found", e) null } @@ -93,13 +94,14 @@ private fun getServiceLabelAndIcon( providerFlattenedComponentName, PackageManager.PackageInfoFlags.of(0) ) + val applicationInfo = checkNotNull(pkgInfo.applicationInfo) providerLabel = - pkgInfo.applicationInfo.loadSafeLabel( + applicationInfo.loadSafeLabel( pm, 0f, TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM ).toString() - providerIcon = pkgInfo.applicationInfo.loadIcon(pm) - } catch (e: PackageManager.NameNotFoundException) { + providerIcon = applicationInfo.loadIcon(pm) + } catch (e: Exception) { Log.e(Constants.LOG_TAG, "Provider package info not found", e) } } else { @@ -119,13 +121,14 @@ private fun getServiceLabelAndIcon( component.packageName, PackageManager.PackageInfoFlags.of(0) ) + val applicationInfo = checkNotNull(pkgInfo.applicationInfo) providerLabel = - pkgInfo.applicationInfo.loadSafeLabel( + applicationInfo.loadSafeLabel( pm, 0f, TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM ).toString() - providerIcon = pkgInfo.applicationInfo.loadIcon(pm) - } catch (e: PackageManager.NameNotFoundException) { + providerIcon = applicationInfo.loadIcon(pm) + } catch (e: Exception) { Log.e(Constants.LOG_TAG, "Provider package info not found", e) } } diff --git a/packages/EasterEgg/src/com/android/egg/quares/Quare.kt b/packages/EasterEgg/src/com/android/egg/quares/Quare.kt index eb77362a0be2..f0cc2a1eac93 100644 --- a/packages/EasterEgg/src/com/android/egg/quares/Quare.kt +++ b/packages/EasterEgg/src/com/android/egg/quares/Quare.kt @@ -137,14 +137,12 @@ class Quare(val width: Int, val height: Int, val depth: Int) : Parcelable { return 0 } - override fun writeToParcel(p: Parcel?, flags: Int) { - p?.let { - p.writeInt(width) - p.writeInt(height) - p.writeInt(depth) - p.writeIntArray(data) - p.writeIntArray(user) - } + override fun writeToParcel(p: Parcel, flags: Int) { + p.writeInt(width) + p.writeInt(height) + p.writeInt(depth) + p.writeIntArray(data) + p.writeIntArray(user) } companion object CREATOR : Parcelable.Creator<Quare> { diff --git a/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt index 578de01a0c30..562f7be5ae1e 100644 --- a/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt +++ b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt @@ -60,8 +60,8 @@ class QuaresActivity : Activity() { setContentView(R.layout.activity_quares) - grid = findViewById(R.id.grid) - label = findViewById(R.id.label) + grid = requireViewById(R.id.grid) + label = requireViewById(R.id.label) if (savedInstanceState != null) { Log.v(TAG, "restoring puzzle from state") @@ -135,7 +135,7 @@ class QuaresActivity : Activity() { if (q.check()) { val dp = resources.displayMetrics.density - val label: Button = findViewById(R.id.label) + val label: Button = requireViewById(R.id.label) label.text = resName.replace(Regex("^.*/"), "") val drawable = icon?.loadDrawable(this)?.also { it.setBounds(0, 0, (32 * dp).toInt(), (32 * dp).toInt()) @@ -293,7 +293,7 @@ class ClueView(context: Context) : View(context) { return correct } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) if (!showText) return canvas?.let { diff --git a/packages/SettingsLib/SearchWidget/res/values-fr-rCA/strings.xml b/packages/SettingsLib/SearchWidget/res/values-fr-rCA/strings.xml index 9977138f2079..1b22e9e3af8a 100644 --- a/packages/SettingsLib/SearchWidget/res/values-fr-rCA/strings.xml +++ b/packages/SettingsLib/SearchWidget/res/values-fr-rCA/strings.xml @@ -17,5 +17,5 @@ <resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <string name="search_menu" msgid="1914043873178389845">"Rechercher dans les paramètres"</string> + <string name="search_menu" msgid="1914043873178389845">"Recherchez dans les paramètres"</string> </resources> diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt index 2b38b4cefe3e..657c391da7c2 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/AppListRepository.kt @@ -75,6 +75,7 @@ internal class AppListRepositoryImpl(private val context: Context) : AppListRepo packageManager.getInstalledModules(0) .filter { it.isHidden } .map { it.packageName } + .filterNotNull() .toSet() } val hideWhenDisabledPackagesDeferred = async { diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt index 69c6131679a9..92fd0cd07777 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/app/PackageManagers.kt @@ -82,7 +82,8 @@ internal class PackageManagersImpl( val packageInfo = getPackageInfoAsUser(packageName, PackageManager.GET_PERMISSIONS, userId) val index = packageInfo?.requestedPermissions?.indexOf(permission) ?: return false return index >= 0 && - packageInfo.requestedPermissionsFlags[index].hasFlag(REQUESTED_PERMISSION_GRANTED) + checkNotNull(packageInfo.requestedPermissionsFlags)[index] + .hasFlag(REQUESTED_PERMISSION_GRANTED) } override suspend fun getAppOpPermissionPackages(userId: Int, permission: String): Set<String> = diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt index fab3ae8e510b..20beec73c958 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/model/enterprise/EnterpriseRepository.kt @@ -28,7 +28,7 @@ class EnterpriseRepository(private val context: Context) { } fun getEnterpriseString(updatableStringId: String, resId: Int): String = - resources.getString(updatableStringId) { context.getString(resId) } + checkNotNull(resources.getString(updatableStringId) { context.getString(resId) }) fun getProfileTitle(isManagedProfile: Boolean): String = if (isManagedProfile) { getEnterpriseString(WORK_CATEGORY_HEADER, R.string.category_work) diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt index a0ff216875a2..55a438f1f1fd 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppInfo.kt @@ -55,7 +55,7 @@ class AppInfoProvider(private val packageInfo: PackageInfo) { .semantics(mergeDescendants = true) {}, horizontalAlignment = Alignment.CenterHorizontally, ) { - val app = packageInfo.applicationInfo + val app = checkNotNull(packageInfo.applicationInfo) Box(modifier = Modifier.padding(SettingsDimension.itemPaddingAround)) { AppIcon(app = app, size = SettingsDimension.appIconInfoSize) } diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt index 7c689c62427e..1a627409632e 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppInfoPage.kt @@ -144,7 +144,7 @@ internal fun TogglePermissionAppListModel<out AppRecord>.TogglePermissionAppInfo footerContent = footerContent(), packageManagers = packageManagers, ) { - val model = createSwitchModel(applicationInfo) + val model = createSwitchModel(checkNotNull(applicationInfo)) val restrictions = Restrictions(userId, switchRestrictionKeys) RestrictedSwitchPreference(model, restrictions, restrictionsProviderFactory) } diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt index a03acc3a078c..73f6db6d464b 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 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int) 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 48dd08f206c1..a2c76839fea7 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 @@ constructor( // 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 @@ constructor( ): 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 @@ constructor( 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) { @@ -867,7 +867,7 @@ private class AnimatedDialog( } // Show the background dim. - dialog.window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) + dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) startAnimation( isLaunching = true, @@ -947,7 +947,7 @@ private class AnimatedDialog( 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 1a03ede98d12..6c4b695ed709 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 @@ constructor( 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 @@ constructor( 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 142fd21d4a16..d6eba2e7064d 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 @@ class LaunchAnimator(private val timings: Timings, private val interpolators: In 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 @@ class LaunchAnimator(private val timings: Timings, private val interpolators: In 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 b555fa583588..8dc74951d332 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 @@ interface TypefaceVariantCache { 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 @@ class TextAnimator( } 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 @@ class TextAnimator( 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 8e79e3ce1742..68d745621c87 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ViewHierarchyAnimator.kt @@ -1020,7 +1020,7 @@ class ViewHierarchyAnimator { } } - 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 a4b1ceeebfa3..c1cc3bd3c563 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/WeatherData.kt @@ -52,7 +52,7 @@ constructor( 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/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt index 070a45170d04..bca9c31052b9 100644 --- a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt +++ b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt @@ -145,6 +145,7 @@ open class ViewScreenshotTestRule( activityRule.scenario.onActivity { activity -> dialog = dialogProvider(activity).apply { + val window = checkNotNull(window) // Make sure that the dialog draws full screen and fits the whole display // instead of the system bars. window.setDecorFitsSystemWindows(false) @@ -175,7 +176,7 @@ open class ViewScreenshotTestRule( } private fun Dialog.toBitmap(): Bitmap { - val window = window + val window = checkNotNull(window) return window.decorView.toBitmap(window) } 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 c1429335292f..5edd283bf131 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 @@ object ActivityManagerKt { */ 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 d7e61d60aa55..ebc57d2f8af7 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 @@ class SmartspaceState() : Parcelable { 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 aca9907fec1b..dac130d684bd 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 @@ class NaturalRotationUnfoldProgressProvider( 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 084295343bb0..734df940fd37 100644 --- a/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt +++ b/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt @@ -105,7 +105,7 @@ open class BouncerKeyguardMessageArea(context: Context?, attrs: AttributeSet?) : hideAnimator.addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { super@BouncerKeyguardMessageArea.setMessage(msg, animate) } } @@ -118,7 +118,7 @@ open class BouncerKeyguardMessageArea(context: Context?, attrs: AttributeSet?) : 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 8ea4c31a5ac9..0b41c8b39609 100644 --- a/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +++ b/packages/SystemUI/src/com/android/keyguard/ClockEventController.kt @@ -110,20 +110,20 @@ constructor( } value.smallClock.view.addOnAttachStateChangeListener( 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.addOnAttachStateChangeListener( 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) { } }) } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java index 6854c97c3415..ad0d52755424 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java @@ -23,6 +23,7 @@ import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_CL import android.animation.Animator; import android.animation.ValueAnimator; +import android.annotation.NonNull; import android.annotation.Nullable; import android.content.res.Configuration; import android.graphics.Rect; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 6f0f6331ef50..66689250e95f 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 @@ class AuthRippleController @Inject constructor( 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 5ede16d221b7..4c2dc41fb759 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 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at 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 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at 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 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at 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 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at 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 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at } } - 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/SideFpsController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt index 54aef00a5a8c..9e8370e3fbf5 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/SideFpsController.kt @@ -117,7 +117,7 @@ constructor( 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() @@ -262,7 +262,7 @@ constructor( } 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 8352d0aeab35..5dafa61f9a27 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 @@ class UdfpsFpmEmptyView( 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/domain/interactor/CredentialInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/CredentialInteractor.kt index 1f1a1b5c83bd..2a026675adcb 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 @@ constructor( ) 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 @@ private fun Context.getLastAttemptBeforeWipeProfileMessage( 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 @@ private fun Context.getLastAttemptBeforeWipeProfileMessage( } getString(defaultId) } + + return devicePolicyManager.resources?.getString(id, getFallbackString) ?: getFallbackString() } private fun Context.getLastAttemptBeforeWipeUserMessage( @@ -266,8 +267,8 @@ private fun Context.getNowWipingMessage( 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 @@ private fun Context.getNowWipingMessage( } 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 a3f34ce7471d..b940ec85efbf 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 @@ class CredentialPasswordView(context: Context, attrs: AttributeSet?) : 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 8486c3f96b21..a881c07021fc 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 @@ -88,27 +88,27 @@ object BiometricViewBinder { 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 for marquee titleView.isSelected = true subtitleView.isSelected = true 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 1dffa80a084f..2b06f3aa4df3 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 @@ -71,7 +71,7 @@ object BiometricViewSizeBinder { } } - 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) @@ -198,7 +198,7 @@ object BiometricViewSizeBinder { } 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 5ca36ab39dba..ddb097491988 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 @@ class WiredChargingRippleController @Inject constructor( } 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 @@ class WiredChargingRippleController @Inject constructor( 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 63d57cc3fc8d..a9f3b77ceb5e 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 @@ import javax.inject.Inject */ 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 3e6ac86e2417..c0d1951c22ce 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 @@ constructor( .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 f17d0f307473..0b327a19ef81 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 @@ class ContrastDialog( 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 e8c97bf77271..4a534e9cc74d 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 @@ class ControlsControllerImpl @Inject constructor ( 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 59fa7f53fc17..da571b3af086 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsFavoritingActivity.kt @@ -216,7 +216,7 @@ open class ControlsFavoritingActivity @Inject constructor( 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 ff55b76d4db7..a13f717bc77d 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 @@ object ChallengeDialogs { } ) - 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 @@ object ChallengeDialogs { ) } 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 c04bc8792223..abe342320858 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 @@ class ControlViewHolder( ) } addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { stateAnimator = null } }) @@ -438,7 +438,7 @@ class ControlViewHolder( duration = 200L interpolator = Interpolators.LINEAR addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { statusRowUpdater.invoke() } }) @@ -450,7 +450,7 @@ class ControlViewHolder( 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 be50a1468f07..98f17f409184 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 @@ class DetailDialog( 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 @@ class DetailDialog( } // 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 @@ class DetailDialog( } 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 ad2b785ea5c5..dbbda9aad518 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 @@ data class RenderInfo( 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 84cda5a541e3..3c2bfa0efc39 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 @@ class StatusBehavior : Behavior { ) } 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 1461135d3d3b..b2c95a63ad72 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 @@ class ToggleRangeBehavior : Behavior { 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 @@ class ToggleRangeBehavior : Behavior { } override fun onScroll( - e1: MotionEvent, + e1: MotionEvent?, e2: MotionEvent, xDiff: Float, yDiff: Float 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 70783418ddb4..b5b56b2b2108 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 @@ class KeyboardBacklightDialog( } 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 c019d21e00ed..5d7a3d432dcb 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 @@ constructor( 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 @@ constructor( ) } - 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 @@ constructor( 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 9621f03f63a0..6a58879c58b8 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 @@ -538,7 +538,7 @@ constructor( // 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 482e9a3d09d7..5654faaa6266 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 @@ -136,12 +136,13 @@ constructor( 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 5ad6e5196f66..30ca6affcc0c 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 @@ -488,7 +488,7 @@ object KeyguardBottomAreaViewBinder { 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/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt index b92d10474ccd..ece6ff278507 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 @@ -97,7 +97,7 @@ constructor( 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 e06483990c90..5f7991e62cd7 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 @@ fun View.repeatWhenAttached( 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 @@ fun View.repeatWhenAttached( ) } - 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 35f5a8ca4345..a91917ab97c2 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 @@ constructor( * 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 @@ constructor( * 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 207df6bc4422..a1291a4d6b0f 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 @@ constructor( // 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 @@ constructor( "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 69f02f785b03..721052b6e571 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 @@ -23,6 +23,7 @@ import android.app.Notification.EXTRA_SUBSTITUTE_APP_NAME import android.app.PendingIntent import android.app.StatusBarManager import android.app.UriGrantsManager +import android.app.smartspace.SmartspaceAction import android.app.smartspace.SmartspaceConfig import android.app.smartspace.SmartspaceManager import android.app.smartspace.SmartspaceSession @@ -1650,20 +1651,18 @@ class MediaDataManager( * 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 d6f941de1b6d..6a8ffb7d8c42 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 @@ constructor( private val sessionListener = object : MediaSessionManager.OnActiveSessionsChangedListener { - override fun onActiveSessionsChanged(controllers: List<MediaController>) { + override fun onActiveSessionsChanged(controllers: List<MediaController>?) { handleControllersChanged(controllers) } } @@ -190,16 +190,18 @@ constructor( } } - 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 b46ebb22ff05..b9cc772e7136 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 @@ class IlluminationDrawable : Drawable() { } 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 937a618df68f..646d1d0ff0fc 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 @@ class LightSourceDrawable : Drawable() { 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 @@ class LightSourceDrawable : Drawable() { ) addListener( object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { rippleData.progress = 0f rippleAnimation = null invalidateSelf() @@ -270,11 +270,8 @@ class LightSourceDrawable : Drawable() { 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 1ace3168780a..ce50a11cd85d 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 @@ class MediaCarouselScrollHandler( 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 fe8ebafdf9b4..c1c757e424dc 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 @@ constructor( 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 @@ constructor( 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 @@ constructor( 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 be570b4a1119..631a0b8471b8 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 @@ constructor( 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 583c626d2156..16dfc2130402 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 @@ class SquigglyProgress : Drawable() { } 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 bbd3d33e45c8..da8e106d3019 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 @@ open class MediaTttChipControllerReceiver @Inject constructor( } 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 50138024e268..fbf7e25981da 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 @@ constructor( ) 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 0b0535df6228..35018f190394 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 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi // 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 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi 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 f75f8b9a18f7..87d0098805b3 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 @@ constructor( 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 c816446d5c25..64de9bd76122 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 @@ constructor( .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/people/ui/view/PeopleViewBinder.kt b/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt index d8a429e5bb1a..a821d3ce8c07 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 @@ -140,13 +140,13 @@ object PeopleViewBinder { 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/screenrecord/BaseScreenSharePermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt index b34004397520..23894a3f7835 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 @@ open class BaseScreenSharePermissionDialog( 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 @@ open class BaseScreenSharePermissionDialog( 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 604d44967e68..e8683fbea735 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 @@ class ScreenRecordPermissionDialog( @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 3af75cef3d4c..5f53b594a4b6 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt @@ -126,11 +126,11 @@ constructor( 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 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 var roundedCorners = 0 private var cutout: DisplayCutout? = null @@ -555,7 +555,7 @@ constructor( 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) { @@ -563,7 +563,7 @@ constructor( } } - 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/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt index b7551cf3408e..e284ac5b6a77 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt @@ -80,7 +80,7 @@ abstract class ShadeModule { fun providesNotificationStackScrollLayout( notificationShadeWindowView: NotificationShadeWindowView, ): NotificationStackScrollLayout { - return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller) + return notificationShadeWindowView.requireViewById(R.id.notification_stack_scroller) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -89,7 +89,7 @@ abstract class ShadeModule { fun providesNotificationPanelView( notificationShadeWindowView: NotificationShadeWindowView, ): NotificationPanelView { - return notificationShadeWindowView.findViewById(R.id.notification_panel) + return notificationShadeWindowView.requireViewById(R.id.notification_panel) } @Provides @@ -97,7 +97,7 @@ abstract class ShadeModule { fun providesLightRevealScrim( notificationShadeWindowView: NotificationShadeWindowView, ): LightRevealScrim { - return notificationShadeWindowView.findViewById(R.id.light_reveal_scrim) + return notificationShadeWindowView.requireViewById(R.id.light_reveal_scrim) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -106,7 +106,7 @@ abstract class ShadeModule { 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. @@ -115,7 +115,7 @@ abstract class ShadeModule { fun providesLockIconView( notificationShadeWindowView: NotificationShadeWindowView, ): LockIconView { - return notificationShadeWindowView.findViewById(R.id.lock_icon_view) + return notificationShadeWindowView.requireViewById(R.id.lock_icon_view) } // TODO(b/277762009): Only allow this view's controller to inject the view. See above. @@ -124,7 +124,7 @@ abstract class ShadeModule { 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. @@ -134,7 +134,7 @@ abstract class ShadeModule { 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 @@ -151,7 +151,7 @@ abstract class ShadeModule { @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 @@ -185,7 +185,7 @@ abstract class ShadeModule { fun providesOngoingPrivacyChip( @Named(SHADE_HEADER) header: MotionLayout, ): OngoingPrivacyChip { - return header.findViewById(R.id.privacy_chip) + return header.requireViewById(R.id.privacy_chip) } @Provides @@ -194,7 +194,7 @@ abstract class ShadeModule { 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 37140ec2aa32..520976746785 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 @@ class BatteryStatusChip @JvmOverloads constructor(context: Context, attrs: Attri 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 823bb355a307..b2b6e1424f98 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 @@ constructor( 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 c098f455512a..2d65c3884abf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -475,7 +475,7 @@ class LockscreenShadeTransitionController @Inject constructor( } 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 750272d65659..17b4e3baef13 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 @@ class MediaArtworkProcessor @Inject constructor() { 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 b624115dc5e7..59c63aa28d0f 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 @@ class NotificationShadeDepthController @Inject constructor( 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 eddb6835318d..d1e0a7193948 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 @@ open class PrivacyDotViewController @Inject constructor( } // 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 @@ open class PrivacyDotViewController @Inject constructor( // 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 6c1dc8c0a51d..fe1144e0deac 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt @@ -165,7 +165,11 @@ constructor( now.isBefore(Instant.ofEpochMilli(t.expiryTimeMillis)) } if (weatherTarget != null) { - val weatherData = WeatherData.fromBundle(weatherTarget.baseAction.extras) + val weatherData = weatherTarget.baseAction?.extras?.let { extras -> + WeatherData.fromBundle( + extras, + ) + } 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 16f1a45ba83f..1b43922f652a 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 @@ class ViewGroupFadeHelper { 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 38a1579222b1..9c4aa072a83d 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 @@ class ChannelEditorListView(c: Context, attrs: AttributeSet) : LinearLayout(c, a override fun onFinishInflate() { super.onFinishInflate() - appControlRow = findViewById(R.id.app_control) + appControlRow = requireViewById(R.id.app_control) } /** @@ -143,9 +143,9 @@ class AppControlView(c: Context, attrs: AttributeSet) : LinearLayout(c, attrs) { 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 @@ class ChannelRow(c: Context, attrs: AttributeSet) : LinearLayout(c, attrs) { 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 1827a46958f8..2a4eba486089 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt @@ -879,8 +879,8 @@ constructor( 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 d433814d7ce4..d832b6b75200 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.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel 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 @@ -94,7 +95,7 @@ constructor( 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 e6cb68ff17a9..0f6d6244354a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewController.kt @@ -67,8 +67,8 @@ class PhoneStatusBarViewController private constructor( override fun onViewAttached() { 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 c850d4f9c56b..ad1817019284 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 @@ class StatusBarContentInsetsProvider @Inject constructor( * 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 @@ class StatusBarContentInsetsProvider @Inject constructor( */ 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 @@ class StatusBarContentInsetsProvider @Inject constructor( 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 135307accd13..5a90edde342e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -101,18 +101,18 @@ class UnlockedScreenOffAnimationController @Inject constructor( } } 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( mCentralSurfaces.notificationShadeWindowView, CUJ_SCREEN_OFF) } @@ -339,7 +339,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // 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 270c592ae4fd..12594771a0df 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 @@ class StatusBarUserSwitcherContainer( 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 49504827e073..ffb743ff926c 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 @@ public class DeviceControlsControllerImpl @Inject constructor( 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 @@ public class DeviceControlsControllerImpl @Inject constructor( } 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 27aaa6828036..eb7d339f5b42 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 @@ constructor( // 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 72786efc416d..5ad963035e36 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 @@ class UserSwitchFullscreenDialog( 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 088cd93bdf7e..ee84580ac4ec 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 @@ class UserSwitcherPopupMenu( 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 e74232df3ac3..7f16e47abce1 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 @@ object LegacyUserUiHelper { 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 56c5d3b433ff..7866d7673937 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 @@ class TransitionLayout @JvmOverloads constructor( } } - 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 2908e753c2fe..565e22f4fc25 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 @@ class SideFpsControllerTest : SysuiTestCase() { 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 2da2e9238d0a..8fe7010260ac 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt @@ -134,18 +134,18 @@ class ShadeHeaderControllerTest : SysuiTestCase() { @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<StatusIconContainer>(view.requireViewById(R.id.statusIcons)).thenReturn(statusIcons) viewContext = Mockito.spy(context) whenever(view.context).thenReturn(viewContext) diff --git a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt index de7dc3b53752..fc10f2623eb4 100644 --- a/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt +++ b/services/permission/java/com/android/server/permission/access/permission/PermissionService.kt @@ -931,7 +931,7 @@ class PermissionService( isGranted: Boolean ) { val appOpPolicy = service.getSchemePolicy(UidUri.SCHEME, AppOpUri.SCHEME) as UidAppOpPolicy - val appOpName = AppOpsManager.permissionToOp(permissionName) + val appOpName = checkNotNull(AppOpsManager.permissionToOp(permissionName)) val mode = if (isGranted) AppOpsManager.MODE_ALLOWED else AppOpsManager.MODE_ERRORED with(appOpPolicy) { setAppOpMode(packageState.appId, userId, appOpName, mode) } } @@ -1889,7 +1889,7 @@ class PermissionService( packageName: String, appId: Int, packageState: PackageState, - androidPackage: AndroidPackage?, + androidPackage: AndroidPackage, sharedUserPkgs: List<AndroidPackage>, userId: Int ) { diff --git a/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt b/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt index 32c2230e4880..ad95fbc36867 100644 --- a/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt +++ b/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt @@ -39,7 +39,7 @@ class PeerDeviceSystemAttestationVerificationTest { @Before fun setup() { rule.getScenario().onActivity { - avm = it.getSystemService(AttestationVerificationManager::class.java) + avm = it.getSystemService(AttestationVerificationManager::class.java)!! activity = it } invalidAttestationByteArray = TEST_ATTESTATION_CERT_FILENAME.fromPEMFileToByteArray() diff --git a/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt b/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt index 169effaa45ca..8f06b4a2ea0a 100644 --- a/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt +++ b/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt @@ -43,7 +43,7 @@ class SystemAttestationVerificationTest { @Before fun setup() { rule.getScenario().onActivity { - avm = it.getSystemService(AttestationVerificationManager::class.java) + avm = it.getSystemService(AttestationVerificationManager::class.java)!! activity = it androidKeystore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) } } diff --git a/tests/Input/src/com/android/test/input/AnrTest.kt b/tests/Input/src/com/android/test/input/AnrTest.kt index d185ee6ae116..7bc5df52e316 100644 --- a/tests/Input/src/com/android/test/input/AnrTest.kt +++ b/tests/Input/src/com/android/test/input/AnrTest.kt @@ -134,7 +134,7 @@ class AnrTest { private fun getExitReasons(): List<ApplicationExitInfo> { lateinit var infos: List<ApplicationExitInfo> instrumentation.runOnMainSync { - val am = instrumentation.getContext().getSystemService(ActivityManager::class.java) + val am = instrumentation.getContext().getSystemService(ActivityManager::class.java)!! infos = am.getHistoricalProcessExitReasons(PACKAGE_NAME, ALL_PIDS, NO_MAX) } return infos diff --git a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt index 3a24406e2b73..63782f1bf955 100644 --- a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt +++ b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt @@ -45,9 +45,9 @@ class UnresponsiveGestureMonitorActivity : Activity() { private lateinit var mInputMonitor: InputMonitor override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val inputManager = getSystemService(InputManager::class.java) + val inputManager = checkNotNull(getSystemService(InputManager::class.java)) mInputMonitor = inputManager.monitorGestureInput(MONITOR_NAME, displayId) mInputEventReceiver = UnresponsiveReceiver( - mInputMonitor.getInputChannel(), Looper.myLooper()) + mInputMonitor.getInputChannel(), Looper.myLooper()!!) } } diff --git a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt index 8a653045c97b..1a79a11a3718 100644 --- a/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt +++ b/tests/SilkFX/src/com/android/test/silkfx/hdr/GainmapMetadataEditor.kt @@ -99,23 +99,23 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { (view.getParent() as ViewGroup).removeView(view) parent.addView(view) - view.findViewById<Button>(R.id.gainmap_metadata_done)!!.setOnClickListener { + view.requireViewById<Button>(R.id.gainmap_metadata_done).setOnClickListener { closeEditor() } - view.findViewById<Button>(R.id.gainmap_metadata_reset)!!.setOnClickListener { + view.requireViewById<Button>(R.id.gainmap_metadata_reset).setOnClickListener { resetGainmapMetadata() } updateMetadataUi() - val gainmapMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin) - val gainmapMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax) - val capacityMinSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin) - val capacityMaxSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax) - val gammaSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_gamma) - val offsetSdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr) - val offsetHdrSeek = view.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr) + val gainmapMinSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin) + val gainmapMaxSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax) + val capacityMinSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymin) + val capacityMaxSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymax) + val gammaSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_gamma) + val offsetSdrSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr) + val offsetHdrSeek = view.requireViewById<SeekBar>(R.id.gainmap_metadata_offsethdr) arrayOf(gainmapMinSeek, gainmapMaxSeek, capacityMinSeek, capacityMaxSeek, gammaSeek, offsetSdrSeek, offsetHdrSeek).forEach { it.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{ @@ -140,13 +140,13 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { } private fun updateMetadataUi() { - val gainmapMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin) - val gainmapMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax) - val capacityMinSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymin) - val capacityMaxSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_capacitymax) - val gammaSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_gamma) - val offsetSdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr) - val offsetHdrSeek = parent.findViewById<SeekBar>(R.id.gainmap_metadata_offsethdr) + val gainmapMinSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmin) + val gainmapMaxSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gainmapmax) + val capacityMinSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymin) + val capacityMaxSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_capacitymax) + val gammaSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_gamma) + val offsetSdrSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_offsetsdr) + val offsetHdrSeek = parent.requireViewById<SeekBar>(R.id.gainmap_metadata_offsethdr) gainmapMinSeek.setProgress( ((currentMetadata.ratioMin - minRatioMin) / maxRatioMin * maxProgress).toInt()) @@ -166,19 +166,19 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { ((1.0 - Math.log(currentMetadata.offsetHdr.toDouble() / Math.log(3.0)) / -11.0) .toFloat() * maxProgress).toInt()) - parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val).setText( "%.3f".format(currentMetadata.ratioMin)) - parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val).setText( "%.3f".format(currentMetadata.ratioMax)) - parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymin_val).setText( "%.3f".format(currentMetadata.capacityMin)) - parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymax_val).setText( "%.3f".format(currentMetadata.capacityMax)) - parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gamma_val).setText( "%.3f".format(currentMetadata.gamma)) - parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val).setText( "%.5f".format(currentMetadata.offsetSdr)) - parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_offsethdr_val).setText( "%.5f".format(currentMetadata.offsetHdr)) } @@ -201,7 +201,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { private fun updateGainmapMin(normalized: Float) { val newValue = minRatioMin + normalized * (maxRatioMin - minRatioMin) - parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmin_val).setText( "%.3f".format(newValue)) currentMetadata.ratioMin = newValue if (showingEdits) { @@ -212,7 +212,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { private fun updateGainmapMax(normalized: Float) { val newValue = minRatioMax + normalized * (maxRatioMax - minRatioMax) - parent.findViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gainmapmax_val).setText( "%.3f".format(newValue)) currentMetadata.ratioMax = newValue if (showingEdits) { @@ -223,7 +223,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { private fun updateCapacityMin(normalized: Float) { val newValue = minCapacityMin + normalized * (maxCapacityMin - minCapacityMin) - parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymin_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymin_val).setText( "%.3f".format(newValue)) currentMetadata.capacityMin = newValue if (showingEdits) { @@ -234,7 +234,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { private fun updateCapacityMax(normalized: Float) { val newValue = minCapacityMax + normalized * (maxCapacityMax - minCapacityMax) - parent.findViewById<TextView>(R.id.gainmap_metadata_capacitymax_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_capacitymax_val).setText( "%.3f".format(newValue)) currentMetadata.capacityMax = newValue if (showingEdits) { @@ -245,7 +245,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { private fun updateGamma(normalized: Float) { val newValue = minGamma + normalized * (maxGamma - minGamma) - parent.findViewById<TextView>(R.id.gainmap_metadata_gamma_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_gamma_val).setText( "%.3f".format(newValue)) currentMetadata.gamma = newValue if (showingEdits) { @@ -259,7 +259,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { if (normalized > 0.0f ) { newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat() } - parent.findViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_offsetsdr_val).setText( "%.5f".format(newValue)) currentMetadata.offsetSdr = newValue if (showingEdits) { @@ -273,7 +273,7 @@ class GainmapMetadataEditor(val parent: ViewGroup, val renderView: View) { if (normalized > 0.0f ) { newValue = Math.pow(3.0, (1.0 - normalized.toDouble()) * -11.0).toFloat() } - parent.findViewById<TextView>(R.id.gainmap_metadata_offsethdr_val)!!.setText( + parent.requireViewById<TextView>(R.id.gainmap_metadata_offsethdr_val).setText( "%.5f".format(newValue)) currentMetadata.offsetHdr = newValue if (showingEdits) { diff --git a/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt b/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt index 9d17d38d4298..4d38660e6029 100644 --- a/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt +++ b/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt @@ -132,7 +132,7 @@ class BackgroundBlurActivity : Activity(), SeekBar.OnSeekBarChangeListener { mBlurForceDisabled = disabled Settings.Global.putInt(getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS, if (mBlurForceDisabled) 1 else 0) - (findViewById(R.id.toggle_blur_enabled) as Button) + (requireViewById(R.id.toggle_blur_enabled) as Button) .setText(if (mBlurForceDisabled) "Enable blurs" else "Disable blurs") } @@ -142,13 +142,13 @@ class BackgroundBlurActivity : Activity(), SeekBar.OnSeekBarChangeListener { fun setBackgroundBlur(radius: Int) { mBackgroundBlurRadius = radius - (findViewById(R.id.background_blur_radius) as TextView).setText(radius.toString()) + (requireViewById(R.id.background_blur_radius) as TextView).setText(radius.toString()) window.setBackgroundBlurRadius(mBackgroundBlurRadius) } fun setBlurBehind(radius: Int) { mBlurBehindRadius = radius - (findViewById(R.id.blur_behind_radius) as TextView).setText(radius.toString()) + (requireViewById(R.id.blur_behind_radius) as TextView).setText(radius.toString()) window.getAttributes().setBlurBehindRadius(mBlurBehindRadius) window.setAttributes(window.getAttributes()) } @@ -159,7 +159,7 @@ class BackgroundBlurActivity : Activity(), SeekBar.OnSeekBarChangeListener { } else { mDimAmountNoBlur = amount } - (findViewById(R.id.dim_amount) as TextView).setText("%.2f".format(amount)) + (requireViewById(R.id.dim_amount) as TextView).setText("%.2f".format(amount)) window.getAttributes().dimAmount = amount window.setAttributes(window.getAttributes()) } @@ -168,7 +168,7 @@ class BackgroundBlurActivity : Activity(), SeekBar.OnSeekBarChangeListener { mBatterySavingModeOn = on Settings.Global.putInt(getContentResolver(), Settings.Global.LOW_POWER_MODE, if (on) 1 else 0) - (findViewById(R.id.toggle_battery_saving_mode) as Button).setText( + (requireViewById(R.id.toggle_battery_saving_mode) as Button).setText( if (on) "Exit low power mode" else "Enter low power mode") } @@ -182,7 +182,7 @@ class BackgroundBlurActivity : Activity(), SeekBar.OnSeekBarChangeListener { } else { mAlphaNoBlur = alpha } - (findViewById(R.id.background_alpha) as TextView).setText("%.2f".format(alpha)) + (requireViewById(R.id.background_alpha) as TextView).setText("%.2f".format(alpha)) mBackgroundDrawable.setAlpha((alpha * 255f).toInt()) getWindowManager().updateViewLayout(window.getDecorView(), window.getAttributes()) } diff --git a/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt b/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt index 2f2578b87f35..41baeadf7a8c 100644 --- a/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt +++ b/tests/SilkFX/src/com/android/test/silkfx/materials/GlassView.kt @@ -190,9 +190,9 @@ class GlassView(context: Context, attributeSet: AttributeSet) : FrameLayout(cont sensorManager?.unregisterListener(sensorListener) } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { updateGlassRenderNode() - canvas?.drawRenderNode(renderNode) + canvas.drawRenderNode(renderNode) } fun resetGyroOffsets() { @@ -227,4 +227,4 @@ class GlassView(context: Context, attributeSet: AttributeSet) : FrameLayout(cont renderNodeIsDirty = false } } -}
\ No newline at end of file +} |