ProvisioningService: unify setup state into single coherent method

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
This commit is contained in:
oxmc
2026-06-16 20:14:35 -07:00
parent 590f38f028
commit 8d6ec6f49a

View File

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