Search code examples
androidandroid-source

NullPointerException when inPinnedWindowingMode is called in ActivityStarter.isAllowedToStart


I'm investigating a crash in an Android app that started to appear on some Xiaomi and OnePlus devices a couple of days back. It only occurs for a low number of users (< 10) at the moment, but it bothers me that I can't figure out what is going on.

The crash is triggered by a call to startActivity(...) in the app, but the actual exception is thrown by a system process, inside ActivityStarter:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.wm.ConfigurationContainer.inPinnedWindowingMode()' on a null object reference
at com.android.server.wm.ActivityStarter.isAllowedToStart(ActivityStarter.java:2068)
at com.android.server.wm.ActivityStarter.startActivityInner(ActivityStarter.java:1874)      
at com.android.server.wm.ActivityStarter.startActivityUnchecked(ActivityStarter.java:1678)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1231)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:717)

There are two things in that puzzles me about this:

  • The call stack shows that the call to inPinnedWindowingMode happens on ActivityStarter.java:2068. However, I can't find find any revision of ActivityStarter.java in the Google repo where the call happens on line 2068.
  • The only place in ActivityStarter that calls inPinnedWindowingMode also calls isUidPresent on the same object, but this doesn't cause the NPE:
boolean blockBalInTask = (newTask
        || !targetTask.isUidPresent(mCallingUid)
        || (LAUNCH_SINGLE_INSTANCE == mLaunchMode && targetTask.inPinnedWindowingMode()));

https://cs.android.com/android/platform/superproject/+/master:frameworks/base/services/core/java/com/android/server/wm/ActivityStarter.java;drc=11b75eba3af4c5a46304dc51be66884a26d44cea;l=1785

What could explain this behaviour?

Unable to reproduce the issue and it only happens for a low number of users.


Solution

  • It seems like the crashes is being triggered by a custom "Evolution-X" version of Android: https://github.com/Evolution-X/frameworks_base/blob/l10n_tiramisu/services/core/java/com/android/server/wm/ActivityStarter.java