fix(kiosk): warn user to press 'Done' not 'Open' after gateway install
- Before launching system installer (ACTION_VIEW fallback), show a non-cancellable dialog warning: press Fine, NOT Apri - After installer returns, force SetupActivity back to foreground in case user pressed Open anyway (FLAG_ACTIVITY_REORDER_TO_FRONT)
This commit is contained in:
@@ -1112,8 +1112,14 @@ class SetupActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
INSTALL_FALLBACK_REQUEST -> {
|
INSTALL_FALLBACK_REQUEST -> {
|
||||||
// System package installer returned — check if the package is now installed
|
// System package installer returned — check if the package is now installed.
|
||||||
|
// Whether the user pressed "Done" or "Open", bring setup back to foreground.
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
// Bring this activity back to front in case user pressed "Open"
|
||||||
|
val bringFront = Intent(this, SetupActivity::class.java).apply {
|
||||||
|
flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
|
||||||
|
}
|
||||||
|
startActivity(bringFront)
|
||||||
val installed = try { packageManager.getPackageInfo(pendingInstallPkg, 0); true } catch (_: Exception) { false }
|
val installed = try { packageManager.getPackageInfo(pendingInstallPkg, 0); true } catch (_: Exception) { false }
|
||||||
if (installed) {
|
if (installed) {
|
||||||
setGatewayUI("✅", getString(R.string.install_success),
|
setGatewayUI("✅", getString(R.string.install_success),
|
||||||
@@ -1138,11 +1144,25 @@ class SetupActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
pendingInstallFile = file
|
pendingInstallFile = file
|
||||||
pendingInstallPkg = targetPkg
|
pendingInstallPkg = targetPkg
|
||||||
setGatewayUI("⏳", getString(R.string.install_installing),
|
|
||||||
"Conferma l'installazione nella finestra di sistema...",
|
// Warn user: after installation Android shows "Open" and "Done" buttons.
|
||||||
0xFF94a3b8.toInt(), btnEnabled = false, progress = -1)
|
// Opening the gateway app directly would leave the kiosk in the background.
|
||||||
@Suppress("DEPRECATION")
|
AlertDialog.Builder(this)
|
||||||
startActivityForResult(intent, INSTALL_FALLBACK_REQUEST)
|
.setTitle("📦 Installazione in corso")
|
||||||
|
.setMessage(
|
||||||
|
"Quando Android mostra la schermata di installazione completata:\n\n" +
|
||||||
|
"✅ Premi \"Fine\" per tornare al setup\n" +
|
||||||
|
"⛔ NON premere \"Apri\" — l'app potrebbe non funzionare correttamente se aperta direttamente"
|
||||||
|
)
|
||||||
|
.setPositiveButton("Ho capito, procedi") { _, _ ->
|
||||||
|
setGatewayUI("⏳", getString(R.string.install_installing),
|
||||||
|
"Conferma l'installazione nella finestra di sistema...",
|
||||||
|
0xFF94a3b8.toInt(), btnEnabled = false, progress = -1)
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
startActivityForResult(intent, INSTALL_FALLBACK_REQUEST)
|
||||||
|
}
|
||||||
|
.setCancelable(false)
|
||||||
|
.show()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
val deviceLabel = buildDeviceLabel()
|
val deviceLabel = buildDeviceLabel()
|
||||||
val diagInfo = buildString {
|
val diagInfo = buildString {
|
||||||
|
|||||||
Reference in New Issue
Block a user