Improve UI/UX around device transfer.

This commit is contained in:
Cody Henthorne
2021-03-16 10:18:02 -04:00
committed by GitHub
parent ace85df9b7
commit 490944a02a
24 changed files with 394 additions and 168 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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);

View File

@@ -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);

View File

@@ -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
}
}