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.parser; 18 19 import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE; 20 import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE; 21 import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE; 22 import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE; 23 import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_USER; 24 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE; 25 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE; 26 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME; 27 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE; 28 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM; 29 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER; 30 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION; 31 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI; 32 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL; 33 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME; 34 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM; 35 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DISCLAIMERS; 36 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DISCLAIMER_CONTENT; 37 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DISCLAIMER_HEADER; 38 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION; 39 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED; 40 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LOCALE; 41 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LOCAL_TIME; 42 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_LOGO_URI; 43 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_MAIN_COLOR; 44 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_ORGANIZATION_NAME; 45 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_ENCRYPTION; 46 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_USER_CONSENT; 47 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS; 48 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SKIP_USER_SETUP; 49 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_SUPPORT_URL; 50 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_TIME_ZONE; 51 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_USE_MOBILE_DATA; 52 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_ANONYMOUS_IDENTITY; 53 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_CA_CERTIFICATE; 54 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_DOMAIN; 55 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_EAP_METHOD; 56 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_HIDDEN; 57 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_IDENTITY; 58 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PAC_URL; 59 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PASSWORD; 60 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PHASE2_AUTH; 61 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PROXY_BYPASS; 62 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PROXY_HOST; 63 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_PROXY_PORT; 64 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SECURITY_TYPE; 65 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_SSID; 66 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE; 67 68 import static com.android.internal.util.Preconditions.checkNotNull; 69 import static com.android.managedprovisioning.common.Globals.ACTION_PROVISION_MANAGED_DEVICE_SILENTLY; 70 import static com.android.managedprovisioning.common.Globals.ACTION_RESUME_PROVISIONING; 71 import static com.android.managedprovisioning.model.ProvisioningParams.DEFAULT_EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS; 72 import static com.android.managedprovisioning.model.ProvisioningParams.DEFAULT_EXTRA_PROVISIONING_USE_MOBILE_DATA; 73 import static com.android.managedprovisioning.model.ProvisioningParams.inferStaticDeviceAdminPackageName; 74 75 import android.app.admin.DevicePolicyManager; 76 import android.content.ComponentName; 77 import android.content.Context; 78 import android.content.Intent; 79 import android.net.Uri; 80 import android.os.Bundle; 81 import android.os.Parcelable; 82 import android.os.UserHandle; 83 84 import androidx.annotation.Nullable; 85 import androidx.annotation.VisibleForTesting; 86 87 import com.android.managedprovisioning.common.IllegalProvisioningArgumentException; 88 import com.android.managedprovisioning.common.LogoUtils; 89 import com.android.managedprovisioning.common.ManagedProvisioningSharedPreferences; 90 import com.android.managedprovisioning.common.ProvisionLogger; 91 import com.android.managedprovisioning.common.StoreUtils; 92 import com.android.managedprovisioning.common.Utils; 93 import com.android.managedprovisioning.model.DisclaimersParam; 94 import com.android.managedprovisioning.model.PackageDownloadInfo; 95 import com.android.managedprovisioning.model.ProvisioningParams; 96 import com.android.managedprovisioning.model.WifiInfo; 97 98 import java.util.Arrays; 99 import java.util.Collections; 100 import java.util.HashMap; 101 import java.util.HashSet; 102 import java.util.IllformedLocaleException; 103 import java.util.Map; 104 import java.util.Set; 105 106 /** 107 * A parser which parses provisioning data from intent which stores in {@link Bundle} extras. 108 */ 109 110 @VisibleForTesting 111 public class ExtrasProvisioningDataParser implements ProvisioningDataParser { 112 private static final Set<String> PROVISIONING_ACTIONS_SUPPORT_ALL_PROVISIONING_DATA = 113 new HashSet<>(Collections.singletonList( 114 ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE)); 115 116 private static final Set<String> PROVISIONING_ACTIONS_SUPPORT_MIN_PROVISIONING_DATA = 117 new HashSet<>(Arrays.asList( 118 ACTION_PROVISION_MANAGED_DEVICE, 119 ACTION_PROVISION_MANAGED_SHAREABLE_DEVICE, 120 ACTION_PROVISION_MANAGED_USER, 121 ACTION_PROVISION_MANAGED_PROFILE, 122 ACTION_PROVISION_MANAGED_DEVICE_SILENTLY)); 123 124 @VisibleForTesting 125 static final String EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE_SHORT = "a.a.e.PAEB"; 126 127 @VisibleForTesting 128 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME_SHORT = "a.a.e.PDAPN"; 129 130 @VisibleForTesting 131 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME_SHORT = "a.a.e.PDACN"; 132 133 @VisibleForTesting 134 static final String EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE_SHORT = "a.a.e.PATM"; 135 136 @VisibleForTesting 137 static final String EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION_SHORT = "a.a.e.PKAOM"; 138 139 @VisibleForTesting 140 static final String EXTRA_PROVISIONING_MAIN_COLOR_SHORT = "a.a.e.PMC"; 141 142 @VisibleForTesting 143 static final String EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED_SHORT = "a.a.e.PLASAE"; 144 145 @VisibleForTesting 146 static final String EXTRA_PROVISIONING_TIME_ZONE_SHORT = "a.a.e.PTZ"; 147 148 @VisibleForTesting 149 static final String EXTRA_PROVISIONING_LOCAL_TIME_SHORT = "a.a.e.PLT"; 150 151 @VisibleForTesting 152 static final String EXTRA_PROVISIONING_LOCALE_SHORT = "a.a.e.PL"; 153 154 @VisibleForTesting 155 static final String EXTRA_PROVISIONING_WIFI_SSID_SHORT = "a.a.e.PWS"; 156 157 @VisibleForTesting 158 static final String EXTRA_PROVISIONING_WIFI_HIDDEN_SHORT = "a.a.e.PWH"; 159 160 @VisibleForTesting 161 static final String EXTRA_PROVISIONING_WIFI_SECURITY_TYPE_SHORT = "a.a.e.PWST"; 162 163 @VisibleForTesting 164 static final String EXTRA_PROVISIONING_WIFI_PASSWORD_SHORT = "a.a.e.PWP"; 165 166 @VisibleForTesting 167 static final String EXTRA_PROVISIONING_WIFI_EAP_METHOD_SHORT = "a.a.e.PWEM"; 168 169 @VisibleForTesting 170 static final String EXTRA_PROVISIONING_WIFI_PHASE2_AUTH_SHORT = "a.a.e.PWPA"; 171 172 @VisibleForTesting 173 static final String EXTRA_PROVISIONING_WIFI_CA_CERTIFICATE_SHORT = "a.a.e.PWCC"; 174 175 @VisibleForTesting 176 static final String EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE_SHORT = "a.a.e.PWUC"; 177 178 @VisibleForTesting 179 static final String EXTRA_PROVISIONING_WIFI_IDENTITY_SHORT = "a.a.e.PWI"; 180 181 @VisibleForTesting 182 static final String EXTRA_PROVISIONING_WIFI_ANONYMOUS_IDENTITY_SHORT = "a.a.e.PWAI"; 183 184 @VisibleForTesting 185 static final String EXTRA_PROVISIONING_WIFI_DOMAIN_SHORT = "a.a.e.PWD"; 186 187 @VisibleForTesting 188 static final String EXTRA_PROVISIONING_WIFI_PROXY_HOST_SHORT = "a.a.e.PWPH"; 189 190 @VisibleForTesting 191 static final String EXTRA_PROVISIONING_WIFI_PROXY_PORT_SHORT = "a.a.e.PWPRP"; 192 193 @VisibleForTesting 194 static final String EXTRA_PROVISIONING_WIFI_PROXY_BYPASS_SHORT = "a.a.e.PWPB"; 195 196 @VisibleForTesting 197 static final String EXTRA_PROVISIONING_WIFI_PAC_URL_SHORT = "a.a.e.PWPU"; 198 199 @VisibleForTesting 200 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION_SHORT = 201 "a.a.e.PDAPDL"; 202 203 @VisibleForTesting 204 static final String EXTRA_PROVISIONING_ORGANIZATION_NAME_SHORT = "a.a.e.PON"; 205 206 @VisibleForTesting 207 static final String EXTRA_PROVISIONING_SUPPORT_URL_SHORT = "a.a.e.PSU"; 208 209 @VisibleForTesting 210 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL_SHORT = "a.a.e.PDAPL"; 211 212 @VisibleForTesting 213 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI_SHORT = "a.a.e.PDAPIU"; 214 215 @VisibleForTesting 216 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE_SHORT = "a.a.e.PDAMVC"; 217 218 @VisibleForTesting 219 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER_SHORT = 220 "a.a.e.PDAPDCH"; 221 222 @VisibleForTesting 223 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM_SHORT = "a.a.e.PDAPC"; 224 225 @VisibleForTesting 226 static final String EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM_SHORT = "a.a.e.PDASC"; 227 228 @VisibleForTesting 229 static final String EXTRA_PROVISIONING_SKIP_ENCRYPTION_SHORT = "a.a.e.PSE"; 230 231 @VisibleForTesting 232 static final String EXTRA_PROVISIONING_LOGO_URI_SHORT = "a.a.e.PLU"; 233 234 @VisibleForTesting 235 static final String EXTRA_PROVISIONING_DISCLAIMERS_SHORT = "a.a.e.PD"; 236 237 @VisibleForTesting 238 static final String EXTRA_PROVISIONING_DISCLAIMER_HEADER_SHORT = "a.a.e.PDH"; 239 240 @VisibleForTesting 241 static final String EXTRA_PROVISIONING_DISCLAIMER_CONTENT_SHORT = "a.a.e.PDC"; 242 243 @VisibleForTesting 244 static final String EXTRA_PROVISIONING_SKIP_USER_SETUP_SHORT = "a.a.e.PSUS"; 245 246 @VisibleForTesting 247 static final String EXTRA_PROVISIONING_SKIP_USER_CONSENT_SHORT = "a.a.e.PSUC"; 248 249 @VisibleForTesting 250 static final String EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS_SHORT = "a.a.e.PSES"; 251 252 @VisibleForTesting 253 static final String EXTRA_PROVISIONING_USE_MOBILE_DATA_SHORT = "a.a.e.PUMD"; 254 255 private static final Map<String, String> SHORTER_EXTRAS = buildShorterExtrasMap(); 256 buildShorterExtrasMap()257 private static Map<String, String> buildShorterExtrasMap() { 258 Map<String, String> shorterExtras = new HashMap<>(); 259 shorterExtras.put( 260 EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, 261 EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE_SHORT); 262 shorterExtras.put( 263 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, 264 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME_SHORT); 265 shorterExtras.put( 266 EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME, 267 EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME_SHORT); 268 shorterExtras.put( 269 EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE, EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE_SHORT); 270 shorterExtras.put( 271 EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION, 272 EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION_SHORT); 273 shorterExtras.put( 274 EXTRA_PROVISIONING_MAIN_COLOR, EXTRA_PROVISIONING_MAIN_COLOR_SHORT); 275 shorterExtras.put( 276 EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED, 277 EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED_SHORT); 278 shorterExtras.put( 279 EXTRA_PROVISIONING_TIME_ZONE, EXTRA_PROVISIONING_TIME_ZONE_SHORT); 280 shorterExtras.put( 281 EXTRA_PROVISIONING_LOCAL_TIME, EXTRA_PROVISIONING_LOCAL_TIME_SHORT); 282 shorterExtras.put( 283 EXTRA_PROVISIONING_LOCALE, EXTRA_PROVISIONING_LOCALE_SHORT); 284 shorterExtras.put( 285 EXTRA_PROVISIONING_WIFI_SSID, EXTRA_PROVISIONING_WIFI_SSID_SHORT); 286 shorterExtras.put( 287 EXTRA_PROVISIONING_WIFI_HIDDEN, EXTRA_PROVISIONING_WIFI_HIDDEN_SHORT); 288 shorterExtras.put( 289 EXTRA_PROVISIONING_WIFI_SECURITY_TYPE, EXTRA_PROVISIONING_WIFI_SECURITY_TYPE_SHORT); 290 shorterExtras.put( 291 EXTRA_PROVISIONING_WIFI_PASSWORD, EXTRA_PROVISIONING_WIFI_PASSWORD_SHORT); 292 shorterExtras.put( 293 EXTRA_PROVISIONING_WIFI_EAP_METHOD, EXTRA_PROVISIONING_WIFI_EAP_METHOD_SHORT); 294 shorterExtras.put( 295 EXTRA_PROVISIONING_WIFI_PHASE2_AUTH, EXTRA_PROVISIONING_WIFI_PHASE2_AUTH_SHORT); 296 shorterExtras.put( 297 EXTRA_PROVISIONING_WIFI_CA_CERTIFICATE, 298 EXTRA_PROVISIONING_WIFI_CA_CERTIFICATE_SHORT); 299 shorterExtras.put( 300 EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE, 301 EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE_SHORT); 302 shorterExtras.put( 303 EXTRA_PROVISIONING_WIFI_IDENTITY, EXTRA_PROVISIONING_WIFI_IDENTITY_SHORT); 304 shorterExtras.put( 305 EXTRA_PROVISIONING_WIFI_ANONYMOUS_IDENTITY, 306 EXTRA_PROVISIONING_WIFI_ANONYMOUS_IDENTITY_SHORT); 307 shorterExtras.put( 308 EXTRA_PROVISIONING_WIFI_DOMAIN, EXTRA_PROVISIONING_WIFI_DOMAIN_SHORT); 309 shorterExtras.put( 310 EXTRA_PROVISIONING_WIFI_PROXY_HOST, EXTRA_PROVISIONING_WIFI_PROXY_HOST_SHORT); 311 shorterExtras.put( 312 EXTRA_PROVISIONING_WIFI_PROXY_PORT, EXTRA_PROVISIONING_WIFI_PROXY_PORT_SHORT); 313 shorterExtras.put( 314 EXTRA_PROVISIONING_WIFI_PROXY_BYPASS, EXTRA_PROVISIONING_WIFI_PROXY_BYPASS_SHORT); 315 shorterExtras.put( 316 EXTRA_PROVISIONING_WIFI_PAC_URL, EXTRA_PROVISIONING_WIFI_PAC_URL_SHORT); 317 shorterExtras.put( 318 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION, 319 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION_SHORT); 320 shorterExtras.put( 321 EXTRA_PROVISIONING_ORGANIZATION_NAME, EXTRA_PROVISIONING_ORGANIZATION_NAME_SHORT); 322 shorterExtras.put( 323 EXTRA_PROVISIONING_SUPPORT_URL, EXTRA_PROVISIONING_SUPPORT_URL_SHORT); 324 shorterExtras.put( 325 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL, 326 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL_SHORT); 327 shorterExtras.put( 328 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI, 329 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI_SHORT); 330 shorterExtras.put( 331 EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE, 332 EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE_SHORT); 333 shorterExtras.put( 334 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER, 335 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER_SHORT); 336 shorterExtras.put( 337 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM, 338 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM_SHORT); 339 shorterExtras.put( 340 EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM, 341 EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM_SHORT); 342 shorterExtras.put( 343 EXTRA_PROVISIONING_SKIP_ENCRYPTION, EXTRA_PROVISIONING_SKIP_ENCRYPTION_SHORT); 344 shorterExtras.put( 345 EXTRA_PROVISIONING_DISCLAIMERS, EXTRA_PROVISIONING_DISCLAIMERS_SHORT); 346 shorterExtras.put( 347 EXTRA_PROVISIONING_LOGO_URI, EXTRA_PROVISIONING_LOGO_URI_SHORT); 348 shorterExtras.put( 349 EXTRA_PROVISIONING_DISCLAIMER_HEADER, EXTRA_PROVISIONING_DISCLAIMER_HEADER_SHORT); 350 shorterExtras.put( 351 EXTRA_PROVISIONING_DISCLAIMER_CONTENT, EXTRA_PROVISIONING_DISCLAIMER_CONTENT_SHORT); 352 shorterExtras.put( 353 EXTRA_PROVISIONING_SKIP_USER_SETUP, EXTRA_PROVISIONING_SKIP_USER_SETUP_SHORT); 354 shorterExtras.put( 355 EXTRA_PROVISIONING_SKIP_USER_CONSENT, EXTRA_PROVISIONING_SKIP_USER_CONSENT_SHORT); 356 shorterExtras.put( 357 EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS, 358 EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS_SHORT); 359 shorterExtras.put( 360 EXTRA_PROVISIONING_USE_MOBILE_DATA, EXTRA_PROVISIONING_USE_MOBILE_DATA_SHORT); 361 return shorterExtras; 362 } 363 364 private final Utils mUtils; 365 private final Context mContext; 366 private final ManagedProvisioningSharedPreferences mSharedPreferences; 367 ExtrasProvisioningDataParser(Context context, Utils utils)368 ExtrasProvisioningDataParser(Context context, Utils utils) { 369 this(context, utils, new ManagedProvisioningSharedPreferences(context)); 370 } 371 372 @VisibleForTesting ExtrasProvisioningDataParser(Context context, Utils utils, ManagedProvisioningSharedPreferences sharedPreferences)373 ExtrasProvisioningDataParser(Context context, Utils utils, 374 ManagedProvisioningSharedPreferences sharedPreferences) { 375 mContext = checkNotNull(context); 376 mUtils = checkNotNull(utils); 377 mSharedPreferences = checkNotNull(sharedPreferences); 378 } 379 380 @Override parse(Intent provisioningIntent)381 public ProvisioningParams parse(Intent provisioningIntent) 382 throws IllegalProvisioningArgumentException{ 383 String provisioningAction = provisioningIntent.getAction(); 384 if (ACTION_RESUME_PROVISIONING.equals(provisioningAction)) { 385 return getParcelableExtraFromLongName(provisioningIntent, 386 ProvisioningParams.EXTRA_PROVISIONING_PARAMS); 387 } 388 if (PROVISIONING_ACTIONS_SUPPORT_MIN_PROVISIONING_DATA.contains(provisioningAction)) { 389 ProvisionLogger.logi("Processing mininalist extras intent."); 390 return parseMinimalistSupportedProvisioningDataInternal(provisioningIntent, mContext) 391 .build(); 392 } else if (PROVISIONING_ACTIONS_SUPPORT_ALL_PROVISIONING_DATA.contains( 393 provisioningAction)) { 394 return parseAllSupportedProvisioningData(provisioningIntent, mContext); 395 } else { 396 throw new IllegalProvisioningArgumentException("Unsupported provisioning action: " 397 + provisioningAction); 398 } 399 } 400 401 /** 402 * Returns a short version of the requested extra. 403 */ getShortExtraNames(String extraName)404 static String getShortExtraNames(String extraName) { 405 return SHORTER_EXTRAS.get(extraName); 406 } 407 hasExtraFromLongName(Intent intent, String longName)408 private boolean hasExtraFromLongName(Intent intent, String longName) { 409 return intent.hasExtra(longName) || intent.hasExtra(getShortExtraNames(longName)); 410 } 411 412 @Nullable getParcelableExtraFromLongName( Intent intent, String longName)413 private <T extends Parcelable> T getParcelableExtraFromLongName( 414 Intent intent, String longName) { 415 if (intent.hasExtra(longName)) { 416 return intent.getParcelableExtra(longName); 417 } 418 String shortName = getShortExtraNames(longName); 419 if (intent.hasExtra(shortName)) { 420 return intent.getParcelableExtra(shortName); 421 } 422 return null; 423 } 424 425 @Nullable getParcelableArrayExtraFromLongName(Intent intent, String longName)426 private Parcelable[] getParcelableArrayExtraFromLongName(Intent intent, String longName) { 427 if (intent.hasExtra(longName)) { 428 return intent.getParcelableArrayExtra(longName); 429 } 430 String shortName = getShortExtraNames(longName); 431 if (intent.hasExtra(shortName)) { 432 return intent.getParcelableArrayExtra(shortName); 433 } 434 return null; 435 } 436 getIntExtraFromLongName(Intent intent, String longName, int defaultValue)437 private int getIntExtraFromLongName(Intent intent, String longName, int defaultValue) { 438 if (intent.hasExtra(longName)) { 439 return intent.getIntExtra(longName, defaultValue); 440 } 441 String shortName = getShortExtraNames(longName); 442 if (intent.hasExtra(shortName)) { 443 return intent.getIntExtra(shortName, defaultValue); 444 } 445 return defaultValue; 446 } 447 getBooleanExtraFromLongName( Intent intent, String longName, boolean defaultValue)448 private boolean getBooleanExtraFromLongName( 449 Intent intent, String longName, boolean defaultValue) { 450 if (intent.hasExtra(longName)) { 451 return intent.getBooleanExtra(longName, defaultValue); 452 } 453 String shortName = getShortExtraNames(longName); 454 if (intent.hasExtra(shortName)) { 455 return intent.getBooleanExtra(shortName, defaultValue); 456 } 457 return defaultValue; 458 } 459 getParcelableExtraFromLongName(Intent intent, String longName, long defaultValue)460 private long getParcelableExtraFromLongName(Intent intent, String longName, long defaultValue) { 461 if (intent.hasExtra(longName)) { 462 return intent.getLongExtra(longName, defaultValue); 463 } 464 String shortName = getShortExtraNames(longName); 465 if (intent.hasExtra(shortName)) { 466 return intent.getLongExtra(shortName, defaultValue); 467 } 468 return defaultValue; 469 } 470 471 @Nullable getStringExtraFromLongName(Intent intent, String longName)472 private String getStringExtraFromLongName(Intent intent, String longName) { 473 if (intent.getStringExtra(longName) != null) { 474 return intent.getStringExtra(longName); 475 } 476 String shortName = getShortExtraNames(longName); 477 if (intent.getStringExtra(shortName) != null) { 478 return intent.getStringExtra(shortName); 479 } 480 return null; 481 } 482 483 /** 484 * Parses minimal supported set of parameters from bundle extras of a provisioning intent. 485 * 486 * <p>Here is the list of supported parameters. 487 * <ul> 488 * <li>{@link EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME}</li> 489 * <li> 490 * {@link EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME} only in 491 * {@link ACTION_PROVISION_MANAGED_PROFILE}. 492 * </li> 493 * <li>{@link EXTRA_PROVISIONING_LOGO_URI}</li> 494 * <li>{@link EXTRA_PROVISIONING_MAIN_COLOR}</li> 495 * <li> 496 * {@link EXTRA_PROVISIONING_SKIP_USER_SETUP} only in 497 * {@link ACTION_PROVISION_MANAGED_USER} and {@link ACTION_PROVISION_MANAGED_DEVICE}. 498 * </li> 499 * <li>{@link EXTRA_PROVISIONING_SKIP_ENCRYPTION}</li> 500 * <li>{@link EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED}</li> 501 * <li>{@link EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE}</li> 502 * <li>{@link EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE}</li> 503 * <li>{@link EXTRA_PROVISIONING_SKIP_USER_CONSENT}</li> 504 * </ul> 505 */ parseMinimalistSupportedProvisioningDataInternal( Intent intent, Context context)506 private ProvisioningParams.Builder parseMinimalistSupportedProvisioningDataInternal( 507 Intent intent, Context context) 508 throws IllegalProvisioningArgumentException { 509 final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class); 510 boolean isProvisionManagedDeviceFromTrustedSourceIntent = 511 ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE.equals(intent.getAction()); 512 try { 513 final long provisioningId = mSharedPreferences.incrementAndGetProvisioningId(); 514 String provisioningAction = mUtils.mapIntentToDpmAction(intent); 515 final boolean isManagedProfileAction = 516 ACTION_PROVISION_MANAGED_PROFILE.equals(provisioningAction); 517 518 // Parse device admin package name and component name. 519 ComponentName deviceAdminComponentName = getParcelableExtraFromLongName( 520 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME); 521 // Device admin package name is deprecated. It is only supported in Profile Owner 522 // provisioning and when resuming NFC provisioning. 523 String deviceAdminPackageName = null; 524 if (isManagedProfileAction) { 525 // In L, we only support package name. This means some DPC may still send us the 526 // device admin package name only. Attempts to obtain the package name from extras. 527 deviceAdminPackageName = getStringExtraFromLongName( 528 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME); 529 // For profile owner, the device admin package should be installed. Verify the 530 // device admin package. 531 deviceAdminComponentName = mUtils.findDeviceAdmin( 532 deviceAdminPackageName, 533 deviceAdminComponentName, 534 context, 535 UserHandle.myUserId()); 536 // Since the device admin package must be installed at this point and its component 537 // name has been obtained, it should be safe to set the deprecated package name 538 // value to null. 539 deviceAdminPackageName = null; 540 } 541 542 // Parse skip user setup in ACTION_PROVISION_MANAGED_USER and 543 // ACTION_PROVISION_MANAGED_DEVICE (sync auth) only. This extra is not supported if 544 // provisioning was started by trusted source, as it is not clear where SUW should 545 // continue from. 546 boolean skipUserSetup = ProvisioningParams.DEFAULT_SKIP_USER_SETUP; 547 if (!isProvisionManagedDeviceFromTrustedSourceIntent 548 && (provisioningAction.equals(ACTION_PROVISION_MANAGED_USER) 549 || provisioningAction.equals(ACTION_PROVISION_MANAGED_DEVICE))) { 550 skipUserSetup = getBooleanExtraFromLongName( 551 intent, EXTRA_PROVISIONING_SKIP_USER_SETUP, 552 ProvisioningParams.DEFAULT_SKIP_USER_SETUP); 553 } 554 555 // Only current DeviceOwner can specify EXTRA_PROVISIONING_SKIP_USER_CONSENT when 556 // provisioning PO with ACTION_PROVISION_MANAGED_PROFILE 557 final boolean skipUserConsent = isManagedProfileAction 558 && getBooleanExtraFromLongName(intent, 559 EXTRA_PROVISIONING_SKIP_USER_CONSENT, 560 ProvisioningParams.DEFAULT_EXTRA_PROVISIONING_SKIP_USER_CONSENT) 561 && mUtils.isPackageDeviceOwner(dpm, inferStaticDeviceAdminPackageName( 562 deviceAdminComponentName, deviceAdminPackageName)); 563 564 final boolean skipEducationScreens = shouldSkipEducationScreens(intent); 565 566 // Only when provisioning PO with ACTION_PROVISION_MANAGED_PROFILE 567 final boolean keepAccountMigrated = isManagedProfileAction 568 && getBooleanExtraFromLongName( 569 intent, EXTRA_PROVISIONING_KEEP_ACCOUNT_ON_MIGRATION, 570 ProvisioningParams 571 .DEFAULT_EXTRA_PROVISIONING_KEEP_ACCOUNT_MIGRATED); 572 573 // Parse main color and organization's logo. This is not supported in managed device 574 // from trusted source provisioning because, currently, there is no way to send 575 // organization logo to the device at this stage. 576 Integer mainColor = ProvisioningParams.DEFAULT_MAIN_COLOR; 577 if (!isProvisionManagedDeviceFromTrustedSourceIntent) { 578 if (hasExtraFromLongName(intent, EXTRA_PROVISIONING_MAIN_COLOR)) { 579 mainColor = getIntExtraFromLongName( 580 intent, EXTRA_PROVISIONING_MAIN_COLOR, 0 /* not used */); 581 } 582 parseOrganizationLogoUrlFromExtras(context, intent); 583 } 584 585 DisclaimersParam disclaimersParam = new DisclaimersParser(context, provisioningId) 586 .parse(getParcelableArrayExtraFromLongName( 587 intent, EXTRA_PROVISIONING_DISCLAIMERS)); 588 589 String deviceAdminLabel = null; 590 String organizationName = null; 591 String supportUrl = null; 592 String deviceAdminIconFilePath = null; 593 if (isProvisionManagedDeviceFromTrustedSourceIntent) { 594 deviceAdminLabel = getStringExtraFromLongName(intent, 595 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_LABEL); 596 organizationName = getStringExtraFromLongName( 597 intent,EXTRA_PROVISIONING_ORGANIZATION_NAME); 598 supportUrl = getStringExtraFromLongName(intent,EXTRA_PROVISIONING_SUPPORT_URL); 599 deviceAdminIconFilePath = new DeviceAdminIconParser(context, provisioningId).parse( 600 getParcelableExtraFromLongName(intent, 601 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_ICON_URI)); 602 } 603 604 final boolean leaveAllSystemAppsEnabled = isManagedProfileAction 605 ? false 606 : getBooleanExtraFromLongName( 607 intent, EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED, 608 ProvisioningParams.DEFAULT_LEAVE_ALL_SYSTEM_APPS_ENABLED); 609 610 return ProvisioningParams.Builder.builder() 611 .setProvisioningId(provisioningId) 612 .setProvisioningAction(provisioningAction) 613 .setDeviceAdminComponentName(deviceAdminComponentName) 614 .setDeviceAdminPackageName(deviceAdminPackageName) 615 .setSkipEncryption( 616 getBooleanExtraFromLongName( 617 intent, EXTRA_PROVISIONING_SKIP_ENCRYPTION, 618 ProvisioningParams.DEFAULT_EXTRA_PROVISIONING_SKIP_ENCRYPTION)) 619 .setLeaveAllSystemAppsEnabled(leaveAllSystemAppsEnabled) 620 .setAdminExtrasBundle(getParcelableExtraFromLongName( 621 intent, EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE)) 622 .setMainColor(mainColor) 623 .setDisclaimersParam(disclaimersParam) 624 .setSkipUserConsent(skipUserConsent) 625 .setKeepAccountMigrated(keepAccountMigrated) 626 .setSkipUserSetup(skipUserSetup) 627 .setSkipEducationScreens(skipEducationScreens) 628 .setAccountToMigrate(getParcelableExtraFromLongName( 629 intent, EXTRA_PROVISIONING_ACCOUNT_TO_MIGRATE)) 630 .setDeviceAdminLabel(deviceAdminLabel) 631 .setOrganizationName(organizationName) 632 .setSupportUrl(supportUrl) 633 .setDeviceAdminIconFilePath(deviceAdminIconFilePath) 634 .setIsCloudEnrollment(mUtils.isCloudEnrollment(intent)) 635 .setIsOrganizationOwnedProvisioning( 636 mUtils.isOrganizationOwnedProvisioning(intent)); 637 } catch (ClassCastException e) { 638 throw new IllegalProvisioningArgumentException("Extra has invalid type", e); 639 } catch (IllegalArgumentException e) { 640 throw new IllegalProvisioningArgumentException("Invalid parameter found!", e); 641 } catch (NullPointerException e) { 642 throw new IllegalProvisioningArgumentException("Compulsory parameter not found!", e); 643 } 644 } 645 646 /** 647 * When {@link DevicePolicyManager#EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS} is passed as 648 * a provisioning extra, we only process it for managed Google account enrollment and 649 * persistent device owner. 650 */ shouldSkipEducationScreens(Intent intent)651 private boolean shouldSkipEducationScreens(Intent intent) { 652 if (!getBooleanExtraFromLongName(intent, 653 EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS, 654 DEFAULT_EXTRA_PROVISIONING_SKIP_EDUCATION_SCREENS)) { 655 return false; 656 } 657 if (mUtils.isOrganizationOwnedProvisioning(intent)) { 658 return false; 659 } 660 return isFullyManagedDeviceAction(intent); 661 } 662 isFullyManagedDeviceAction(Intent intent)663 private boolean isFullyManagedDeviceAction(Intent intent) { 664 return ACTION_PROVISION_MANAGED_DEVICE.equals(intent.getAction()) 665 || ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE.equals(intent.getAction()); 666 } 667 668 /** 669 * Parses an intent and return a corresponding {@link ProvisioningParams} object. 670 * 671 * @param intent intent to be parsed. 672 * @param context a context 673 */ parseAllSupportedProvisioningData(Intent intent, Context context)674 private ProvisioningParams parseAllSupportedProvisioningData(Intent intent, Context context) 675 throws IllegalProvisioningArgumentException { 676 try { 677 ProvisionLogger.logi("Processing all supported extras intent: " + intent.getAction()); 678 return parseMinimalistSupportedProvisioningDataInternal(intent, context) 679 // Parse time zone, local time and locale. 680 .setTimeZone(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_TIME_ZONE)) 681 .setLocalTime( 682 getParcelableExtraFromLongName( 683 intent, EXTRA_PROVISIONING_LOCAL_TIME, 684 ProvisioningParams.DEFAULT_LOCAL_TIME)) 685 .setLocale(StoreUtils.stringToLocale( 686 getStringExtraFromLongName(intent,EXTRA_PROVISIONING_LOCALE))) 687 .setUseMobileData( 688 getBooleanExtraFromLongName( 689 intent, EXTRA_PROVISIONING_USE_MOBILE_DATA, 690 DEFAULT_EXTRA_PROVISIONING_USE_MOBILE_DATA)) 691 // Parse WiFi configuration. 692 .setWifiInfo(parseWifiInfoFromExtras(intent)) 693 // Parse device admin package download info. 694 .setDeviceAdminDownloadInfo(parsePackageDownloadInfoFromExtras(intent)) 695 // Cases where startedByTrustedSource can be true are 696 // 1. We are reloading a stored provisioning intent, either Nfc bump or 697 // PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE, after encryption reboot, 698 // which is a self-originated intent. 699 // 2. the intent is from a trusted source, for example QR provisioning. 700 .setStartedByTrustedSource(ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE 701 .equals(intent.getAction())) 702 .build(); 703 } catch (IllegalArgumentException e) { 704 throw new IllegalProvisioningArgumentException("Invalid parameter found!", e); 705 } catch (IllformedLocaleException e) { 706 throw new IllegalProvisioningArgumentException("Invalid locale format!", e); 707 } catch (NullPointerException e) { 708 throw new IllegalProvisioningArgumentException("Compulsory parameter not found!", e); 709 } 710 } 711 712 /** 713 * Parses Wifi configuration from an Intent and returns the result in {@link WifiInfo}. 714 */ 715 @Nullable parseWifiInfoFromExtras(Intent intent)716 private WifiInfo parseWifiInfoFromExtras(Intent intent) { 717 if (getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_SSID) == null) { 718 return null; 719 } 720 return WifiInfo.Builder.builder() 721 .setSsid(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_SSID)) 722 .setSecurityType( 723 getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_SECURITY_TYPE)) 724 .setPassword(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_PASSWORD)) 725 .setProxyHost(getStringExtraFromLongName( 726 intent, EXTRA_PROVISIONING_WIFI_PROXY_HOST)) 727 .setProxyBypassHosts( 728 getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_PROXY_BYPASS)) 729 .setPacUrl(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_PAC_URL)) 730 .setProxyPort(getIntExtraFromLongName( 731 intent, EXTRA_PROVISIONING_WIFI_PROXY_PORT, 732 WifiInfo.DEFAULT_WIFI_PROXY_PORT)) 733 .setEapMethod(getStringExtraFromLongName( 734 intent, EXTRA_PROVISIONING_WIFI_EAP_METHOD)) 735 .setPhase2Auth(getStringExtraFromLongName( 736 intent, EXTRA_PROVISIONING_WIFI_PHASE2_AUTH)) 737 .setCaCertificate(getStringExtraFromLongName( 738 intent, EXTRA_PROVISIONING_WIFI_CA_CERTIFICATE)) 739 .setUserCertificate(getStringExtraFromLongName( 740 intent, EXTRA_PROVISIONING_WIFI_USER_CERTIFICATE)) 741 .setIdentity(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_IDENTITY)) 742 .setAnonymousIdentity(getStringExtraFromLongName( 743 intent, EXTRA_PROVISIONING_WIFI_ANONYMOUS_IDENTITY)) 744 .setDomain(getStringExtraFromLongName(intent, EXTRA_PROVISIONING_WIFI_DOMAIN)) 745 .setHidden(getBooleanExtraFromLongName( 746 intent, EXTRA_PROVISIONING_WIFI_HIDDEN, WifiInfo.DEFAULT_WIFI_HIDDEN)) 747 .build(); 748 } 749 750 /** 751 * Parses device admin package download info configuration from an Intent and returns the result 752 * in {@link PackageDownloadInfo}. 753 */ 754 @Nullable parsePackageDownloadInfoFromExtras(Intent intent)755 private PackageDownloadInfo parsePackageDownloadInfoFromExtras(Intent intent) { 756 if (getStringExtraFromLongName( 757 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION) == null) { 758 return null; 759 } 760 PackageDownloadInfo.Builder downloadInfoBuilder = PackageDownloadInfo.Builder.builder() 761 .setMinVersion(getIntExtraFromLongName( 762 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_MINIMUM_VERSION_CODE, 763 PackageDownloadInfo.DEFAULT_MINIMUM_VERSION)) 764 .setLocation(getStringExtraFromLongName( 765 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION)) 766 .setCookieHeader(getStringExtraFromLongName( 767 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_COOKIE_HEADER)); 768 String packageHash = 769 getStringExtraFromLongName( 770 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM); 771 if (packageHash != null) { 772 downloadInfoBuilder.setPackageChecksum(StoreUtils.stringToByteArray(packageHash)); 773 } 774 String sigHash = getStringExtraFromLongName( 775 intent, EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM); 776 if (sigHash != null) { 777 downloadInfoBuilder.setSignatureChecksum(StoreUtils.stringToByteArray(sigHash)); 778 } 779 return downloadInfoBuilder.build(); 780 } 781 782 /** 783 * Parses the organization logo url from intent. 784 */ parseOrganizationLogoUrlFromExtras(Context context, Intent intent)785 private void parseOrganizationLogoUrlFromExtras(Context context, Intent intent) { 786 Uri logoUri = getParcelableExtraFromLongName(intent, EXTRA_PROVISIONING_LOGO_URI); 787 if (logoUri != null) { 788 // If we go through encryption, and if the uri is a content uri: 789 // We'll lose the grant to this uri. So we need to save it to a local file. 790 LogoUtils.saveOrganisationLogo(context, logoUri); 791 } 792 } 793 } 794