Fix potential NPE in BluetoothPairingDialog#onDestroy
am: 56c1b61e79
Change-Id: Idade2f767cf72fc4b6f6c8149020f1e29d82bc56
This commit is contained in:
@@ -67,7 +67,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
private EditText mPairingView;
|
private EditText mPairingView;
|
||||||
private Button mOkButton;
|
private Button mOkButton;
|
||||||
private LocalBluetoothProfile mPbapClientProfile;
|
private LocalBluetoothProfile mPbapClientProfile;
|
||||||
|
private boolean mReceiverRegistered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dismiss the dialog if the bond state changes to bonded or none,
|
* Dismiss the dialog if the bond state changes to bonded or none,
|
||||||
@@ -98,8 +98,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (!intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST))
|
if (!intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
|
||||||
{
|
|
||||||
Log.e(TAG, "Error: this activity may be started only with intent " +
|
Log.e(TAG, "Error: this activity may be started only with intent " +
|
||||||
BluetoothDevice.ACTION_PAIRING_REQUEST);
|
BluetoothDevice.ACTION_PAIRING_REQUEST);
|
||||||
finish();
|
finish();
|
||||||
@@ -167,6 +166,7 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
*/
|
*/
|
||||||
registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_PAIRING_CANCEL));
|
registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_PAIRING_CANCEL));
|
||||||
registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
|
registerReceiver(mReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
|
||||||
|
mReceiverRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUserEntryDialog() {
|
private void createUserEntryDialog() {
|
||||||
@@ -373,8 +373,11 @@ public final class BluetoothPairingDialog extends AlertActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if (mReceiverRegistered) {
|
||||||
|
mReceiverRegistered = false;
|
||||||
unregisterReceiver(mReceiver);
|
unregisterReceiver(mReceiver);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
if (mOkButton != null) {
|
if (mOkButton != null) {
|
||||||
|
Reference in New Issue
Block a user