mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 22:25:46 +01:00
Improve UI/UX around device transfer.
This commit is contained in:
@@ -181,6 +181,7 @@ final class DeviceTransferClient implements Handler.Callback {
|
||||
update(TransferStatus.networkConnected());
|
||||
break;
|
||||
case NetworkClientThread.NETWORK_CLIENT_STOPPED:
|
||||
update(TransferStatus.shutdown());
|
||||
internalShutdown();
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -146,6 +146,7 @@ final class DeviceTransferServer implements Handler.Callback {
|
||||
startWifiDirect(message.arg1);
|
||||
break;
|
||||
case NetworkServerThread.NETWORK_SERVER_STOPPED:
|
||||
update(TransferStatus.shutdown());
|
||||
internalShutdown();
|
||||
break;
|
||||
case NetworkServerThread.NETWORK_CLIENT_CONNECTED:
|
||||
|
||||
@@ -92,8 +92,18 @@ final class NetworkClientThread extends Thread {
|
||||
Log.i(TAG, "Waiting for user to verify sas");
|
||||
awaitAuthenticationCodeVerification();
|
||||
Log.d(TAG, "Waiting for server to tell us they also verified");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
inputStream.read();
|
||||
outputStream.write(0x43);
|
||||
outputStream.flush();
|
||||
try {
|
||||
int result = inputStream.read();
|
||||
if (result == -1) {
|
||||
Log.w(TAG, "Something happened waiting for server to verify");
|
||||
throw new DeviceTransferAuthentication.DeviceTransferAuthenticationException("server disconnected while we waited");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Something happened waiting for server to verify", e);
|
||||
throw new DeviceTransferAuthentication.DeviceTransferAuthenticationException(e);
|
||||
}
|
||||
|
||||
handler.sendEmptyMessage(NETWORK_CLIENT_CONNECTED);
|
||||
clientTask.run(context, outputStream);
|
||||
|
||||
@@ -73,10 +73,21 @@ final class NetworkServerThread extends Thread {
|
||||
|
||||
Log.i(TAG, "Waiting for user to verify sas");
|
||||
awaitAuthenticationCodeVerification();
|
||||
|
||||
handler.sendEmptyMessage(NETWORK_CLIENT_CONNECTED);
|
||||
Log.d(TAG, "Waiting for client to tell us they also verified");
|
||||
outputStream.write(0x43);
|
||||
outputStream.flush();
|
||||
try {
|
||||
int result = inputStream.read();
|
||||
if (result == -1) {
|
||||
Log.w(TAG, "Something happened waiting for client to verify");
|
||||
throw new DeviceTransferAuthentication.DeviceTransferAuthenticationException("client disconnected while we waited");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "Something happened waiting for client to verify", e);
|
||||
throw new DeviceTransferAuthentication.DeviceTransferAuthenticationException(e);
|
||||
}
|
||||
|
||||
handler.sendEmptyMessage(NETWORK_CLIENT_CONNECTED);
|
||||
serverTask.run(context, inputStream);
|
||||
|
||||
outputStream.write(0x53);
|
||||
|
||||
@@ -59,6 +59,10 @@ public class TransferStatus {
|
||||
return new TransferStatus(TransferMode.UNAVAILABLE);
|
||||
}
|
||||
|
||||
public static @NonNull TransferStatus shutdown() {
|
||||
return new TransferStatus(TransferMode.SHUTDOWN);
|
||||
}
|
||||
|
||||
public static @NonNull TransferStatus failed() {
|
||||
return new TransferStatus(TransferMode.FAILED);
|
||||
}
|
||||
@@ -72,6 +76,7 @@ public class TransferStatus {
|
||||
NETWORK_CONNECTED,
|
||||
VERIFICATION_REQUIRED,
|
||||
SERVICE_CONNECTED,
|
||||
SERVICE_DISCONNECTED
|
||||
SERVICE_DISCONNECTED,
|
||||
SHUTDOWN
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user