Keyboard Shortcuts: protect against NPE in WindowManagerService

Using an unresponsive app [while (true) { Thread.sleep(1000) }]
produces NPE:

WindowManager: Window Manager Crash
WindowManager: java.lang.NullPointerException: Attempt to read
               from field 'android.view.IWindow
               com.android.server.wm.WindowState.mClient' on a
               null object reference
WindowManager: at com.android.server.wm.WindowManagerService
               .requestAppKeyboardShortcuts
               (WindowManagerService.java:10628)

Which puts down SysUI (and requires restarting SysUI).

Protect against this by checking for nulls. The end result
is that the dialog is no longer shown for unresponsive apps
and SysUI does not break.

Bug: 27914463
Change-Id: I37f0b0d5980f6ddc50f3bb778582d23ee1c7e9c3
1 file changed