Check null of pidPair instead of pidPair.first which caused a nullpointer exception. clean local variables after sending out STATE_OFF intent. Check bluetooth state in removeServiceRecord. bug 5330367 Change-Id: Ib0af8143223bea48d3f587cca18544c4aef29980