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

Commit 6553ea49 authored by Robert Wu's avatar Robert Wu
Browse files

MIDI: Add null check for UserManager.getMainUser

UserManager.getMainUser() can return null for some devices.
This is causing a NullPointerException in some automotive cases.

This CL adds an additional check to make sure that this is not null.

Bug: 322622902
Test: Connect to jamstick on phone with MIDI+BTLE app.
Test: Verify that MidiScope receives packets successfully.
Change-Id: I5b8e060cd8cafde1b1c60e259cc5ba0516a417d0
parent 0edd8471
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1011,7 +1011,11 @@ public class MidiService extends IMidiManager.Stub {
            }
        }

        if (user.getUserIdentifier() == mUserManager.getMainUser().getIdentifier()) {
        // Allow only the main user to create BluetoothMidiService.
        // If there is no main user, allow all users to create it.
        UserHandle mainUser = mUserManager.getMainUser();
        if ((mainUser == null)
                || (user.getUserIdentifier() == mainUser.getIdentifier())) {
            PackageInfo info;
            try {
                info = mPackageManager.getPackageInfoAsUser(