Explicity receive sticky usb intent

Sticky intents are both returned by onReceive
and broadcast to the receiver. In some cases
though, the receiver could be unregistered
so quickly that it has no time to receive
it. When this happens the screen is not
refreshed, so explicity handle the intent
to ensure a refresh.

Fixes: 74255559
Test: screen refreshed property in multi-window
Change-Id: I2480dc35e28f98561ffed4b557f4bdaf83a73e9c
This commit is contained in:
Jerry Zhang
2018-03-28 16:50:46 -07:00
parent 05ab467e80
commit 0fa350eeaf

View File

@@ -98,7 +98,11 @@ public class UsbConnectionBroadcastReceiver extends BroadcastReceiver implements
final IntentFilter intentFilter = new IntentFilter(); final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(UsbManager.ACTION_USB_STATE); intentFilter.addAction(UsbManager.ACTION_USB_STATE);
intentFilter.addAction(UsbManager.ACTION_USB_PORT_CHANGED); intentFilter.addAction(UsbManager.ACTION_USB_PORT_CHANGED);
mContext.registerReceiver(this, intentFilter); final Intent intent = mContext.registerReceiver(this, intentFilter);
// TODO b/77240599 use an api instead of sticky intent
if (intent != null) {
onReceive(mContext, intent);
}
mListeningToUsbEvents = true; mListeningToUsbEvents = true;
} }
} }