Merge "Crash when scanning WiFi QR code" am: 6c31283455 am: 7950a0acaf

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2020675

Change-Id: I8e31258422049429a0059159e47930c500f41ecd
This commit is contained in:
Treehugger Robot
2022-03-16 15:53:31 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 1 deletions

View File

@@ -168,10 +168,18 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
break;
case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
final Context context = getContext();
if (context == null) {
// Context may be null if the message is received after the Activity has
// been destroyed
Log.d(TAG, "Scan success but context is null");
return;
}
// We may get 2 WifiConfiguration if the QR code has no password in it,
// one for open network and one for enhanced open network.
final WifiManager wifiManager =
getContext().getSystemService(WifiManager.class);
context.getSystemService(WifiManager.class);
final WifiNetworkConfig qrCodeWifiNetworkConfig =
(WifiNetworkConfig)msg.obj;
final List<WifiConfiguration> qrCodeWifiConfigurations =

View File

@@ -124,6 +124,7 @@ public class QrCamera extends Handler {
}
if (mCamera != null) {
mCamera.stopPreview();
releaseCamera();
}
}