Remove workaround for Android issue #190966.

This commit is contained in:
akwizgran
2021-04-08 17:03:28 +01:00
parent 0ee4ade404
commit fe1c6acebb
3 changed files with 1 additions and 36 deletions

View File

@@ -81,18 +81,6 @@ public class AddNearbyContactActivity extends BriarActivity
.observe(this, this::onAddContactStateChanged); .observe(this, this::onAddContactStateChanged);
} }
@Override
protected void onPostResume() {
super.onPostResume();
viewModel.setIsActivityResumed(true);
}
@Override
protected void onPause() {
super.onPause();
viewModel.setIsActivityResumed(false);
}
private void onBluetoothDiscoverableResult(boolean discoverable) { private void onBluetoothDiscoverableResult(boolean discoverable) {
if (discoverable) { if (discoverable) {
LOG.info("Bluetooth discoverability was accepted"); LOG.info("Bluetooth discoverability was accepted");

View File

@@ -182,12 +182,6 @@ class AddNearbyContactPermissionManager {
locationPermission = Permission.PERMANENTLY_DENIED; locationPermission = Permission.PERMANENTLY_DENIED;
} }
} }
// If a permission dialog has been shown, showing the QR code fragment
// on this call path would cause a crash due to
// https://code.google.com/p/android/issues/detail?id=190966.
// In that case the isResumed flag prevents the fragment from being
// shown here, and showQrCodeFragmentIfAllowed() will be called again
// from onPostResume().
if (checkPermissions()) onPermissionsGranted.run(); if (checkPermissions()) onPermissionsGranted.run();
} }

View File

@@ -156,7 +156,6 @@ class AddNearbyContactViewModel extends AndroidViewModel
private BluetoothDecision bluetoothDecision = BluetoothDecision.UNKNOWN; private BluetoothDecision bluetoothDecision = BluetoothDecision.UNKNOWN;
private boolean wasContinueClicked = false; private boolean wasContinueClicked = false;
private boolean isActivityResumed = false;
/** /**
* Records whether we've enabled the wifi plugin so we don't enable it more * Records whether we've enabled the wifi plugin so we don't enable it more
@@ -369,8 +368,7 @@ class AddNearbyContactViewModel extends AndroidViewModel
boolean permissionsGranted = areEssentialPermissionsGranted( boolean permissionsGranted = areEssentialPermissionsGranted(
getApplication(), isBluetoothSupported()); getApplication(), isBluetoothSupported());
boolean locationEnabled = isLocationEnabled(getApplication()); boolean locationEnabled = isLocationEnabled(getApplication());
if (isActivityResumed && wasContinueClicked && permissionsGranted && if (wasContinueClicked && permissionsGranted && locationEnabled) {
locationEnabled) {
if (isWifiReady() && isBluetoothReady()) { if (isWifiReady() && isBluetoothReady()) {
LOG.info("Wifi and Bluetooth are ready"); LOG.info("Wifi and Bluetooth are ready");
startAddingContact(); startAddingContact();
@@ -489,21 +487,6 @@ class AddNearbyContactViewModel extends AndroidViewModel
} }
} }
/**
* Set to true in onPostResume() and false in onPause(). This prevents the
* QR code fragment from being shown if onRequestPermissionsResult() is
* called while the activity is paused, which could cause a crash due to
* https://issuetracker.google.com/issues/37067655.
* TODO check if this is still happening with new permission requesting
*/
@UiThread
void setIsActivityResumed(boolean resumed) {
isActivityResumed = resumed;
// Workaround for
// https://code.google.com/p/android/issues/detail?id=190966
showQrCodeFragmentIfAllowed();
}
@UiThread @UiThread
void setBluetoothDecision(BluetoothDecision decision) { void setBluetoothDecision(BluetoothDecision decision) {
bluetoothDecision = decision; bluetoothDecision = decision;