base-manager: avoid events of USB interface from removing MMDevice

When a USB modem is switching its USB configuration, udev may deliver
the remove events of USB interfaces associated with the old USB
configuration and the add events of USB interfaces associated with the new USB
configuration in an interleaved fashion. An interleaved remove event of USB
interface could trigger the special case handling code in
mm-base-manager.c:device_removed() and incorrectly remove a MMDevice under
probing.

See https://lists.freedesktop.org/archives/modemmanager-devel/2017-August/005626.html
for more details.

This patch adds a check to ensure that only remove events of USB
device (i.e. not interface) can trigger the special handling code.

(cherry picked from commit 76c1a1119cdb08c710b5f8df35c31883a466a64a)

BUG=chromium:756336
TEST=Tested the following:
1. Power cycle the Huawei ME936 modem on nyan_blaze.
2. Verify that ModemManager successfully initializes the modem.
3. Repeat step 1 and 2.

Change-Id: I912af5c0e57eccd98d0f60ad9bc396f156f5486e
Reviewed-on: https://chromium-review.googlesource.com/627091
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
1 file changed