MIDI: Check MIDI permission before parsing XML

MidiService is parsing the XML of installed packages.
This is relatively expensive.

This CL changes it so permissions and flags are checked first.

This CL also adds additional null checks.

Bug: 315203699
Test: atest MidiEchoTest
Change-Id: I57e332f2afdcc54cc67986b8a8b2941ee1899c26
1 file changed