Prevent NPEs when no focusable stack.
Fallback to home stack when no focusable stack (e.g. launcher force stopped & enter PIP mode with no other app task), Fix NPEs for logWindowState & getTopRunningActivity from null stack. Change-Id: I0a0134661dfc20ff844a0bc19ce6833242f4a865 Fixes: 110078217 Test: Manual Test: atest ActivityStackSupervisorTests ActivityStackTests ActivityStarterTests
This commit is contained in:
@@ -185,6 +185,10 @@ class ActivityMetricsLogger {
|
||||
|
||||
mWindowState = WINDOW_STATE_INVALID;
|
||||
ActivityStack stack = mSupervisor.getFocusedStack();
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack.isActivityTypeAssistant()) {
|
||||
mWindowState = WINDOW_STATE_ASSISTANT;
|
||||
return;
|
||||
|
||||
@@ -708,6 +708,11 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
|
||||
if (!focusCandidate.isFocusable()) {
|
||||
// The focus candidate isn't focusable. Move focus to the top stack that is focusable.
|
||||
focusCandidate = getNextFocusableStackLocked(focusCandidate, false /* ignoreCurrent */);
|
||||
if (focusCandidate == null) {
|
||||
Slog.w(TAG,
|
||||
"setFocusStackUnchecked: No focusable stack found, focus home as default");
|
||||
focusCandidate = mHomeStack;
|
||||
}
|
||||
}
|
||||
|
||||
if (focusCandidate != mFocusedStack) {
|
||||
|
||||
Reference in New Issue
Block a user