tls-psk: show error message for unspecialized io exception
This commit is contained in:
@@ -78,7 +78,8 @@ public class KeyTransferInteractor {
|
||||
private static final int CONNECTION_RECEIVE_OK = 4;
|
||||
private static final int CONNECTION_LOST = 5;
|
||||
private static final int CONNECTION_ERROR_CONNECT = 6;
|
||||
private static final int CONNECTION_ERROR_LISTEN = 7;
|
||||
private static final int CONNECTION_ERROR_WHILE_CONNECTED = 7;
|
||||
private static final int CONNECTION_ERROR_LISTEN = 8;
|
||||
|
||||
private static final String QRCODE_URI_FORMAT = "PGP+TRANSFER://%s@%s:%s";
|
||||
private static final int TIMEOUT_RECEIVING = 2000;
|
||||
@@ -174,7 +175,8 @@ public class KeyTransferInteractor {
|
||||
Log.d(Constants.TAG, "ssl handshake error!", e);
|
||||
invokeListener(CONNECTION_ERROR_CONNECT, null);
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "error!", e);
|
||||
Log.e(Constants.TAG, "communication error!", e);
|
||||
invokeListener(CONNECTION_ERROR_WHILE_CONNECTED, e.getLocalizedMessage());
|
||||
}
|
||||
} finally {
|
||||
closeQuietly(socket);
|
||||
@@ -338,6 +340,9 @@ public class KeyTransferInteractor {
|
||||
case CONNECTION_LOST:
|
||||
callback.onConnectionLost();
|
||||
break;
|
||||
case CONNECTION_ERROR_WHILE_CONNECTED:
|
||||
callback.onConnectionError(arg);
|
||||
break;
|
||||
case CONNECTION_ERROR_CONNECT:
|
||||
callback.onConnectionErrorConnect();
|
||||
break;
|
||||
@@ -392,6 +397,7 @@ public class KeyTransferInteractor {
|
||||
|
||||
void onConnectionErrorConnect();
|
||||
void onConnectionErrorListen();
|
||||
void onConnectionError(String arg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,9 +419,11 @@ public class KeyTransferInteractor {
|
||||
}
|
||||
String sAddr = addr.getHostAddress();
|
||||
boolean isIPv4 = sAddr.indexOf(':') < 0;
|
||||
if (isIPv4 && useIPv4) {
|
||||
if (useIPv4) {
|
||||
if (isIPv4) {
|
||||
return sAddr;
|
||||
} else if (!isIPv4) {
|
||||
}
|
||||
} else {
|
||||
int delimIndex = sAddr.indexOf('%'); // drop ip6 zone suffix
|
||||
if (delimIndex >= 0) {
|
||||
sAddr = sAddr.substring(0, delimIndex);
|
||||
|
||||
@@ -276,6 +276,16 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
||||
view.showErrorListenFailed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionError(String errorMessage) {
|
||||
view.showErrorConnectionError(errorMessage);
|
||||
|
||||
connectionClear();
|
||||
if (wasConnected) {
|
||||
view.showViewDisconnected();
|
||||
secretKeyAdapter.setAllDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void connectionStartConnect(String qrCodeContent) {
|
||||
connectionClear();
|
||||
@@ -367,6 +377,7 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
||||
void showErrorBadKey();
|
||||
void showErrorConnectionFailed();
|
||||
void showErrorListenFailed();
|
||||
void showErrorConnectionError(String errorMessage);
|
||||
void showResultNotification(ImportKeyResult result);
|
||||
|
||||
void setSecretKeyAdapter(Adapter adapter);
|
||||
|
||||
@@ -255,6 +255,16 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
||||
Notify.create(getActivity(), R.string.transfer_error_listen, Style.ERROR).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showErrorConnectionError(String errorMessage) {
|
||||
if (errorMessage != null) {
|
||||
String text = getString(R.string.transfer_error_generic_msg, errorMessage);
|
||||
Notify.create(getActivity(), text, Style.ERROR).show();
|
||||
} else {
|
||||
Notify.create(getActivity(), R.string.transfer_error_generic, Style.ERROR).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showResultNotification(ImportKeyResult result) {
|
||||
result.createNotify(getActivity()).show();
|
||||
|
||||
@@ -1901,6 +1901,8 @@
|
||||
<string name="transfer_error_read_incoming">"Failed reading incoming key!"</string>
|
||||
<string name="transfer_error_connect">"Connection failed!"</string>
|
||||
<string name="transfer_error_listen">"Error waiting for connection!"</string>
|
||||
<string name="transfer_error_generic">"Unknown communication error!"</string>
|
||||
<string name="transfer_error_generic_msg">"Communication error: %s"</string>
|
||||
<string name="transfer_not_available">"Sorry, this feature can only be used on Android 5 or newer :("</string>
|
||||
<string name="transfer_list_empty">No keys on this device that could be sent. Waiting for incoming keys…</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user