1 /* 2 * Copyright (C) 2021 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.common; 18 19 import static android.app.admin.DevicePolicyManager.EXTRA_FORCE_UPDATE_ROLE_HOLDER; 20 import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_TRIGGER; 21 22 import static com.android.managedprovisioning.TestUtils.assertIntentsEqual; 23 24 import static com.google.common.truth.Truth.assertThat; 25 26 import static org.junit.Assert.assertThrows; 27 28 import android.app.admin.DevicePolicyManager; 29 import android.content.ComponentName; 30 import android.content.Context; 31 import android.content.Intent; 32 33 import androidx.test.core.app.ApplicationProvider; 34 import androidx.test.filters.SmallTest; 35 36 import com.android.managedprovisioning.model.PackageDownloadInfo; 37 import com.android.managedprovisioning.model.ProvisioningParams; 38 39 import org.junit.Before; 40 import org.junit.Test; 41 import org.junit.runner.RunWith; 42 import org.junit.runners.JUnit4; 43 44 45 @SmallTest 46 @RunWith(JUnit4.class) 47 public class DeviceManagementRoleHolderUpdaterHelperTest { 48 49 private static final String ROLE_HOLDER_UPDATER_PACKAGE_NAME = "com.test.updater.package"; 50 private static final String ROLE_HOLDER_PACKAGE_NAME = "com.test.roleholder.package"; 51 private static final String ROLE_HOLDER_UPDATER_EMPTY_PACKAGE_NAME = ""; 52 private static final String ROLE_HOLDER_UPDATER_NULL_PACKAGE_NAME = null; 53 private static final String ROLE_HOLDER_EMPTY_PACKAGE_NAME = ""; 54 private static final String ROLE_HOLDER_NULL_PACKAGE_NAME = null; 55 private static final int TEST_PROVISIONING_TRIGGER = 56 DevicePolicyManager.PROVISIONING_TRIGGER_QR_CODE; 57 private static final Intent ROLE_HOLDER_UPDATER_INTENT = 58 new Intent(DevicePolicyManager.ACTION_UPDATE_DEVICE_POLICY_MANAGEMENT_ROLE_HOLDER) 59 .setPackage(ROLE_HOLDER_UPDATER_PACKAGE_NAME) 60 .putExtra(EXTRA_PROVISIONING_TRIGGER, TEST_PROVISIONING_TRIGGER) 61 .putExtra(EXTRA_FORCE_UPDATE_ROLE_HOLDER, false); 62 private static final Intent ROLE_HOLDER_UPDATER_INTENT_WITH_FORCE_UPDATE = 63 new Intent(DevicePolicyManager.ACTION_UPDATE_DEVICE_POLICY_MANAGEMENT_ROLE_HOLDER) 64 .setPackage(ROLE_HOLDER_UPDATER_PACKAGE_NAME) 65 .putExtra(EXTRA_FORCE_UPDATE_ROLE_HOLDER, true) 66 .putExtra(EXTRA_PROVISIONING_TRIGGER, TEST_PROVISIONING_TRIGGER); 67 public static final String TEST_EXTRA_KEY = "test_extra_key"; 68 public static final String TEST_EXTRA_VALUE = "test_extra_value"; 69 private static final Intent MANAGED_PROFILE_INTENT = 70 new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE) 71 .putExtra(TEST_EXTRA_KEY, TEST_EXTRA_VALUE); 72 private static final Intent FINANCED_DEVICE_INTENT = 73 new Intent(DevicePolicyManager.ACTION_PROVISION_FINANCED_DEVICE) 74 .putExtra(TEST_EXTRA_KEY, TEST_EXTRA_VALUE); 75 private static final Intent PROVISION_TRUSTED_SOURCE_INTENT = 76 new Intent(DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE_FROM_TRUSTED_SOURCE) 77 .putExtra(TEST_EXTRA_KEY, TEST_EXTRA_VALUE); 78 private static final Intent MANAGED_PROVISIONING_INTENT = MANAGED_PROFILE_INTENT; 79 private static final ComponentName ADMIN = new ComponentName("com.test.admin", ".Receiver"); 80 private static final ProvisioningParams PARAMS = ProvisioningParams.Builder.builder() 81 .setProvisioningAction(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE) 82 .setDeviceAdminComponentName(ADMIN) 83 .build(); 84 private static final String TEST_DOWNLOAD_LOCATION = 85 "http://example/dpc.apk"; 86 private static final String TEST_COOKIE_HEADER = 87 "Set-Cookie: sessionToken=foobar; Expires=Thu, 18 Feb 2016 23:59:59 GMT"; 88 private static final byte[] TEST_SIGNATURE_CHECKSUM = new byte[] { '5', '4', '3', '2', '1' }; 89 private static final PackageDownloadInfo ROLE_HOLDER_DOWNLOAD_INFO = 90 PackageDownloadInfo.Builder.builder() 91 .setLocation(TEST_DOWNLOAD_LOCATION) 92 .setSignatureChecksum(TEST_SIGNATURE_CHECKSUM) 93 .setCookieHeader(TEST_COOKIE_HEADER) 94 .build(); 95 private static final ProvisioningParams PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO = 96 ProvisioningParams.Builder.builder() 97 .setProvisioningAction(DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE) 98 .setDeviceAdminComponentName(ADMIN) 99 .setRoleHolderDownloadInfo(ROLE_HOLDER_DOWNLOAD_INFO) 100 .build(); 101 102 private final Context mContext = ApplicationProvider.getApplicationContext(); 103 private boolean mCanDelegateProvisioningToRoleHolder; 104 105 @Before setUp()106 public void setUp() { 107 enableRoleHolderDelegation(); 108 } 109 110 @Test roleHolderHelperConstructor_roleHolderPackageNameNull_noExceptionThrown()111 public void roleHolderHelperConstructor_roleHolderPackageNameNull_noExceptionThrown() { 112 createRoleHolderUpdaterHelperWithUpdaterPackageName(ROLE_HOLDER_UPDATER_NULL_PACKAGE_NAME); 113 } 114 115 @Test roleHolderHelperConstructor_roleHolderPackageNameEmpty_noExceptionThrown()116 public void roleHolderHelperConstructor_roleHolderPackageNameEmpty_noExceptionThrown() { 117 createRoleHolderUpdaterHelperWithUpdaterPackageName(ROLE_HOLDER_UPDATER_EMPTY_PACKAGE_NAME); 118 } 119 120 @Test shouldStartRoleHolderUpdater_works()121 public void shouldStartRoleHolderUpdater_works() { 122 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 123 createRoleHolderUpdaterHelper(); 124 125 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 126 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isTrue(); 127 } 128 129 @Test shouldStartRoleHolderUpdater_managedProfileIntent_works()130 public void shouldStartRoleHolderUpdater_managedProfileIntent_works() { 131 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 132 createRoleHolderUpdaterHelper(); 133 134 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 135 mContext, MANAGED_PROFILE_INTENT, PARAMS)).isTrue(); 136 } 137 138 @Test shouldStartRoleHolderUpdater_trustedSourceIntent_works()139 public void shouldStartRoleHolderUpdater_trustedSourceIntent_works() { 140 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 141 createRoleHolderUpdaterHelper(); 142 143 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 144 mContext, PROVISION_TRUSTED_SOURCE_INTENT, PARAMS)).isTrue(); 145 } 146 147 @Test shouldStartRoleHolderUpdater_financedDeviceIntent_returnsFalse()148 public void shouldStartRoleHolderUpdater_financedDeviceIntent_returnsFalse() { 149 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 150 createRoleHolderUpdaterHelper(); 151 152 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 153 mContext, FINANCED_DEVICE_INTENT, PARAMS)).isFalse(); 154 } 155 156 @Test shouldStartRoleHolderUpdater_nullRoleHolderPackageName_returnsFalse()157 public void shouldStartRoleHolderUpdater_nullRoleHolderPackageName_returnsFalse() { 158 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 159 createRoleHolderUpdaterHelperWithRoleHolderPackageName( 160 ROLE_HOLDER_NULL_PACKAGE_NAME); 161 162 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 163 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 164 } 165 166 @Test shouldStartRoleHolderUpdater_emptyRoleHolderPackageName_returnsFalse()167 public void shouldStartRoleHolderUpdater_emptyRoleHolderPackageName_returnsFalse() { 168 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 169 createRoleHolderUpdaterHelperWithRoleHolderPackageName( 170 ROLE_HOLDER_EMPTY_PACKAGE_NAME); 171 172 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 173 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 174 } 175 176 @Test shouldStartRoleHolderUpdater_nullRoleHolderUpdaterPackageName_returnsFalse()177 public void shouldStartRoleHolderUpdater_nullRoleHolderUpdaterPackageName_returnsFalse() { 178 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 179 createRoleHolderUpdaterHelperWithUpdaterPackageName( 180 ROLE_HOLDER_UPDATER_NULL_PACKAGE_NAME); 181 182 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 183 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 184 } 185 186 @Test shouldStartRoleHolderUpdater_emptyRoleHolderUpdaterPackageName_returnsFalse()187 public void shouldStartRoleHolderUpdater_emptyRoleHolderUpdaterPackageName_returnsFalse() { 188 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 189 createRoleHolderUpdaterHelperWithUpdaterPackageName( 190 ROLE_HOLDER_UPDATER_EMPTY_PACKAGE_NAME); 191 192 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 193 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 194 } 195 196 @Test shouldStartRoleHolderUpdater_roleHolderDelegationDisabled_returnsFalse()197 public void shouldStartRoleHolderUpdater_roleHolderDelegationDisabled_returnsFalse() { 198 disableRoleHolderDelegation(); 199 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 200 createRoleHolderUpdaterHelper(); 201 202 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 203 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 204 } 205 206 @Test shouldStartRoleHolderUpdater_roleHolderUpdaterNotInstalled_returnsFalse()207 public void shouldStartRoleHolderUpdater_roleHolderUpdaterNotInstalled_returnsFalse() { 208 disableRoleHolderDelegation(); 209 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 210 createRoleHolderUpdaterHelperWithUpdaterNotInstalled(); 211 212 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 213 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 214 } 215 216 @Test shouldStartRoleHolderUpdater_roleHolderUpdaterNotResolvable_returnsFalse()217 public void shouldStartRoleHolderUpdater_roleHolderUpdaterNotResolvable_returnsFalse() { 218 disableRoleHolderDelegation(); 219 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 220 createRoleHolderUpdaterHelperWithUpdaterNotResolvable(); 221 222 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 223 mContext, MANAGED_PROVISIONING_INTENT, PARAMS)).isFalse(); 224 } 225 226 @Test shouldStartRoleHolderUpdater_withRoleHolderDownloadInfo_returnsFalse()227 public void shouldStartRoleHolderUpdater_withRoleHolderDownloadInfo_returnsFalse() { 228 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 229 createRoleHolderUpdaterHelper(); 230 231 assertThat(roleHolderUpdaterHelper.shouldStartRoleHolderUpdater( 232 mContext, PROVISION_TRUSTED_SOURCE_INTENT, 233 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 234 } 235 236 @Test createRoleHolderUpdaterIntent_works()237 public void createRoleHolderUpdaterIntent_works() { 238 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 239 createRoleHolderUpdaterHelper(); 240 241 assertIntentsEqual( 242 roleHolderUpdaterHelper.createRoleHolderUpdaterIntent( 243 /* parentActivityIntent= */ null, 244 TEST_PROVISIONING_TRIGGER, 245 /* isRoleHolderRequestedUpdate= */ false), 246 ROLE_HOLDER_UPDATER_INTENT); 247 } 248 249 @Test createRoleHolderUpdaterIntent_withForceUpdate_works()250 public void createRoleHolderUpdaterIntent_withForceUpdate_works() { 251 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 252 createRoleHolderUpdaterHelper(); 253 254 assertIntentsEqual( 255 roleHolderUpdaterHelper.createRoleHolderUpdaterIntent( 256 /* parentActivityIntent= */ null, 257 TEST_PROVISIONING_TRIGGER, 258 /* isRoleHolderRequestedUpdate= */ true), 259 ROLE_HOLDER_UPDATER_INTENT_WITH_FORCE_UPDATE); 260 } 261 262 @Test createRoleHolderUpdaterIntent_nullRoleHolderUpdaterPackageName_throwsException()263 public void createRoleHolderUpdaterIntent_nullRoleHolderUpdaterPackageName_throwsException() { 264 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 265 createRoleHolderUpdaterHelperWithUpdaterPackageName( 266 ROLE_HOLDER_UPDATER_NULL_PACKAGE_NAME); 267 268 assertThrows(IllegalStateException.class, 269 () -> roleHolderUpdaterHelper.createRoleHolderUpdaterIntent( 270 /* parentActivityIntent= */ null, 271 TEST_PROVISIONING_TRIGGER, 272 /* isRoleHolderRequestedUpdate= */ false)); 273 } 274 275 @Test createRoleHolderUpdaterIntent_emptyRoleHolderUpdaterPackageName_throwsException()276 public void createRoleHolderUpdaterIntent_emptyRoleHolderUpdaterPackageName_throwsException() { 277 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 278 createRoleHolderUpdaterHelperWithUpdaterPackageName( 279 ROLE_HOLDER_UPDATER_EMPTY_PACKAGE_NAME); 280 281 assertThrows(IllegalStateException.class, 282 () -> roleHolderUpdaterHelper.createRoleHolderUpdaterIntent( 283 /* parentActivityIntent= */ null, 284 TEST_PROVISIONING_TRIGGER, 285 /* isRoleHolderRequestedUpdate= */ false)); 286 } 287 288 @Test shouldPlatformDownloadRoleHolder_works()289 public void shouldPlatformDownloadRoleHolder_works() { 290 enableRoleHolderDelegation(); 291 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 292 createRoleHolderUpdaterHelper(); 293 294 assertThat(roleHolderUpdaterHelper 295 .shouldPlatformDownloadRoleHolder( 296 PROVISION_TRUSTED_SOURCE_INTENT, 297 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isTrue(); 298 } 299 300 @Test shouldPlatformDownloadRoleHolder_noRoleHolderDownloadInfoSupplied_returnsFalse()301 public void shouldPlatformDownloadRoleHolder_noRoleHolderDownloadInfoSupplied_returnsFalse() { 302 enableRoleHolderDelegation(); 303 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 304 createRoleHolderUpdaterHelper(); 305 306 assertThat(roleHolderUpdaterHelper 307 .shouldPlatformDownloadRoleHolder(PROVISION_TRUSTED_SOURCE_INTENT, PARAMS)) 308 .isFalse(); 309 } 310 311 @Test shouldPlatformDownloadRoleHolder_managedProfileIntent_returnsFalse()312 public void shouldPlatformDownloadRoleHolder_managedProfileIntent_returnsFalse() { 313 enableRoleHolderDelegation(); 314 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 315 createRoleHolderUpdaterHelper(); 316 317 assertThat(roleHolderUpdaterHelper 318 .shouldPlatformDownloadRoleHolder( 319 MANAGED_PROFILE_INTENT, 320 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 321 } 322 323 @Test shouldPlatformDownloadRoleHolder_financedDeviceIntent_returnsFalse()324 public void shouldPlatformDownloadRoleHolder_financedDeviceIntent_returnsFalse() { 325 enableRoleHolderDelegation(); 326 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 327 createRoleHolderUpdaterHelper(); 328 329 assertThat(roleHolderUpdaterHelper 330 .shouldPlatformDownloadRoleHolder( 331 FINANCED_DEVICE_INTENT, 332 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 333 } 334 335 @Test shouldPlatformDownloadRoleHolder_featureFlagDisabled_returnsFalse()336 public void shouldPlatformDownloadRoleHolder_featureFlagDisabled_returnsFalse() { 337 disableRoleHolderDelegation(); 338 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 339 createRoleHolderUpdaterHelper(); 340 341 assertThat(roleHolderUpdaterHelper 342 .shouldPlatformDownloadRoleHolder( 343 PROVISION_TRUSTED_SOURCE_INTENT, 344 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 345 } 346 347 @Test shouldPlatformDownloadRoleHolder_emptyRoleHolderPackage_returnsFalse()348 public void shouldPlatformDownloadRoleHolder_emptyRoleHolderPackage_returnsFalse() { 349 disableRoleHolderDelegation(); 350 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 351 createRoleHolderUpdaterHelperWithRoleHolderPackageName( 352 ROLE_HOLDER_EMPTY_PACKAGE_NAME); 353 354 assertThat(roleHolderUpdaterHelper 355 .shouldPlatformDownloadRoleHolder( 356 PROVISION_TRUSTED_SOURCE_INTENT, 357 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 358 } 359 360 @Test shouldPlatformDownloadRoleHolder_nullRoleHolderPackage_returnsFalse()361 public void shouldPlatformDownloadRoleHolder_nullRoleHolderPackage_returnsFalse() { 362 disableRoleHolderDelegation(); 363 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 364 createRoleHolderUpdaterHelperWithRoleHolderPackageName( 365 ROLE_HOLDER_NULL_PACKAGE_NAME); 366 367 assertThat(roleHolderUpdaterHelper 368 .shouldPlatformDownloadRoleHolder( 369 PROVISION_TRUSTED_SOURCE_INTENT, 370 PARAMS_WITH_ROLE_HOLDER_DOWNLOAD_INFO)).isFalse(); 371 } 372 373 @Test isRoleHolderUpdaterDefined_actuallyDefined_returnsTrue()374 public void isRoleHolderUpdaterDefined_actuallyDefined_returnsTrue() { 375 enableRoleHolderDelegation(); 376 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 377 createRoleHolderUpdaterHelper(); 378 379 assertThat(roleHolderUpdaterHelper.isRoleHolderUpdaterDefined()).isTrue(); 380 } 381 382 @Test isRoleHolderUpdaterDefined_actuallyNotDefined_returnsFalse()383 public void isRoleHolderUpdaterDefined_actuallyNotDefined_returnsFalse() { 384 enableRoleHolderDelegation(); 385 DeviceManagementRoleHolderUpdaterHelper roleHolderUpdaterHelper = 386 createRoleHolderUpdaterHelperWithUpdaterPackageName( 387 ROLE_HOLDER_UPDATER_EMPTY_PACKAGE_NAME); 388 389 assertThat(roleHolderUpdaterHelper.isRoleHolderUpdaterDefined()).isFalse(); 390 } 391 createFeatureFlagChecker()392 private FeatureFlagChecker createFeatureFlagChecker() { 393 return () -> mCanDelegateProvisioningToRoleHolder; 394 } 395 396 private DeviceManagementRoleHolderUpdaterHelper createRoleHolderUpdaterHelperWithUpdaterPackageName( String packageName)397 createRoleHolderUpdaterHelperWithUpdaterPackageName( 398 String packageName) { 399 return new DeviceManagementRoleHolderUpdaterHelper( 400 packageName, 401 ROLE_HOLDER_PACKAGE_NAME, 402 /* packageInstallChecker= */ (roleHolderPackageName) -> true, 403 /* intentResolverChecker= */ (intent) -> true, 404 createFeatureFlagChecker()); 405 } 406 407 private DeviceManagementRoleHolderUpdaterHelper createRoleHolderUpdaterHelperWithRoleHolderPackageName( String roleHolderPackageName)408 createRoleHolderUpdaterHelperWithRoleHolderPackageName( 409 String roleHolderPackageName) { 410 return new DeviceManagementRoleHolderUpdaterHelper( 411 ROLE_HOLDER_UPDATER_PACKAGE_NAME, 412 roleHolderPackageName, 413 /* packageInstallChecker= */ (packageName) -> true, 414 /* intentResolverChecker= */ (intent) -> true, 415 createFeatureFlagChecker()); 416 } 417 createRoleHolderUpdaterHelper()418 private DeviceManagementRoleHolderUpdaterHelper createRoleHolderUpdaterHelper() { 419 return new DeviceManagementRoleHolderUpdaterHelper( 420 ROLE_HOLDER_UPDATER_PACKAGE_NAME, 421 ROLE_HOLDER_PACKAGE_NAME, 422 /* packageInstallChecker= */ (roleHolderPackageName) -> true, 423 /* intentResolverChecker= */ (intent) -> true, 424 createFeatureFlagChecker()); 425 } 426 427 private DeviceManagementRoleHolderUpdaterHelper createRoleHolderUpdaterHelperWithUpdaterNotInstalled()428 createRoleHolderUpdaterHelperWithUpdaterNotInstalled() { 429 return new DeviceManagementRoleHolderUpdaterHelper( 430 ROLE_HOLDER_UPDATER_PACKAGE_NAME, 431 ROLE_HOLDER_PACKAGE_NAME, 432 /* packageInstallChecker= */ (roleHolderPackageName) -> false, 433 /* intentResolverChecker= */ (intent) -> true, 434 createFeatureFlagChecker()); 435 } 436 437 private DeviceManagementRoleHolderUpdaterHelper createRoleHolderUpdaterHelperWithUpdaterNotResolvable()438 createRoleHolderUpdaterHelperWithUpdaterNotResolvable() { 439 return new DeviceManagementRoleHolderUpdaterHelper( 440 ROLE_HOLDER_UPDATER_PACKAGE_NAME, 441 ROLE_HOLDER_PACKAGE_NAME, 442 /* packageInstallChecker= */ (roleHolderPackageName) -> true, 443 /* intentResolverChecker= */ (intent) -> false, 444 createFeatureFlagChecker()); 445 } 446 enableRoleHolderDelegation()447 private void enableRoleHolderDelegation() { 448 mCanDelegateProvisioningToRoleHolder = true; 449 } 450 disableRoleHolderDelegation()451 private void disableRoleHolderDelegation() { 452 mCanDelegateProvisioningToRoleHolder = false; 453 } 454 } 455