Merge "Fix null pointer exception if USBPort is removed" am: 066cd28370 am: fd5364769f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1308901 Change-Id: Ia64a294b4059dfd76b67446a8153d2b41bf75d0b
This commit is contained in:
@@ -837,11 +837,13 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
boolean prevHostConnected = mHostConnected;
|
boolean prevHostConnected = mHostConnected;
|
||||||
UsbPort port = (UsbPort) args.arg1;
|
UsbPort port = (UsbPort) args.arg1;
|
||||||
UsbPortStatus status = (UsbPortStatus) args.arg2;
|
UsbPortStatus status = (UsbPortStatus) args.arg2;
|
||||||
|
|
||||||
|
if (status != null) {
|
||||||
mHostConnected = status.getCurrentDataRole() == DATA_ROLE_HOST;
|
mHostConnected = status.getCurrentDataRole() == DATA_ROLE_HOST;
|
||||||
mSourcePower = status.getCurrentPowerRole() == POWER_ROLE_SOURCE;
|
mSourcePower = status.getCurrentPowerRole() == POWER_ROLE_SOURCE;
|
||||||
mSinkPower = status.getCurrentPowerRole() == POWER_ROLE_SINK;
|
mSinkPower = status.getCurrentPowerRole() == POWER_ROLE_SINK;
|
||||||
mAudioAccessoryConnected = (status.getCurrentMode() == MODE_AUDIO_ACCESSORY);
|
mAudioAccessoryConnected = (status.getCurrentMode() == MODE_AUDIO_ACCESSORY);
|
||||||
mAudioAccessorySupported = port.isModeSupported(MODE_AUDIO_ACCESSORY);
|
|
||||||
// Ideally we want to see if PR_SWAP and DR_SWAP is supported.
|
// Ideally we want to see if PR_SWAP and DR_SWAP is supported.
|
||||||
// But, this should be suffice, since, all four combinations are only supported
|
// But, this should be suffice, since, all four combinations are only supported
|
||||||
// when PR_SWAP and DR_SWAP are supported.
|
// when PR_SWAP and DR_SWAP are supported.
|
||||||
@@ -851,6 +853,15 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
&& status.isRoleCombinationSupported(POWER_ROLE_SOURCE,
|
&& status.isRoleCombinationSupported(POWER_ROLE_SOURCE,
|
||||||
DATA_ROLE_DEVICE)
|
DATA_ROLE_DEVICE)
|
||||||
&& status.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE);
|
&& status.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE);
|
||||||
|
} else {
|
||||||
|
mHostConnected = false;
|
||||||
|
mSourcePower = false;
|
||||||
|
mSinkPower = false;
|
||||||
|
mAudioAccessoryConnected = false;
|
||||||
|
mSupportsAllCombinations = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAudioAccessorySupported = port.isModeSupported(MODE_AUDIO_ACCESSORY);
|
||||||
|
|
||||||
args.recycle();
|
args.recycle();
|
||||||
updateUsbNotification(false);
|
updateUsbNotification(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user