From 8d6ec6f49a3fda21bd6d04ab6c4130a8bc8320ae Mon Sep 17 00:00:00 2001 From: oxmc <67136658+oxmc@users.noreply.github.com> Date: Tue, 16 Jun 2026 20:14:35 -0700 Subject: [PATCH] ProvisioningService: unify setup state into single coherent method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace separate configureDeviceProvisioned() and configureSetupWizard() with configureSetupState() that treats them as one decision: - wizard enabled → provisioning flow owned by wizard; don't touch USER_SETUP_COMPLETE or DEVICE_PROVISIONED, don't disable any wizard package; device_provisioned key is ignored (irrelevant when wizard runs) - wizard disabled → force DEVICE_PROVISIONED from device_provisioned config and disable all wizard packages --- .../ProvisioningService.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/dev/oxmc/configprovisioner/ProvisioningService.java b/src/dev/oxmc/configprovisioner/ProvisioningService.java index 8c3179c..84ff0f1 100644 --- a/src/dev/oxmc/configprovisioner/ProvisioningService.java +++ b/src/dev/oxmc/configprovisioner/ProvisioningService.java @@ -71,8 +71,7 @@ public class ProvisioningService extends Service { applyConfigApkSettings(); applyApns(); } - configureDeviceProvisioned(); - configureSetupWizard(); + configureSetupState(); return true; } @@ -385,22 +384,27 @@ public class ProvisioningService extends Service { // Setup wizard configuration // ------------------------------------------------------------------------- - private void configureDeviceProvisioned() { - boolean provisioned = VendorConfig.isDeviceProvisioned(); - Log.i(TAG, "Device provisioned: " + provisioned); - try { - int v = provisioned ? 1 : 0; - Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, v); - Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, v); - } catch (Exception e) { - Log.w(TAG, "Failed to set device provisioned state", e); - } - } + private void configureSetupState() { + boolean wizardEnabled = VendorConfig.isSetupWizardEnabled(); + boolean deviceProvisioned = VendorConfig.isDeviceProvisioned(); + Log.i(TAG, "configureSetupState: wizard=" + wizardEnabled + " device_provisioned=" + deviceProvisioned); - private void configureSetupWizard() { - boolean enable = VendorConfig.isSetupWizardEnabled(); - Log.i(TAG, "Setup wizard: " + (enable ? "ENABLED" : "DISABLED")); - if (!enable) { + if (wizardEnabled) { + // Wizard owns the provisioning flow. Don't touch USER_SETUP_COMPLETE or + // DEVICE_PROVISIONED — the wizard sets them on completion. Also don't + // disable any wizard package; device_provisioned is irrelevant here. + Log.i(TAG, "Setup wizard enabled: provisioning flow delegated to wizard"); + } else { + // Wizard is disabled. Force-set provisioned state based on device_provisioned + // config so the launcher starts directly without any wizard UI. + try { + int v = deviceProvisioned ? 1 : 0; + Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, v); + Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, v); + Log.i(TAG, "Setup wizard disabled: DEVICE_PROVISIONED=" + v); + } catch (Exception e) { + Log.w(TAG, "Failed to set device provisioned state", e); + } disablePackage("me.pawlet.setupwizard"); disablePackage("com.android.setupwizard"); disablePackage("com.google.android.setupwizard");