Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c185ae1c authored by Lee Shombert's avatar Lee Shombert
Browse files

Fix a crash during mock testing

Bug: 249161784

This fixes a crash during mock testing of the broadcast queue when
BOOT_COMPLETED broadcasts are simulated.  The umInternal variable is
null, and umInternal.getUserInfo() throws a null pointer
exception. The change avoids dereferencing umInternal if it is null.

This was tested with a draft version of the broadcast replay code; it
was verified that BOOT_COMPLETED did not generate an NPE.

Test: atest
 * FrameworksMockingServicesTests:BroadcastQueueTest
Change-Id: I31f57f1dcb7f2ed9f02558f841e18958e8097373
parent 281eb31f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1488,7 +1488,8 @@ public class BroadcastQueueImpl extends BroadcastQueue {
            // LocalServices.getService() here.
            final UserManagerInternal umInternal = LocalServices.getService(
                    UserManagerInternal.class);
            final UserInfo userInfo = umInternal.getUserInfo(r.userId);
            final UserInfo userInfo =
                    (umInternal != null) ? umInternal.getUserInfo(r.userId) : null;
            if (userInfo != null) {
                userType = UserManager.getUserTypeForStatsd(userInfo.userType);
            }