From db625de3c866bc2f83904eae28f741a7a74d37a8 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Thu, 7 May 2020 18:31:29 +0800 Subject: [PATCH] Handle the WatchRotation failed WindowManagerService#WatchRotation throw the IllegalArgumentException when trying to register the rotation event with invalid display. There is a case in MultiDisplaySystemDecorationTests when the display is invalid, but the RotationButtonController still tries to register the rotation event. The symptom impact the WindowManager CTS to execute tesing completely. This CL do the basic protection first to make the WM CTS more smooth. Bug: 153607881 Test: atest MultiDisplaySystemDecorationTests Change-Id: Ie3c240c3bc270d1f145640ee420b33ce95902e5d --- .../systemui/statusbar/phone/RotationButtonController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java index 0147e7ff7cb21..ba323271faaab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/RotationButtonController.java @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Looper; import android.os.RemoteException; import android.provider.Settings; +import android.util.Log; import android.view.IRotationWatcher.Stub; import android.view.MotionEvent; import android.view.Surface; @@ -53,6 +54,7 @@ import java.util.function.Consumer; /** Contains logic that deals with showing a rotate suggestion button with animation. */ public class RotationButtonController { + private static final String TAG = "StatusBar/RotationButtonController"; private static final int BUTTON_FADE_IN_OUT_DURATION_MS = 100; private static final int NAVBAR_HIDDEN_PENDING_ICON_TIMEOUT_MS = 20000; @@ -138,6 +140,9 @@ public class RotationButtonController { try { WindowManagerGlobal.getWindowManagerService() .watchRotation(mRotationWatcher, mContext.getDisplay().getDisplayId()); + } catch (IllegalArgumentException e) { + mListenersRegistered = false; + Log.w(TAG, "RegisterListeners for the display failed"); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); }