Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright 2016, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.managedprovisioning.model;
     18 
     19 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE;
     20 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE;
     21 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME;
     22 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI;
     23 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL;
     24 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME;
     25 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DISCLAIMERS;
     26 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION;
     27 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED;
     28 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LOCALE;
     29 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LOCAL_TIME;
     30 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR;
     31 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ORGANIZATION_NAME;
     32 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_ENCRYPTION;
     33 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_USER_CONSENT;
     34 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_USER_SETUP;
     35 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SUPPORT_URL;
     36 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_TIME_ZONE;
     37 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_USE_MOBILE_DATA;
     38 
     39 import static com.android.internal.util.Preconditions.checkArgument;
     40 import static com.android.internal.util.Preconditions.checkNotNull;
     41 import static com.android.managedprovisioning.common.ManagedProvisioningSharedPreferences.DEFAULT_PROVISIONING_ID;
     42 import static com.android.managedprovisioning.common.StoreUtils.accountToPersistableBundle;
     43 import static com.android.managedprovisioning.common.StoreUtils.getIntegerAttrFromPersistableBundle;
     44 import static com.android.managedprovisioning.common.StoreUtils.getObjectAttrFromPersistableBundle;
     45 import static com.android.managedprovisioning.common.StoreUtils.getStringAttrFromPersistableBundle;
     46 import static com.android.managedprovisioning.common.StoreUtils.putIntegerIfNotNull;
     47 import static com.android.managedprovisioning.common.StoreUtils.putPersistableBundlableIfNotNull;
     48 
     49 import android.accounts.Account;
     50 import android.content.ComponentName;
     51 import android.content.Context;
     52 import android.os.Parcel;
     53 import android.os.Parcelable;
     54 import android.os.PersistableBundle;
     55 import android.support.annotation.Nullable;
     56 import android.util.AtomicFile;
     57 import android.util.Xml;
     58 
     59 import com.android.internal.util.FastXmlSerializer;
     60 import com.android.managedprovisioning.common.IllegalProvisioningArgumentException;
     61 import com.android.managedprovisioning.common.PersistableBundlable;
     62 import com.android.managedprovisioning.common.ProvisionLogger;
     63 import com.android.managedprovisioning.common.StoreUtils;
     64 import com.android.managedprovisioning.common.Utils;
     65 
     66 import org.xmlpull.v1.XmlPullParser;
     67 import org.xmlpull.v1.XmlPullParserException;
     68 import org.xmlpull.v1.XmlSerializer;
     69 
     70 import java.io.File;
     71 import java.io.FileInputStream;
     72 import java.io.FileOutputStream;
     73 import java.io.IOException;
     74 import java.nio.charset.StandardCharsets;
     75 import java.util.Locale;
     76 
     77 /**
     78  * Provisioning parameters for Device Owner and Profile Owner provisioning.
     79  */
     80 public final class ProvisioningParams extends PersistableBundlable {
     81     public static final long DEFAULT_LOCAL_TIME = -1;
     82     public static final Integer DEFAULT_MAIN_COLOR = null;
     83     public static final boolean DEFAULT_STARTED_BY_TRUSTED_SOURCE = false;
     84     public static final boolean DEFAULT_IS_NFC = false;
     85     public static final boolean DEFAULT_LEAVE_ALL_SYSTEM_APPS_ENABLED = false;
     86     public static final boolean DEFAULT_EXTRA_PROVISIONING_SKIP_ENCRYPTION = false;
     87     public static final boolean DEFAULT_EXTRA_PROVISIONING_SKIP_USER_CONSENT = false;
     88     public static final boolean DEFAULT_EXTRA_PROVISIONING_KEEP_ACCOUNT_MIGRATED = false;
     89     public static final boolean DEFAULT_SKIP_USER_SETUP = true;
     90     public static final boolean DEFAULT_EXTRA_PROVISIONING_USE_MOBILE_DATA = false;
     91     // Intent extra used internally for passing data between activities and service.
     92     public static final String EXTRA_PROVISIONING_PARAMS = "provisioningParams";
     93 
     94     private static final String TAG_PROVISIONING_ID = "provisioning-id";
     95     private static final String TAG_PROVISIONING_PARAMS = "provisioning-params";
     96     private static final String TAG_WIFI_INFO = "wifi-info";
     97     private static final String TAG_PACKAGE_DOWNLOAD_INFO = "download-info";
     98     private static final String TAG_STARTED_BY_TRUSTED_SOURCE = "started-by-trusted-source";
     99     private static final String TAG_IS_NFC = "started-is-nfc";
    100     private static final String TAG_PROVISIONING_ACTION = "provisioning-action";
    101 
    102     public static final Parcelable.Creator<ProvisioningParams> CREATOR
    103             = new Parcelable.Creator<ProvisioningParams>() {
    104         @Override
    105         public ProvisioningParams createFromParcel(Parcel in) {
    106             return new ProvisioningParams(in);
    107         }
    108 
    109         @Override
    110         public ProvisioningParams[] newArray(int size) {
    111             return new ProvisioningParams[size];
    112         }
    113     };
    114 
    115     public final long provisioningId;
    116 
    117     @Nullable
    118     public final String timeZone;
    119 
    120     public final long localTime;
    121 
    122     @Nullable
    123     public final Locale locale;
    124 
    125     /** WiFi configuration. */
    126     @Nullable
    127     public final WifiInfo wifiInfo;
    128 
    129     public final boolean useMobileData;
    130 
    131     /**
    132      * Package name of the device admin package.
    133      *
    134      * <p>At least one one of deviceAdminPackageName and deviceAdminComponentName should be
    135      * non-null.
    136      * <p>
    137      * In most cases, it is preferable to access the admin package name using
    138      * {@link #inferDeviceAdminPackageName}.
    139      */
    140     @Deprecated
    141     @Nullable
    142     public final String deviceAdminPackageName;
    143 
    144     /**
    145      * {@link ComponentName} of the device admin package.
    146      *
    147      * <p>At least one one of deviceAdminPackageName and deviceAdminComponentName should be
    148      * non-null.
    149      * <p>
    150      * In most cases, it is preferable to access the admin component name using
    151      * {@link #inferDeviceAdminComponentName(Utils, Context, int)} .
    152      */
    153     @Nullable
    154     public final ComponentName deviceAdminComponentName;
    155 
    156     public final String deviceAdminLabel;
    157     public final String organizationName;
    158     public final String supportUrl;
    159     public final String deviceAdminIconFilePath;
    160 
    161     /** {@link Account} that should be migrated to the managed profile. */
    162     @Nullable
    163     public final Account accountToMigrate;
    164 
    165     /** True if the account will not be removed from the calling user after it is migrated. */
    166     public final boolean keepAccountMigrated;
    167 
    168     /** Provisioning action comes along with the provisioning data. */
    169     public final String provisioningAction;
    170 
    171     /**
    172      * The main color theme used in managed profile only.
    173      *
    174      * <p>{@code null} means the default value.
    175      */
    176     @Nullable
    177     public final Integer mainColor;
    178 
    179     /** The download information of device admin package. */
    180     @Nullable
    181     public final PackageDownloadInfo deviceAdminDownloadInfo;
    182 
    183     /** List of disclaimers */
    184     @Nullable
    185     public final DisclaimersParam disclaimersParam;
    186 
    187     /**
    188      * Custom key-value pairs from enterprise mobility management which are passed to device admin
    189      * package after provisioning.
    190      *
    191      * <p>Note that {@link ProvisioningParams} is not immutable because this field is mutable.
    192      */
    193     @Nullable
    194     public final PersistableBundle adminExtrasBundle;
    195 
    196     /**
    197      * True iff provisioning flow was started by a trusted app. This includes Nfc bump and QR code.
    198      */
    199     public final boolean startedByTrustedSource;
    200 
    201     public final boolean isNfc;
    202 
    203     /** True if all system apps should be enabled after provisioning. */
    204     public final boolean leaveAllSystemAppsEnabled;
    205 
    206     /** True if device encryption should be skipped. */
    207     public final boolean skipEncryption;
    208 
    209     /** True if user setup can be skipped. */
    210     public final boolean skipUserSetup;
    211 
    212     /** True if user consent page in pre-provisioning can be skipped. */
    213     public final boolean skipUserConsent;
    214 
    215     public static String inferStaticDeviceAdminPackageName(ComponentName deviceAdminComponentName,
    216             String deviceAdminPackageName) {
    217         if (deviceAdminComponentName != null) {
    218             return deviceAdminComponentName.getPackageName();
    219         }
    220         return deviceAdminPackageName;
    221     }
    222 
    223     public String inferDeviceAdminPackageName() {
    224         return inferStaticDeviceAdminPackageName(deviceAdminComponentName, deviceAdminPackageName);
    225     }
    226 
    227     /**
    228      * Due to legacy reason, DPC is allowed to provide either package name or the component name.
    229      * If component name is not {@code null}, we will return it right away. Otherwise, we will
    230      * infer the component name.
    231      * <p>
    232      * In most cases, it is preferable to access the admin component name using this method.
    233      * But if the purpose is to verify the device admin component name, you should use
    234      * {@link Utils#findDeviceAdmin(String, ComponentName, Context, int)} instead.
    235      */
    236     public ComponentName inferDeviceAdminComponentName(Utils utils, Context context, int userId)
    237             throws IllegalProvisioningArgumentException {
    238         if (deviceAdminComponentName != null) {
    239             return deviceAdminComponentName;
    240         }
    241         return utils.findDeviceAdmin(
    242                 deviceAdminPackageName, deviceAdminComponentName, context, userId);
    243     }
    244 
    245     private ProvisioningParams(Builder builder) {
    246         provisioningId = builder.mProvisioningId;
    247         timeZone = builder.mTimeZone;
    248         localTime = builder.mLocalTime;
    249         locale = builder.mLocale;
    250 
    251         wifiInfo = builder.mWifiInfo;
    252         useMobileData = builder.mUseMobileData;
    253 
    254         deviceAdminComponentName = builder.mDeviceAdminComponentName;
    255         deviceAdminPackageName = builder.mDeviceAdminPackageName;
    256         deviceAdminLabel = builder.mDeviceAdminLabel;
    257         organizationName = builder.mOrganizationName;
    258         supportUrl = builder.mSupportUrl;
    259         deviceAdminIconFilePath = builder.mDeviceAdminIconFilePath;
    260 
    261         deviceAdminDownloadInfo = builder.mDeviceAdminDownloadInfo;
    262         disclaimersParam = builder.mDisclaimersParam;
    263 
    264         adminExtrasBundle = builder.mAdminExtrasBundle;
    265 
    266         startedByTrustedSource = builder.mStartedByTrustedSource;
    267         isNfc = builder.mIsNfc;
    268         leaveAllSystemAppsEnabled = builder.mLeaveAllSystemAppsEnabled;
    269         skipEncryption = builder.mSkipEncryption;
    270         accountToMigrate = builder.mAccountToMigrate;
    271         provisioningAction = checkNotNull(builder.mProvisioningAction);
    272         mainColor = builder.mMainColor;
    273         skipUserConsent = builder.mSkipUserConsent;
    274         skipUserSetup = builder.mSkipUserSetup;
    275         keepAccountMigrated = builder.mKeepAccountMigrated;
    276 
    277         validateFields();
    278     }
    279 
    280     private ProvisioningParams(Parcel in) {
    281         this(createBuilderFromPersistableBundle(
    282                 PersistableBundlable.getPersistableBundleFromParcel(in)));
    283     }
    284 
    285     private void validateFields() {
    286         checkArgument(deviceAdminPackageName != null || deviceAdminComponentName != null);
    287     }
    288 
    289     @Override
    290     public PersistableBundle toPersistableBundle() {
    291         final PersistableBundle bundle = new PersistableBundle();
    292 
    293         bundle.putLong(TAG_PROVISIONING_ID, provisioningId);
    294         bundle.putString(EXTRA_PROVISIONING_TIME_ZONE, timeZone);
    295         bundle.putLong(EXTRA_PROVISIONING_LOCAL_TIME, localTime);
    296         bundle.putString(EXTRA_PROVISIONING_LOCALE, StoreUtils.localeToString(locale));
    297         putPersistableBundlableIfNotNull(bundle, TAG_WIFI_INFO, wifiInfo);
    298         bundle.putBoolean(EXTRA_PROVISIONING_USE_MOBILE_DATA, useMobileData);
    299         bundle.putString(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, deviceAdminPackageName);
    300         bundle.putString(EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME,
    301                 StoreUtils.componentNameToString(deviceAdminComponentName));
    302         bundle.putString(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL, deviceAdminLabel);
    303         bundle.putString(EXTRA_PROVISIONING_ORGANIZATION_NAME, organizationName);
    304         bundle.putString(EXTRA_PROVISIONING_SUPPORT_URL, supportUrl);
    305         bundle.putString(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI, deviceAdminIconFilePath);
    306         bundle.putPersistableBundle(EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE, accountToMigrate == null
    307                 ? null : accountToPersistableBundle(accountToMigrate));
    308         bundle.putString(TAG_PROVISIONING_ACTION, provisioningAction);
    309         putIntegerIfNotNull(bundle, EXTRA_PROVISIONING_MAIN_COLOR, mainColor);
    310         putPersistableBundlableIfNotNull(bundle, TAG_PACKAGE_DOWNLOAD_INFO,
    311                 deviceAdminDownloadInfo);
    312         putPersistableBundlableIfNotNull(bundle, EXTRA_PROVISIONING_DISCLAIMERS,
    313                 disclaimersParam);
    314         bundle.putPersistableBundle(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, adminExtrasBundle);
    315         bundle.putBoolean(TAG_STARTED_BY_TRUSTED_SOURCE, startedByTrustedSource);
    316         bundle.putBoolean(TAG_IS_NFC, isNfc);
    317         bundle.putBoolean(EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED,
    318                 leaveAllSystemAppsEnabled);
    319         bundle.putBoolean(EXTRA_PROVISIONING_SKIP_ENCRYPTION, skipEncryption);
    320         bundle.putBoolean(EXTRA_PROVISIONING_SKIP_USER_SETUP, skipUserSetup);
    321         bundle.putBoolean(EXTRA_PROVISIONING_SKIP_USER_CONSENT, skipUserConsent);
    322         bundle.putBoolean(EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION, keepAccountMigrated);
    323         return bundle;
    324     }
    325 
    326     /* package */ static ProvisioningParams fromPersistableBundle(PersistableBundle bundle) {
    327         return createBuilderFromPersistableBundle(bundle).build();
    328     }
    329 
    330     private static Builder createBuilderFromPersistableBundle(PersistableBundle bundle) {
    331         Builder builder = new Builder();
    332         builder.setProvisioningId(bundle.getLong(TAG_PROVISIONING_ID, DEFAULT_PROVISIONING_ID));
    333         builder.setTimeZone(bundle.getString(EXTRA_PROVISIONING_TIME_ZONE));
    334         builder.setLocalTime(bundle.getLong(EXTRA_PROVISIONING_LOCAL_TIME));
    335         builder.setLocale(getStringAttrFromPersistableBundle(bundle,
    336                 EXTRA_PROVISIONING_LOCALE, StoreUtils::stringToLocale));
    337         builder.setUseMobileData(bundle.getBoolean(EXTRA_PROVISIONING_USE_MOBILE_DATA));
    338         builder.setWifiInfo(getObjectAttrFromPersistableBundle(bundle,
    339                 TAG_WIFI_INFO, WifiInfo::fromPersistableBundle));
    340         builder.setDeviceAdminPackageName(bundle.getString(
    341                 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME));
    342         builder.setDeviceAdminComponentName(getStringAttrFromPersistableBundle(bundle,
    343                 EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, StoreUtils::stringToComponentName));
    344         builder.setDeviceAdminLabel(bundle.getString(
    345                 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL));
    346         builder.setOrganizationName(bundle.getString(EXTRA_PROVISIONING_ORGANIZATION_NAME));
    347         builder.setSupportUrl(bundle.getString(EXTRA_PROVISIONING_SUPPORT_URL));
    348         builder.setDeviceAdminIconFilePath(bundle.getString(
    349                 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI));
    350         builder.setAccountToMigrate(getObjectAttrFromPersistableBundle(bundle,
    351                 EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE, StoreUtils::persistableBundleToAccount));
    352         builder.setProvisioningAction(bundle.getString(TAG_PROVISIONING_ACTION));
    353         builder.setMainColor(getIntegerAttrFromPersistableBundle(bundle,
    354                 EXTRA_PROVISIONING_MAIN_COLOR));
    355         builder.setDeviceAdminDownloadInfo(getObjectAttrFromPersistableBundle(bundle,
    356                 TAG_PACKAGE_DOWNLOAD_INFO, PackageDownloadInfo::fromPersistableBundle));
    357         builder.setDisclaimersParam(getObjectAttrFromPersistableBundle(bundle,
    358                 EXTRA_PROVISIONING_DISCLAIMERS, DisclaimersParam::fromPersistableBundle));
    359         builder.setAdminExtrasBundle(bundle.getPersistableBundle(
    360                 EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
    361         builder.setStartedByTrustedSource(bundle.getBoolean(TAG_STARTED_BY_TRUSTED_SOURCE));
    362         builder.setIsNfc(bundle.getBoolean(TAG_IS_NFC));
    363         builder.setSkipEncryption(bundle.getBoolean(EXTRA_PROVISIONING_SKIP_ENCRYPTION));
    364         builder.setLeaveAllSystemAppsEnabled(bundle.getBoolean(
    365                 EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED));
    366         builder.setSkipUserSetup(bundle.getBoolean(EXTRA_PROVISIONING_SKIP_USER_SETUP));
    367         builder.setSkipUserConsent(bundle.getBoolean(EXTRA_PROVISIONING_SKIP_USER_CONSENT));
    368         builder.setKeepAccountMigrated(bundle.getBoolean(
    369                 EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION));
    370         return builder;
    371     }
    372 
    373     @Override
    374     public String toString() {
    375         return "ProvisioningParams values: " + toPersistableBundle().toString();
    376     }
    377 
    378     /**
    379      * Saves the ProvisioningParams to the specified file.
    380      */
    381     public void save(File file) {
    382         ProvisionLogger.logd("Saving ProvisioningParams to " + file);
    383         AtomicFile atomicFile = null;
    384         FileOutputStream stream = null;
    385         try {
    386             atomicFile = new AtomicFile(file);
    387             stream = atomicFile.startWrite();
    388             XmlSerializer serializer = new FastXmlSerializer();
    389             serializer.setOutput(stream, StandardCharsets.UTF_8.name());
    390             serializer.startDocument(null, true);
    391             serializer.startTag(null, TAG_PROVISIONING_PARAMS);
    392             toPersistableBundle().saveToXml(serializer);
    393             serializer.endTag(null, TAG_PROVISIONING_PARAMS);
    394             serializer.endDocument();
    395             atomicFile.finishWrite(stream);
    396         } catch (IOException | XmlPullParserException e) {
    397             ProvisionLogger.loge("Caught exception while trying to save Provisioning Params to "
    398                     + " file " + file, e);
    399             file.delete();
    400             if (atomicFile != null) {
    401                 atomicFile.failWrite(stream);
    402             }
    403         }
    404     }
    405 
    406     public void cleanUp() {
    407         if (disclaimersParam != null) {
    408             disclaimersParam.cleanUp();
    409         }
    410         if (deviceAdminIconFilePath != null) {
    411             new File(deviceAdminIconFilePath).delete();
    412         }
    413     }
    414 
    415     /**
    416      * Loads the ProvisioningParams From the specified file.
    417      */
    418     public static ProvisioningParams load(File file) {
    419         if (!file.exists()) {
    420             return null;
    421         }
    422         ProvisionLogger.logd("Loading ProvisioningParams from " + file);
    423         try (FileInputStream stream = new FileInputStream(file)) {
    424             XmlPullParser parser = Xml.newPullParser();
    425             parser.setInput(stream, null);
    426             return load(parser);
    427         } catch (IOException | XmlPullParserException e) {
    428             ProvisionLogger.loge("Caught exception while trying to load the provisioning params"
    429                     + " from file " + file, e);
    430             return null;
    431         }
    432     }
    433 
    434     private static ProvisioningParams load(XmlPullParser parser) throws XmlPullParserException,
    435             IOException {
    436         int type;
    437         int outerDepth = parser.getDepth();
    438         while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
    439                 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
    440              if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
    441                  continue;
    442              }
    443              String tag = parser.getName();
    444              switch (tag) {
    445                  case TAG_PROVISIONING_PARAMS:
    446                      return createBuilderFromPersistableBundle(
    447                              PersistableBundle.restoreFromXml(parser)).build();
    448              }
    449         }
    450         return new Builder().build();
    451     }
    452 
    453     public final static class Builder {
    454         private long mProvisioningId;
    455         private String mTimeZone;
    456         private long mLocalTime = DEFAULT_LOCAL_TIME;
    457         private Locale mLocale;
    458         private WifiInfo mWifiInfo;
    459         private String mDeviceAdminPackageName;
    460         private ComponentName mDeviceAdminComponentName;
    461         private String mDeviceAdminLabel;
    462         private String mOrganizationName;
    463         private String mSupportUrl;
    464         private String mDeviceAdminIconFilePath;
    465         private Account mAccountToMigrate;
    466         private String mProvisioningAction;
    467         private Integer mMainColor = DEFAULT_MAIN_COLOR;
    468         private PackageDownloadInfo mDeviceAdminDownloadInfo;
    469         private DisclaimersParam mDisclaimersParam;
    470         private PersistableBundle mAdminExtrasBundle;
    471         private boolean mStartedByTrustedSource = DEFAULT_STARTED_BY_TRUSTED_SOURCE;
    472         private boolean mIsNfc = DEFAULT_IS_NFC;
    473         private boolean mLeaveAllSystemAppsEnabled = DEFAULT_LEAVE_ALL_SYSTEM_APPS_ENABLED;
    474         private boolean mSkipEncryption = DEFAULT_EXTRA_PROVISIONING_SKIP_ENCRYPTION;
    475         private boolean mSkipUserConsent = DEFAULT_EXTRA_PROVISIONING_SKIP_USER_CONSENT;
    476         private boolean mSkipUserSetup = DEFAULT_SKIP_USER_SETUP;
    477         private boolean mKeepAccountMigrated = DEFAULT_EXTRA_PROVISIONING_KEEP_ACCOUNT_MIGRATED;
    478         private boolean mUseMobileData = DEFAULT_EXTRA_PROVISIONING_USE_MOBILE_DATA;
    479 
    480         public Builder setProvisioningId(long provisioningId) {
    481             mProvisioningId = provisioningId;
    482             return this;
    483         }
    484 
    485         public Builder setTimeZone(String timeZone) {
    486             mTimeZone = timeZone;
    487             return this;
    488         }
    489 
    490         public Builder setLocalTime(long localTime) {
    491             mLocalTime = localTime;
    492             return this;
    493         }
    494 
    495         public Builder setLocale(Locale locale) {
    496             mLocale = locale;
    497             return this;
    498         }
    499 
    500         public Builder setWifiInfo(WifiInfo wifiInfo) {
    501             mWifiInfo = wifiInfo;
    502             return this;
    503         }
    504 
    505         @Deprecated
    506         public Builder setDeviceAdminPackageName(String deviceAdminPackageName) {
    507             mDeviceAdminPackageName = deviceAdminPackageName;
    508             return this;
    509         }
    510 
    511         public Builder setDeviceAdminComponentName(ComponentName deviceAdminComponentName) {
    512             mDeviceAdminComponentName = deviceAdminComponentName;
    513             return this;
    514         }
    515 
    516         public Builder setDeviceAdminLabel(String deviceAdminLabel) {
    517             mDeviceAdminLabel = deviceAdminLabel;
    518             return this;
    519         }
    520 
    521         public Builder setOrganizationName(String organizationName) {
    522             mOrganizationName = organizationName;
    523             return this;
    524         }
    525 
    526         public Builder setSupportUrl(String supportUrl) {
    527             mSupportUrl = supportUrl;
    528             return this;
    529         }
    530 
    531         public Builder setDeviceAdminIconFilePath(String deviceAdminIconFilePath) {
    532             mDeviceAdminIconFilePath = deviceAdminIconFilePath;
    533             return this;
    534         }
    535 
    536         public Builder setAccountToMigrate(Account accountToMigrate) {
    537             mAccountToMigrate = accountToMigrate;
    538             return this;
    539         }
    540 
    541         public Builder setProvisioningAction(String provisioningAction) {
    542             mProvisioningAction = provisioningAction;
    543             return this;
    544         }
    545 
    546         public Builder setMainColor(Integer mainColor) {
    547             mMainColor = mainColor;
    548             return this;
    549         }
    550 
    551         public Builder setDeviceAdminDownloadInfo(PackageDownloadInfo deviceAdminDownloadInfo) {
    552             mDeviceAdminDownloadInfo = deviceAdminDownloadInfo;
    553             return this;
    554         }
    555 
    556         public Builder setDisclaimersParam(DisclaimersParam disclaimersParam) {
    557             mDisclaimersParam = disclaimersParam;
    558             return this;
    559         }
    560 
    561         public Builder setAdminExtrasBundle(PersistableBundle adminExtrasBundle) {
    562             mAdminExtrasBundle = adminExtrasBundle;
    563             return this;
    564         }
    565 
    566         public Builder setStartedByTrustedSource(boolean startedByTrustedSource) {
    567             mStartedByTrustedSource = startedByTrustedSource;
    568             return this;
    569         }
    570 
    571         public Builder setIsNfc(boolean isNfc) {
    572             mIsNfc = isNfc;
    573             return this;
    574         }
    575 
    576 
    577         public Builder setLeaveAllSystemAppsEnabled(boolean leaveAllSystemAppsEnabled) {
    578             mLeaveAllSystemAppsEnabled = leaveAllSystemAppsEnabled;
    579             return this;
    580         }
    581 
    582         public Builder setSkipEncryption(boolean skipEncryption) {
    583             mSkipEncryption = skipEncryption;
    584             return this;
    585         }
    586 
    587         public Builder setSkipUserConsent(boolean skipUserConsent) {
    588             mSkipUserConsent = skipUserConsent;
    589             return this;
    590         }
    591 
    592         public Builder setSkipUserSetup(boolean skipUserSetup) {
    593             mSkipUserSetup = skipUserSetup;
    594             return this;
    595         }
    596 
    597         public Builder setKeepAccountMigrated(boolean keepAccountMigrated) {
    598             mKeepAccountMigrated = keepAccountMigrated;
    599             return this;
    600         }
    601 
    602         public Builder setUseMobileData(boolean useMobileData) {
    603             mUseMobileData = useMobileData;
    604             return this;
    605         }
    606 
    607         public ProvisioningParams build() {
    608             return new ProvisioningParams(this);
    609         }
    610 
    611         public static Builder builder() {
    612             return new Builder();
    613         }
    614     }
    615 }
    616