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