Buggy code:
final class RemoteDevices { private static final boolean DBG = false ; private static final String TAG = "BluetoothRemoteDevices" ; private static BluetoothAdapter mAdapter ; private static AdapterService mAdapterService ; private static ArrayList < BluetoothDevice > mSdpTracker ; private static ArrayList < BluetoothDevice > mSdpMasTracker ; private WakeLock mWakeLock ; private Object mObject = new Object ( ) ; private static final int UUID_INTENT_DELAY = 6000 ; private static final int MESSAGE_UUID_INTENT = 1 ; private static final int MAS_INSTANCE_INTENT_DELAY = 6000 ; private static final int MESSAGE_MAS_INSTANCE_INTENT = 2 ; private HashMap < BluetoothDevice , RemoteDevices . DeviceProperties > mDevices ; RemoteDevices ( PowerManager pm , AdapterService service ) { } void cleanup ( ) { } @ Override public Object clone ( ) throws CloneNotSupportedException { } RemoteDevices . DeviceProperties getDeviceProperties ( BluetoothDevice device ) { } BluetoothDevice getDevice ( byte [ ] address ) { } RemoteDevices . DeviceProperties addDeviceProperties ( byte [ ] address ) { } class DeviceProperties { private String mName ; private byte [ ] mAddress ; private int mBluetoothClass ; private short mRssi ; private ParcelUuid [ ] mUuids ; private int mDeviceType ; private int retValue ; private String mAlias ; private int mBondState ; private BluetoothRemoteDiRecord mDiRecord ; private boolean mTrustValue ; DeviceProperties ( ) { } String getName ( ) { } int getBluetoothClass ( ) { } ParcelUuid [ ] getUuids ( ) { } byte [ ] getAddress ( ) { } short getRssi ( ) { } int getDeviceType ( ) { } String getAlias ( ) { } void setAlias ( String alias ) { } boolean getTrust ( ) { } void setTrust ( boolean trustVal ) { } void setBondState ( int mBondState ) { } int getBondState ( ) { } BluetoothRemoteDiRecord getRemoteDiRecord ( ) { } void updateRemoteDiRecord ( byte [ ] val ) { } } private void sendUuidIntent ( BluetoothDevice device ) { } private void sendMasInstanceIntent ( BluetoothDevice device , ArrayList < BluetoothMasInstance > instances ) { } private void sendDisplayPinIntent ( byte [ ] address , int pin ) { } void devicePropertyChangedCallback ( byte [ ] address , int [ ] types , byte [ ] [ ] values ) { Intent intent ; byte [ ] val ; int type ; BluetoothDevice bdDevice = getDevice ( address ) ; RemoteDevices . DeviceProperties device ; if ( bdDevice == null ) { device = addDeviceProperties ( address ) ; bdDevice = getDevice ( address ) ; } else { device = getDeviceProperties ( bdDevice ) ; } <START_BUG> for ( int j = 0 ; j < ( types . length ) ; j ++ ) { <END_BUG> type = types [ j ] ; val = values [ j ] ; if ( ( val . length ) <= 0 ) errorLog ( ( ( ( "devicePropertyChangedCallback:<seq2seq4repair_space>bdDevice:<seq2seq4repair_space>" + bdDevice ) + ",<seq2seq4repair_space>value<seq2seq4repair_space>is<seq2seq4repair_space>empty<seq2seq4repair_space>for<seq2seq4repair_space>type:<seq2seq4repair_space>" ) + type ) ) ; else { synchronized ( mObject ) { switch ( type ) { case AbstractionLayer . BT_PROPERTY_BDNAME : device . mName = new String ( val ) ; intent = new Intent ( BluetoothDevice . ACTION_NAME_CHANGED ) ; intent . putExtra ( EXTRA_DEVICE , bdDevice ) ; intent . putExtra ( EXTRA_NAME , device . mName ) ; intent . addFlags ( FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT ) ; RemoteDevices . mAdapterService . sendBroadcast ( intent , RemoteDevices . mAdapterService . BLUETOOTH_PERM ) ; debugLog ( ( "Remote<seq2seq4repair_space>Device<seq2seq4repair_space>name<seq2seq4repair_space>is:<seq2seq4repair_space>" + ( device . mName ) ) ) ; break ; case AbstractionLayer . BT_PROPERTY_REMOTE_FRIENDLY_NAME : device . mAlias = new String ( val ) ; break ; case AbstractionLayer . BT_PROPERTY_BDADDR : device . mAddress = val ; debugLog ( ( "Remote<seq2seq4repair_space>Address<seq2seq4repair_space>is:" + ( Utils . getAddressStringFromByte ( val ) ) ) ) ; break ; case AbstractionLayer . BT_PROPERTY_CLASS_OF_DEVICE : device . mBluetoothClass = Utils . byteArrayToInt ( val ) ; intent = new Intent ( BluetoothDevice . ACTION_CLASS_CHANGED ) ; intent . putExtra ( EXTRA_DEVICE , bdDevice ) ; intent . putExtra ( EXTRA_CLASS , new BluetoothClass ( device . mBluetoothClass ) ) ; intent . addFlags ( FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT ) ; RemoteDevices . mAdapterService . sendBroadcast ( intent , RemoteDevices . mAdapterService . BLUETOOTH_PERM ) ; debugLog ( ( "Remote<seq2seq4repair_space>class<seq2seq4repair_space>is:" + ( device . mBluetoothClass ) ) ) ; break ; case AbstractionLayer . BT_PROPERTY_UUIDS : int numUuids = ( val . length ) // ( AbstractionLayer . BT_UUID_SIZE ) ; device . mUuids = Utils . byteArrayToUuid ( val ) ; sendUuidIntent ( bdDevice ) ; break ; case AbstractionLayer . BT_PROPERTY_TYPE_OF_DEVICE : device . mDeviceType = Utils . byteArrayToInt ( val ) ; break ; case AbstractionLayer . BT_PROPERTY_REMOTE_TRUST_VALUE : device . retValue = Utils . byteArrayToInt ( val ) ; if ( ( device . retValue ) == 1 ) device . mTrustValue = true ; else device . mTrustValue = false ; break ; case AbstractionLayer . BT_PROPERTY_REMOTE_RSSI : device . mRssi = val [ 0 ] ; break ; case AbstractionLayer . BT_PROPERTY_REMOTE_DI_RECORD : device . updateRemoteDiRecord ( val ) ; break ; } } } } } void deviceFoundCallback ( byte [ ] address ) { } void pinRequestCallback ( byte [ ] address , byte [ ] name , int cod , boolean secure ) { } void sspRequestCallback ( byte [ ] address , byte [ ] name , int cod , int pairingVariant , int passkey ) { } void aclStateChangeCallback ( int status , byte [ ] address , int newState ) { } void deviceMasInstancesFoundCallback ( int status , byte [ ] address , String [ ] name , int [ ] scn , int [ ] id , int [ ] msgtype ) { } void fetchUuids ( BluetoothDevice device ) { } void fetchMasInstances ( BluetoothDevice device ) { } private final Handler mHandler = new Handler ( ) { @ Override public void handleMessage ( Message msg ) { } } ;

Fix:
for ( int j = 0 ; ( j < ( types . length ) ) && ( device != null ) ; j ++ ) {