ForgetDeviceDialogFragment check whether device is null or not
Bug: 280687867 Test: build pass Change-Id: I4134569854165f20f6287406d9ed627b2c15c05b
This commit is contained in:
committed by
SongFerng Wang
parent
0741621536
commit
13cd052693
@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
@@ -63,6 +64,13 @@ public class ForgetDeviceDialogFragment extends InstrumentedDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle inState) {
|
public Dialog onCreateDialog(Bundle inState) {
|
||||||
|
Context context = getContext();
|
||||||
|
mDevice = getDevice(context);
|
||||||
|
if (mDevice == null) {
|
||||||
|
Log.e(TAG, "onCreateDialog: Device is null.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
DialogInterface.OnClickListener onConfirm = (dialog, which) -> {
|
DialogInterface.OnClickListener onConfirm = (dialog, which) -> {
|
||||||
mDevice.unpair();
|
mDevice.unpair();
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
@@ -70,9 +78,6 @@ public class ForgetDeviceDialogFragment extends InstrumentedDialogFragment {
|
|||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Context context = getContext();
|
|
||||||
mDevice = getDevice(context);
|
|
||||||
|
|
||||||
AlertDialog dialog = new AlertDialog.Builder(context)
|
AlertDialog dialog = new AlertDialog.Builder(context)
|
||||||
.setPositiveButton(R.string.bluetooth_unpair_dialog_forget_confirm_button,
|
.setPositiveButton(R.string.bluetooth_unpair_dialog_forget_confirm_button,
|
||||||
onConfirm)
|
onConfirm)
|
||||||
|
Reference in New Issue
Block a user