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