From acb7b31bff812eb325e318620c4e1cc443358688 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsuda Date: Fri, 7 Aug 2015 17:49:54 +0900 Subject: [PATCH] Handle the case where null is returned for USB_STATE intent. USB_STATE is not received if USB_STATE has not changed from the initial state. This CL adds handling for that case. BUG: 22163689 Change-Id: I232a558caaac4f4984f7629e2574d478fc7ad432 --- src/com/android/settings/deviceinfo/UsbBackend.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/deviceinfo/UsbBackend.java b/src/com/android/settings/deviceinfo/UsbBackend.java index c44f2eb6641..3327ea6e939 100644 --- a/src/com/android/settings/deviceinfo/UsbBackend.java +++ b/src/com/android/settings/deviceinfo/UsbBackend.java @@ -47,7 +47,8 @@ public class UsbBackend { public UsbBackend(Context context) { Intent intent = context.registerReceiver(null, new IntentFilter(UsbManager.ACTION_USB_STATE)); - mIsUnlocked = intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false); + mIsUnlocked = intent == null ? + false : intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false); mUserManager = UserManager.get(context); mUsbManager = context.getSystemService(UsbManager.class); @@ -151,4 +152,4 @@ public class UsbBackend { // No port, support sink modes only. return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE; } -} \ No newline at end of file +}