Skip to content

Commit db1eb10

Browse files
ADFA-5151 fix(clone): a completed receive lands on the Library, not stranded on step 2
A successful clone-receive left the user on the receive screen — the transfer was done but nothing moved them on. The install index has always redirected home on success; the receive did not. showReceiveTerminal now, on success, confirms briefly on the progress screen ("Copy complete", 100%, no Cancel) and after 3s goes to the Library tab, where LibraryHomeFragment refreshes onto the system releaseCloneEnv just booted. A receiveExiting flag holds the confirmation so onTransferState's renderReceive (SUCCESS is not active) can't tear it down first. Failure keeps the existing dialog. It lives in the shared terminal, so a normal receive gets the same exit. openLibraryTab mirrors openCloneTab. This is the success exit ADFA-5151's loop needs before the confinement can be added safely — the door before the walls.
1 parent 6e0ecb5 commit db1eb10

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ private enum Stage { JOIN, START }
8484
private boolean cloneGuardHeld = false; // ADFA-4956: a receive (destructive write) also set InstallGuard
8585
private boolean shareAnyway = false; // ADFA-4786: user chose to share even with no library installed
8686
private boolean systemPresent = true; // ADFA-5150: Send needs a system to send; refreshed on entry / onResume
87+
private boolean receiveExiting = false; // ADFA-5151: success confirmation is showing; hold it, then go to Library
88+
private static final long RECEIVE_SUCCESS_REDIRECT_MS = 3000L; // ADFA-5151: like the install index's REDIRECT_MS
8789
// ADFA-4785: "Send the app" sub-screen (bootstrap a phone with no K2Go) — serves the APK over HTTP.
8890
private boolean sendApp = false;
8991
private ApkServer apkServer;
@@ -863,7 +865,9 @@ private void onTransferState(SyncTransferState st) {
863865
if (st.phase == SyncTransferState.Phase.SUCCESS) { lastSeq = st.seq; showReceiveTerminal(true, st.message); }
864866
else if (st.phase == SyncTransferState.Phase.FAILED || st.phase == SyncTransferState.Phase.ABORTED) { lastSeq = st.seq; showReceiveTerminal(false, st.message); }
865867
}
866-
if (side == Side.RECEIVE) renderReceive();
868+
// ADFA-5151: while the success confirmation is holding before the redirect to Library, don't let
869+
// renderReceive() tear the progress screen down (SUCCESS is not active, so it would).
870+
if (side == Side.RECEIVE && !receiveExiting) renderReceive();
867871
syncProtection(); // ADFA-4782: match protection to the live pull state on every transition
868872
}
869873

@@ -1088,14 +1092,37 @@ private void showReceiveTerminal(boolean ok, String message) {
10881092
}
10891093
releaseCloneEnv(); // ADFA-4956: boot the (possibly replaced) system, end guard, drop the lock
10901094
syncVm.releaseNetwork();
1095+
1096+
if (ok) {
1097+
// ADFA-5151: success exit. Do not strand the user on the receive step — confirm briefly on
1098+
// the progress screen, then go to the Library, exactly as the install index does. A system
1099+
// now exists (releaseCloneEnv booted it), so LibraryHomeFragment refreshes onto it. Shared
1100+
// terminal, so a normal receive (with a system) gets the same courtesy.
1101+
receiveExiting = true;
1102+
if (progressBox != null) progressBox.setVisibility(View.VISIBLE);
1103+
setBarIndeterminate(false);
1104+
if (pbar != null) pbar.setProgressCompat(100, true);
1105+
if (pStatus != null) pStatus.setText(getString(R.string.k2go_clone_copy_complete));
1106+
if (pFile != null) pFile.setText("");
1107+
if (pStats != null) pStats.setText("");
1108+
if (cancel != null) cancel.setVisibility(View.GONE); // nothing to cancel on a finished copy
1109+
View host = (progressBox != null) ? progressBox : getView();
1110+
if (host != null) host.postDelayed(() -> {
1111+
if (!isAdded()) return;
1112+
SyncProgressRepository.get().postIdle();
1113+
if (getActivity() instanceof LibraryActivity) ((LibraryActivity) getActivity()).openLibraryTab();
1114+
}, RECEIVE_SUCCESS_REDIRECT_MS);
1115+
return;
1116+
}
1117+
10911118
String body = (message != null) ? message : "";
10921119
// ADFA-4782: if rsync was SIGKILLed (exit 137, phantom-process killer), guide the user.
1093-
if (!ok && body.contains("137")) {
1120+
if (body.contains("137")) {
10941121
body += "\n\nThe copy was stopped by the system. Keep this screen on and the app in the "
10951122
+ "foreground during a transfer, then scan again to resume.";
10961123
}
10971124
new MaterialAlertDialogBuilder(requireContext())
1098-
.setTitle(getString(ok ? R.string.k2go_clone_copy_complete : R.string.k2go_clone_copy_stopped))
1125+
.setTitle(getString(R.string.k2go_clone_copy_stopped))
10991126
.setMessage(body)
11001127
.setPositiveButton(getString(android.R.string.ok), (d, w) -> { SyncProgressRepository.get().postIdle(); renderReceive(); })
11011128
.setCancelable(false)

‎controller/app/src/main/java/org/iiab/controller/redesign/LibraryActivity.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,15 @@ public void openCloneTab() {
10451045
syncSelection(currentTab);
10461046
}
10471047

1048+
/** ADFA-5151: land on Home/Library — the success exit of a clone-receive (a system now exists),
1049+
* mirroring the install index's goHome. The server was booted by CloneFragment.releaseCloneEnv,
1050+
* so LibraryHomeFragment refreshes onto the new system. */
1051+
public void openLibraryTab() {
1052+
currentTab = R.id.nav_library;
1053+
showTab(currentTab);
1054+
syncSelection(currentTab);
1055+
}
1056+
10481057
/** ADFA-4837: header "Couldn't start — tap to retry" action. Safe no-op unless truly idle. */
10491058
public void startServer() {
10501059
if (!canStartServer()) return;

0 commit comments

Comments
 (0)