From d0ca0e09842221ac8c587eda8c0c25aff61dd6f2 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 29 Mar 2016 10:32:56 -0700 Subject: [PATCH] Ensure window has been added in isTopOfTask Bug 27893230 When isTopOfTask is called prior to the window being added, it will throw an IllegalArgumentException. This checks that the window has been added before making the call. Change-Id: Idd14c0f1051e16d96a0a1fa9f990f380a1f69911 --- core/java/android/app/Activity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 887932a7dbbb8..0d387e660f8ab 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5920,6 +5920,9 @@ public class Activity extends ContextThemeWrapper * @return true if this is the topmost, non-finishing activity in its task. */ private boolean isTopOfTask() { + if (mToken == null || mWindow == null || !mWindowAdded) { + return false; + } try { return ActivityManagerNative.getDefault().isTopOfTask(mToken); } catch (RemoteException e) {